Skip to content

Commit 99c01aa

Browse files
committed
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
1 parent c3510cf commit 99c01aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/tsearch/spell.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ getNextFlagFromString(IspellDict *Conf, char **sflagset, char *sflag)
374374
stop = (maxstep == 0);
375375
break;
376376
case FM_NUM:
377+
errno = 0;
377378
s = strtol(*sflagset, &next, 10);
378379
if (*sflagset == next || errno == ERANGE)
379380
ereport(ERROR,
@@ -1036,6 +1037,7 @@ setCompoundAffixFlagValue(IspellDict *Conf, CompoundAffixFlag *entry,
10361037
char *next;
10371038
int i;
10381039

1040+
errno = 0;
10391041
i = strtol(s, &next, 10);
10401042
if (s == next || errno == ERANGE)
10411043
ereport(ERROR,
@@ -1163,6 +1165,7 @@ getAffixFlagSet(IspellDict *Conf, char *s)
11631165
int curaffix;
11641166
char *end;
11651167

1168+
errno = 0;
11661169
curaffix = strtol(s, &end, 10);
11671170
if (s == end || errno == ERANGE)
11681171
ereport(ERROR,
@@ -1735,6 +1738,7 @@ NISortDictionary(IspellDict *Conf)
17351738

17361739
if (*Conf->Spell[i]->p.flag != '\0')
17371740
{
1741+
errno = 0;
17381742
curaffix = strtol(Conf->Spell[i]->p.flag, &end, 10);
17391743
if (Conf->Spell[i]->p.flag == end || errno == ERANGE)
17401744
ereport(ERROR,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy