Not over yet, but added some more bound checks in string processing. master
authorMatthew Mondor <mmondor@pulsar-zone.net>
Fri, 2 Sep 2016 01:21:05 +0000 (01:21 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Fri, 2 Sep 2016 01:21:05 +0000 (01:21 +0000)
commitdc2ab34ef58d6e3a9bc5b95b778a3b9ff8fc3f45
tree057e39d42c6e4f358835b7da44b86dbbfd5c39b4
parentb52612ced85bff8db0a702d8829b594ac12f2c7e
Not over yet, but added some more bound checks in string processing.

The old pre-stdio bounded snprintf(3)/vsnprintf(3) custom code
returned the actual length that could be written.  On the other
hand, stdio oddly returns "what could have been written".  This is
problematic in loops that expect a short write when a buffer overflow
is mitigated, where the next call can become out of bounds.  Hence,
instead of directly using these stdio functions, a wrapper function
is now used which returns the actual string length that could be
written (calling strlen(3)), and also make sure that the end of
the buffer ends with '\0'.

prefix_buffer() did no bounds checking at all and this was noted
in its comment; this function now performs bounds checking.
include/ircsprintf.h
src/ircsprintf.c
src/send.c