Skip to content

Commit

Permalink
Fix _sasl_add_string
Browse files Browse the repository at this point in the history
Issue #587 was not solved correctly.

_sasl_add_string adds zero terminator to the output string.
This cuts log messages after the first '%s' of the format string.
With the fix the function _sasl_log now logs the complete message.

Signed-off-by: Howard Chu <[email protected]>
  • Loading branch information
hyc committed Sep 22, 2021
1 parent cafec3c commit d514c1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ int _sasl_add_string(char **out, size_t *alloclen,

if (add==NULL) add = "(null)";

addlen=strlen(add)+1; /* only compute once */
if (_buf_alloc(out, alloclen, (*outlen)+addlen)!=SASL_OK)
addlen=strlen(add); /* only compute once */
if (_buf_alloc(out, alloclen, (*outlen)+addlen+1)!=SASL_OK)
return SASL_NOMEM;

strncpy(*out + *outlen, add, addlen);
*outlen += addlen-1;
strcpy(*out + *outlen, add);
*outlen += addlen;

return SASL_OK;
}
Expand Down

0 comments on commit d514c1a

Please sign in to comment.