[post] Return true on truncation

Client can check that buffer was completely filled out and reallocate.
This commit is contained in:
Behdad Esfahbod 2018-11-07 09:16:53 -05:00
parent 7d91f07edf
commit 9d5027696e
1 changed files with 3 additions and 4 deletions

View File

@ -148,10 +148,9 @@ struct post
return false;
if (!buf_len)
return true;
if (buf_len <= s.len) /* What to do with truncation? Returning false for now. */
return false;
strncpy (buf, s.arrayZ, s.len);
buf[s.len] = '\0';
unsigned int len = MIN (buf_len - 1, s.len);
strncpy (buf, s.arrayZ, len);
buf[len] = '\0';
return true;
}