Eggert mods

SCCS-file: localtime.c
SCCS-SID: 7.64
This commit is contained in:
Arthur David Olson
2012-07-18 03:02:29 -04:00
committed by Paul Eggert
parent 8886f04e5f
commit 5bace33a24
+13 -17
View File
@@ -302,27 +302,23 @@ register struct state * const sp;
}
{
struct tzhead * tzhp;
char buf[sizeof *sp + sizeof *tzhp];
union {
struct tzhead tzhead;
char buf[sizeof *sp + sizeof *tzhp];
} u;
int ttisstdcnt;
int ttisgmtcnt;
i = read(fid, buf, sizeof buf);
i = read(fid, u.buf, sizeof u.buf);
if (close(fid) != 0)
return -1;
p = buf;
p += sizeof tzhp->tzh_reserved;
ttisstdcnt = (int) detzcode(p);
p += 4;
ttisgmtcnt = (int) detzcode(p);
p += 4;
sp->leapcnt = (int) detzcode(p);
p += 4;
sp->timecnt = (int) detzcode(p);
p += 4;
sp->typecnt = (int) detzcode(p);
p += 4;
sp->charcnt = (int) detzcode(p);
p += 4;
ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt);
sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt);
sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt);
p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt;
if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
@@ -330,7 +326,7 @@ register struct state * const sp;
(ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
(ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
return -1;
if (i - (p - buf) < sp->timecnt * 4 + /* ats */
if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */
sp->timecnt + /* types */
sp->typecnt * (4 + 2) + /* ttinfos */
sp->charcnt + /* chars */