laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/26726 )

Change subject: logging: Fix Not enough tailroom msgb_put in _output_buf callers
......................................................................

logging: Fix Not enough tailroom msgb_put in _output_buf callers

The function clearly specified in its documentation that the number of
bytes written to the out buffer were being returned. However, the value
returned was "the number of characters (excluding the terminating null
byte) which would have been written to the final string if enough space
had been available.", aka snprintf-style.
The 2 callers of that function were not expecting it, so if a long
enough buffer was passed, the program asserted.

Closes: OS#5383
Change-Id: I8d71bd1a0dad37606acb8302b05c2ae338112e57
---
M src/logging.c
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/logging.c b/src/logging.c
index e5c66f2..24b5553 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -601,7 +601,8 @@
                OSMO_SNPRINTF_RET(ret, rem, offset, len);
        }
 err:
-       buf[buf_len-1] = '\0';
+       len = OSMO_MIN(buf_len - 1, len);
+       buf[len] = '\0';
        return len;
 }


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26726
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8d71bd1a0dad37606acb8302b05c2ae338112e57
Gerrit-Change-Number: 26726
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-MessageType: merged

Reply via email to