[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

View File

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