Skip to content

Commit

Permalink
Merge pull request #15 from earlephilhower/onemoretxfix
Browse files Browse the repository at this point in the history
Reduce code slightly and ensure that only names of the form '<...>'
including the terminal '>' are accepted in the parser. Fixes a
potential error handling corner case.
  • Loading branch information
earlephilhower authored Nov 12, 2020
2 parents 83b5db7 + 8af39e3 commit 9905fb5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions newlib/libc/time/tzset_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ _DEFUN (_tzset_r, (reent_ptr),
if (tzenv[0] == '<')
{
/* This is of the form "<[+-]nn>" so needs a different parsing */
if (sscanf (tzenv, "%9[^>]%n", __tzname_std, &n) <= 0)
if (sscanf (tzenv, "%9[^>]>%n", __tzname_std, &n) <= 0)
{
TZ_UNLOCK;
return;
}
/* Include the final > and skip it */
/* Include the final > */
strcat (__tzname_std, ">");
n++;
}
else
{
Expand Down Expand Up @@ -101,17 +100,16 @@ _DEFUN (_tzset_r, (reent_ptr),
if (tzenv[0] == '<')
{
/* This is of the form "<[+-]nn>" so needs a different parsing */
if (sscanf (tzenv, "%9[^>]%n", __tzname_dst, &n) <= 0)
if (sscanf (tzenv, "%9[^>]>%n", __tzname_dst, &n) <= 0)
{ /* No dst */
_tzname[1] = _tzname[0];
_timezone = tz->__tzrule[0].offset;
_daylight = 0;
TZ_UNLOCK;
return;
}
/* Include the final > and skip it */
/* Include the final > */
strcat (__tzname_dst, ">");
n++;
_tzname[1] = __tzname_dst;
}
else
Expand Down

0 comments on commit 9905fb5

Please sign in to comment.