Blame SOURCES/0259-lib-xatonum-Bail-out-with-null-strings.patch

4b6aa8
From eba5c78b217d29f8e5ad7238b3b3b16d2e3edaaf Mon Sep 17 00:00:00 2001
4b6aa8
From: Ernestas Kulik <ekulik@redhat.com>
4b6aa8
Date: Wed, 29 May 2019 09:12:01 +0200
4b6aa8
Subject: [PATCH] lib: xatonum: Bail out with null strings
4b6aa8
4b6aa8
Signed-off-by: Ernestas Kulik <ekulik@redhat.com>
4b6aa8
---
4b6aa8
 src/lib/xatonum.c | 10 ++++++++++
4b6aa8
 1 file changed, 10 insertions(+)
4b6aa8
4b6aa8
diff --git a/src/lib/xatonum.c b/src/lib/xatonum.c
4b6aa8
index 71b0247..c00b601 100644
4b6aa8
--- a/src/lib/xatonum.c
4b6aa8
+++ b/src/lib/xatonum.c
4b6aa8
@@ -28,6 +28,9 @@ unsigned xatou(const char *numstr)
4b6aa8
     int old_errno;
4b6aa8
     char *e;
4b6aa8
 
4b6aa8
+    if (NULL == numstr)
4b6aa8
+        error_msg_and_die("converting null string to integer");
4b6aa8
+
4b6aa8
     if (*numstr < '0' || *numstr > '9')
4b6aa8
         goto inval;
4b6aa8
 
4b6aa8
@@ -46,6 +49,10 @@ inval:
4b6aa8
 int xatoi_positive(const char *numstr)
4b6aa8
 {
4b6aa8
     unsigned r = xatou(numstr);
4b6aa8
+
4b6aa8
+    if (NULL == numstr)
4b6aa8
+        error_msg_and_die("converting null string to integer");
4b6aa8
+
4b6aa8
     if (r > (unsigned)INT_MAX)
4b6aa8
         error_msg_and_die("invalid number '%s'", numstr);
4b6aa8
     return r;
4b6aa8
@@ -55,6 +62,9 @@ int xatoi(const char *numstr)
4b6aa8
 {
4b6aa8
     unsigned r;
4b6aa8
 
4b6aa8
+    if (NULL == numstr)
4b6aa8
+        error_msg_and_die("converting null string to integer");
4b6aa8
+
4b6aa8
     if (*numstr != '-')
4b6aa8
         return xatoi_positive(numstr);
4b6aa8
 
4b6aa8
-- 
4b6aa8
2.21.0
4b6aa8