Fixed a null pointer bug in rev.1.10. Rev.1.10 was supposed to to
move the "for safety" zeroing of unused members of timebuf to a better place. It actually moved the zeroing to a worse place and didn't add necessary braces. Fixed a nearby older bug. timebuf.tm_gmtoff was sometimes used even when timebuf was invalid. Even when it is zeroed, a failing mktime() might set it to nonzero. PR: 25243
This commit is contained in:
parent
bcc4358845
commit
09f59dfc92
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75178
@ -512,6 +512,7 @@ remotemodtime(file, noisy)
|
||||
if (debug == 0)
|
||||
verbose = -1;
|
||||
if (command("MDTM %s", file) == COMPLETE) {
|
||||
memset(&timebuf, 0, sizeof(timebuf));
|
||||
/*
|
||||
* Parse the time string, which is expected to be 14
|
||||
* characters long. Some broken servers send tm_year
|
||||
@ -529,8 +530,7 @@ remotemodtime(file, noisy)
|
||||
y2kbug = 1;
|
||||
} else if (len == 14)
|
||||
fmt = "%04d%02d%02d%02d%02d%02d";
|
||||
if (fmt != NULL)
|
||||
memset(&timebuf, 0, sizeof(timebuf));
|
||||
if (fmt != NULL) {
|
||||
if (sscanf(mtbuf, fmt, &year, &month,
|
||||
&timebuf.tm_mday, &timebuf.tm_hour,
|
||||
&timebuf.tm_min, &timebuf.tm_sec) == 6) {
|
||||
@ -543,9 +543,11 @@ remotemodtime(file, noisy)
|
||||
rtime = mktime(&timebuf);
|
||||
}
|
||||
}
|
||||
if (rtime == -1 && (noisy || debug != 0))
|
||||
}
|
||||
if (rtime == -1) {
|
||||
if (noisy || debug != 0)
|
||||
printf("Can't convert %s to a time.\n", mtbuf);
|
||||
else
|
||||
} else
|
||||
rtime += timebuf.tm_gmtoff; /* conv. local -> GMT */
|
||||
} else if (noisy && debug == 0)
|
||||
puts(reply_string);
|
||||
|
Loading…
Reference in New Issue
Block a user