[locale] Corrected return value check.

Message ID 20220331193701.493824-1-d.chestnyh@omp.ru
State New
Headers
Series [locale] Corrected return value check. |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Dmitry Chestnyh March 31, 2022, 7:37 p.m. UTC
  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(-)
  

Patch

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.  */