mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
d841bec8d2
commit
beaf2a2839
|
@ -601,7 +601,8 @@ static int _output_buf(char *buf, int buf_len, struct log_target *target, unsign
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue