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

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