aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-03-08 11:24:22 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2025-03-08 11:24:25 -0500
commit7fb880102138e45f58bf626cb2a4599bade8b172 (patch)
treed9c2c29649a2b4b48c9260da8f68f893aa08a42d /src
parent67fc4c9fd7fab7004b656e0cc27826c75d7ea7ad (diff)
downloadpostgresql-7fb880102138e45f58bf626cb2a4599bade8b172.tar.gz
postgresql-7fb880102138e45f58bf626cb2a4599bade8b172.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/tsearch/spell.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c
index 018b66d2c69..146801885d7 100644
--- a/src/backend/tsearch/spell.c
+++ b/src/backend/tsearch/spell.c
@@ -375,6 +375,7 @@ getNextFlagFromString(IspellDict *Conf, const char **sflagset, char *sflag)
stop = (maxstep == 0);
break;
case FM_NUM:
+ errno = 0;
s = strtol(*sflagset, &next, 10);
if (*sflagset == next || errno == ERANGE)
ereport(ERROR,
@@ -1037,6 +1038,7 @@ setCompoundAffixFlagValue(IspellDict *Conf, CompoundAffixFlag *entry,
char *next;
int i;
+ errno = 0;
i = strtol(s, &next, 10);
if (s == next || errno == ERANGE)
ereport(ERROR,
@@ -1164,6 +1166,7 @@ getAffixFlagSet(IspellDict *Conf, char *s)
int curaffix;
char *end;
+ errno = 0;
curaffix = strtol(s, &end, 10);
if (s == end || errno == ERANGE)
ereport(ERROR,
@@ -1740,6 +1743,7 @@ NISortDictionary(IspellDict *Conf)
if (*Conf->Spell[i]->p.flag != '\0')
{
+ errno = 0;
curaffix = strtol(Conf->Spell[i]->p.flag, &end, 10);
if (Conf->Spell[i]->p.flag == end || errno == ERANGE)
ereport(ERROR,