mirror of
https://github.com/postgres/postgres.git
synced 2025-05-21 15:54:08 +03:00
Clear errno before calling strtol() in spell.c.
Per POSIX, a caller of strtol() that wishes to check for errors must set errno to 0 beforehand. Several places in spell.c neglected that, so that they risked delivering a false overflow error in case errno had been ERANGE already. Given the lack of field reports, this case may be unreachable at present --- but it's surely trouble waiting to happen, so fix it. Author: Jacob Brazeal <jacob.brazeal@gmail.com> Discussion: https://postgr.es/m/CA+COZaBhsq6EromFm+knMJfzK6nTpG23zJ+K2=nfUQQXcj_xcQ@mail.gmail.com Backpatch-through: 13
This commit is contained in:
parent
c3510cfc8b
commit
99c01aadf9
@ -374,6 +374,7 @@ getNextFlagFromString(IspellDict *Conf, char **sflagset, char *sflag)
|
|||||||
stop = (maxstep == 0);
|
stop = (maxstep == 0);
|
||||||
break;
|
break;
|
||||||
case FM_NUM:
|
case FM_NUM:
|
||||||
|
errno = 0;
|
||||||
s = strtol(*sflagset, &next, 10);
|
s = strtol(*sflagset, &next, 10);
|
||||||
if (*sflagset == next || errno == ERANGE)
|
if (*sflagset == next || errno == ERANGE)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1036,6 +1037,7 @@ setCompoundAffixFlagValue(IspellDict *Conf, CompoundAffixFlag *entry,
|
|||||||
char *next;
|
char *next;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
i = strtol(s, &next, 10);
|
i = strtol(s, &next, 10);
|
||||||
if (s == next || errno == ERANGE)
|
if (s == next || errno == ERANGE)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1163,6 +1165,7 @@ getAffixFlagSet(IspellDict *Conf, char *s)
|
|||||||
int curaffix;
|
int curaffix;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
curaffix = strtol(s, &end, 10);
|
curaffix = strtol(s, &end, 10);
|
||||||
if (s == end || errno == ERANGE)
|
if (s == end || errno == ERANGE)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -1735,6 +1738,7 @@ NISortDictionary(IspellDict *Conf)
|
|||||||
|
|
||||||
if (*Conf->Spell[i]->p.flag != '\0')
|
if (*Conf->Spell[i]->p.flag != '\0')
|
||||||
{
|
{
|
||||||
|
errno = 0;
|
||||||
curaffix = strtol(Conf->Spell[i]->p.flag, &end, 10);
|
curaffix = strtol(Conf->Spell[i]->p.flag, &end, 10);
|
||||||
if (Conf->Spell[i]->p.flag == end || errno == ERANGE)
|
if (Conf->Spell[i]->p.flag == end || errno == ERANGE)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user