Skip to content

Commit

Permalink
Correct fix for #878
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jan 17, 2015
1 parent c205627 commit e908f71
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib/print.c
Expand Up @@ -206,10 +206,13 @@ size_t fr_prints(char *out, size_t outlen, char const *in, ssize_t inlen, char q
* don't overflow the output buffer.
*/
if (!quote) {
if ((size_t) inlen >= outlen) inlen = outlen - 1;

memcpy(out, in, inlen);
out[inlen] = '\0';
if ((size_t)inlen >= outlen) {
memcpy(out, in, outlen - 1);
out[outlen - 1] = '\0';
} else {
memcpy(out, in, inlen);
out[inlen] = '\0';
}
return inlen;
}

Expand Down Expand Up @@ -337,6 +340,8 @@ size_t fr_prints_len(char const *in, ssize_t inlen, char quote)

if (inlen < 0) inlen = strlen(in);

if (!quote) return inlen + 1;

while (inlen > 0) {
int sp = 0;

Expand Down

0 comments on commit e908f71

Please sign in to comment.