You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const char *
time_to_text(time_t when)
{
struct tm *lt;
static char buf[40];
char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char *month[] = {"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
const char *tz;
long offset;
lt = localtime(&when);
if (lt == NULL || when == 0)
fatalx("time_to_text: localtime");
#if HAVE_STRUCT_TM_TM_GMTOFF
offset = lt->tm_gmtoff;
tz = lt->tm_zone;
#elif defined HAVE_DECL_ALTZONE && defined HAVE_DECL_TIMEZONE
offset = lt->tm_isdst > 0 ? altzone : timezone;
tz = lt->tm_isdst > 0 ? tzname[1] : tzname[0];
#endif
/* We do not use strftime because it is subject to locale substitution*/
if (!bsnprintf(buf, sizeof(buf),
"%s, %d %s %d %02d:%02d:%02d %c%02d%02d (%s)",
day[lt->tm_wday], lt->tm_mday, month[lt->tm_mon],
lt->tm_year + 1900,
lt->tm_hour, lt->tm_min, lt->tm_sec,
offset >= 0 ? '+' : '-',
abs((int)offset / 3600),
abs((int)offset % 3600) / 60,
tz))
fatalx("time_to_text: bsnprintf");
return buf;
}
I don't see where HAVE_STRUCT_TM_TM_GMTOFF or HAVE_DECL_* are defined, so I'm assuming they're undefined. Which means that offset and tz are uninitialized. If tz is null, then printf will print something like this:
Wed, 31 Dec 1969 16:20:34 +0000 ((null))
which is 40 characters, or the exact size of the buffer, causing bsnprintf to fail and print that error. I haven't verified that is happening, but what would be the recommended fix?
The text was updated successfully, but these errors were encountered:
I'm seeing the following log when trying to run opensmtpd on GNU Guix:
Looking at the code, it is print here:
I don't see where HAVE_STRUCT_TM_TM_GMTOFF or HAVE_DECL_* are defined, so I'm assuming they're undefined. Which means that
offset
andtz
are uninitialized. If tz is null, then printf will print something like this:which is 40 characters, or the exact size of the buffer, causing bsnprintf to fail and print that error. I haven't verified that is happening, but what would be the recommended fix?
The text was updated successfully, but these errors were encountered: