diff options
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -235,22 +235,24 @@ buf_puts(struct buffer *buf, const char *str) * This is necessary due to certain buggy implementations of snprintf, * that don't guarantee null termination for size > 0. * + * Return false on overflow. + * * This function is duplicated into service-win32/openvpnserv.c * Any modifications here should be done to the other place as well. */ -int openvpn_snprintf(char *str, size_t size, const char *format, ...) +bool openvpn_snprintf(char *str, size_t size, const char *format, ...) { va_list arglist; - int ret = 0; + int len = -1; if (size > 0) { va_start (arglist, format); - ret = vsnprintf (str, size, format, arglist); + len = vsnprintf (str, size, format, arglist); va_end (arglist); str[size - 1] = 0; } - return ret; + return (len >= 0 && len < size); } /* |