* [PATCH] [locale] Corrected return value check.
@ 2022-04-01 5:46 Dmitry Chestnyh
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Chestnyh @ 2022-04-01 5:46 UTC (permalink / raw)
To: libc-alpha; +Cc: Dmitry Chestnyh
strtol returns LONG_MAX or LONG_MIN on
ERANGE error.
strtoul can return ULONG_MAX on ERANGE error.
This issue was found by SVACE static analyzer.
---
locale/programs/ld-collate.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 992814491d..4c401c9268 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1344,12 +1344,12 @@ order for `%.*s' already defined at %s:%Zu"),
errno = 0;
from = strtol (startp->name + preflen, &cp, base);
- if ((from == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((from == LONG_MAX || from == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
errno = 0;
to = strtol (endp->name + preflen, &cp, base);
- if ((to == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((to == LONG_MAX || to == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
/* Copy the prefix. */
@@ -2934,13 +2934,13 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
symbol[symbol_len] = '\0';
from = strtoul (&symbol[prefixlen], &endp,
ellipsis == tok_ellipsis2 ? 16 : 10);
- if (*endp != '\0')
+ if ((from == ULONG_MAX && errno == ERANGE) || *endp != '\0')
goto col_sym_inv_range;
endsymbol[symbol_len] = '\0';
to = strtoul (&endsymbol[prefixlen], &endp,
ellipsis == tok_ellipsis2 ? 16 : 10);
- if (*endp != '\0')
+ if ((to == ULONG_MAX && errno == ERANGE) || *endp != '\0')
goto col_sym_inv_range;
if (from > to)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] [locale] Corrected return value check.
@ 2022-03-31 19:47 Dmitry Chestnyh
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Chestnyh @ 2022-03-31 19:47 UTC (permalink / raw)
To: libc-alpha; +Cc: Dmitry Chestnyh
strtol returns LONG_MAX or LONG_MIN on
ERANGE error.
This issue was found by SVACE static analyzer.
---
locale/programs/ld-collate.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 992814491d..349761feb2 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1344,12 +1344,12 @@ order for `%.*s' already defined at %s:%Zu"),
errno = 0;
from = strtol (startp->name + preflen, &cp, base);
- if ((from == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((from == LONG_MAX || from == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
errno = 0;
to = strtol (endp->name + preflen, &cp, base);
- if ((to == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((to == LONG_MAX || to == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
/* Copy the prefix. */
@@ -2934,13 +2934,13 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
symbol[symbol_len] = '\0';
from = strtoul (&symbol[prefixlen], &endp,
ellipsis == tok_ellipsis2 ? 16 : 10);
- if (*endp != '\0')
+ if (((from == LONG_MAX || from == LONG_MIN ) && errno == ERANGE) || *endp != '\0')
goto col_sym_inv_range;
endsymbol[symbol_len] = '\0';
to = strtoul (&endsymbol[prefixlen], &endp,
ellipsis == tok_ellipsis2 ? 16 : 10);
- if (*endp != '\0')
+ if (((to == LONG_MAX || to == LONG_MIN ) && errno == ERANGE) || *endp != '\0')
goto col_sym_inv_range;
if (from > to)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] [locale] Corrected return value check.
@ 2022-03-31 19:37 Dmitry Chestnyh
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Chestnyh @ 2022-03-31 19:37 UTC (permalink / raw)
To: libc-alpha; +Cc: Dmitry Chestnyh
strtol returns LONG_MAX or LONG_MIN on
ERANGE error.
This issue was found by SVACE static analyzer.
---
locale/programs/ld-collate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 992814491d..751435a900 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1344,12 +1344,12 @@ order for `%.*s' already defined at %s:%Zu"),
errno = 0;
from = strtol (startp->name + preflen, &cp, base);
- if ((from == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((from == LONG_MAX || from == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
errno = 0;
to = strtol (endp->name + preflen, &cp, base);
- if ((to == UINT_MAX && errno == ERANGE) || *cp != '\0')
+ if (((to == LONG_MAX || to == LONG_MIN ) && errno == ERANGE) || *cp != '\0')
goto invalid_range;
/* Copy the prefix. */
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-01 5:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 5:46 [PATCH] [locale] Corrected return value check Dmitry Chestnyh
-- strict thread matches above, loose matches on Subject: below --
2022-03-31 19:47 Dmitry Chestnyh
2022-03-31 19:37 Dmitry Chestnyh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).