fix truncated writing warning
@@ -3405,21 +3405,30 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
ftime(&tb);
localtime_s(&t, &tb.time);
#if defined(__MINGW32__)
- snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
+ if (snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
outbound ? 'O' : 'I',
- t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+ t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)) < 0) {
+ free(dump_buf);
+ return (NULL);
+ }
#else
- _snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT,
+ if (_snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT,
outbound ? 'O' : 'I',
- t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+ t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm)) < 0) {
+ free(dump_buf);
+ return (NULL);
+ }
#endif
#else
gettimeofday(&tv, NULL);
sec = (time_t)tv.tv_sec;
localtime_r((const time_t *)&sec, &t);
- snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
+ if (snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
outbound ? 'O' : 'I',
- t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec);
+ t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec) < 0) {
+ free(dump_buf);
+ return (NULL);
+ }
#endif
pos += PREAMBLE_LENGTH;
#if defined(_WIN32) && !defined(__MINGW32__)
