Blame SOURCES/sudo-1.8.28-CVE-strtouid-test.patch

e7179e
diff -up ./lib/util/regress/atofoo/atofoo_test.c.CVE-strtouid-test ./lib/util/regress/atofoo/atofoo_test.c
e7179e
--- ./lib/util/regress/atofoo/atofoo_test.c.CVE-strtouid-test	2018-04-29 21:59:23.000000000 +0200
e7179e
+++ ./lib/util/regress/atofoo/atofoo_test.c	2019-10-16 09:38:31.851404545 +0200
e7179e
@@ -1,5 +1,5 @@
e7179e
 /*
e7179e
- * Copyright (c) 2014 Todd C. Miller <Todd.Miller@sudo.ws>
e7179e
+ * Copyright (c) 2014-2019 Todd C. Miller <Todd.Miller@sudo.ws>
e7179e
  *
e7179e
  * Permission to use, copy, modify, and distribute this software for any
e7179e
  * purpose with or without fee is hereby granted, provided that the above
e7179e
@@ -24,6 +24,7 @@
e7179e
 #else
e7179e
 # include "compat/stdbool.h"
e7179e
 #endif
e7179e
+#include <errno.h>
e7179e
 
e7179e
 #include "sudo_compat.h"
e7179e
 #include "sudo_util.h"
e7179e
@@ -78,15 +79,20 @@ static struct strtoid_data {
e7179e
     id_t id;
e7179e
     const char *sep;
e7179e
     const char *ep;
e7179e
+    int errnum;
e7179e
 } strtoid_data[] = {
e7179e
-    { "0,1", 0, ",", "," },
e7179e
-    { "10", 10, NULL, NULL },
e7179e
-    { "-2", -2, NULL, NULL },
e7179e
+    { "0,1", 0, ",", ",", 0 },
e7179e
+    { "10", 10, NULL, NULL, 0 },
e7179e
+    { "-1", 0, NULL, NULL, EINVAL },
e7179e
+    { "4294967295", 0, NULL, NULL, EINVAL },
e7179e
+    { "4294967296", 0, NULL, NULL, ERANGE },
e7179e
+    { "-2147483649", 0, NULL, NULL, ERANGE },
e7179e
+    { "-2", -2, NULL, NULL, 0 },
e7179e
 #if SIZEOF_ID_T != SIZEOF_LONG_LONG
e7179e
-    { "-2", (id_t)4294967294U, NULL, NULL },
e7179e
+    { "-2", (id_t)4294967294U, NULL, NULL, 0 },
e7179e
 #endif
e7179e
-    { "4294967294", (id_t)4294967294U, NULL, NULL },
e7179e
-    { NULL, 0, NULL, NULL }
e7179e
+    { "4294967294", (id_t)4294967294U, NULL, NULL, 0 },
e7179e
+    { NULL, 0, NULL, NULL, 0 }
e7179e
 };
e7179e
 
e7179e
 static int
e7179e
@@ -102,11 +108,23 @@ test_strtoid(int *ntests)
e7179e
 	(*ntests)++;
e7179e
 	errstr = "some error";
e7179e
 	value = sudo_strtoid(d->idstr, d->sep, &ep, &errstr);
e7179e
-	if (errstr != NULL) {
e7179e
-	    if (d->id != (id_t)-1) {
e7179e
-		sudo_warnx_nodebug("FAIL: %s: %s", d->idstr, errstr);
e7179e
+	if (d->errnum != 0) {
e7179e
+	    if (errstr == NULL) {
e7179e
+		sudo_warnx_nodebug("FAIL: %s: missing errstr for errno %d",
e7179e
+		    d->idstr, d->errnum);
e7179e
+		errors++;
e7179e
+	    } else if (value != 0) {
e7179e
+		sudo_warnx_nodebug("FAIL: %s should return 0 on error",
e7179e
+		    d->idstr);
e7179e
+		errors++;
e7179e
+	    } else if (errno != d->errnum) {
e7179e
+		sudo_warnx_nodebug("FAIL: %s: errno mismatch, %d != %d",
e7179e
+		    d->idstr, errno, d->errnum);
e7179e
 		errors++;
e7179e
 	    }
e7179e
+	} else if (errstr != NULL) {
e7179e
+	    sudo_warnx_nodebug("FAIL: %s: %s", d->idstr, errstr);
e7179e
+	    errors++;
e7179e
 	} else if (value != d->id) {
e7179e
 	    sudo_warnx_nodebug("FAIL: %s != %u", d->idstr, (unsigned int)d->id);
e7179e
 	    errors++;
e7179e
diff -up ./plugins/sudoers/regress/testsudoers/test5.out.ok.CVE-strtouid-test ./plugins/sudoers/regress/testsudoers/test5.out.ok
e7179e
--- ./plugins/sudoers/regress/testsudoers/test5.out.ok.CVE-strtouid-test	2018-04-29 21:59:23.000000000 +0200
e7179e
+++ ./plugins/sudoers/regress/testsudoers/test5.out.ok	2019-10-16 09:29:50.246761680 +0200
e7179e
@@ -4,7 +4,7 @@ Parse error in sudoers near line 1.
e7179e
 Entries for user root:
e7179e
 
e7179e
 Command unmatched
e7179e
-testsudoers: test5.inc should be owned by gid 4294967295
e7179e
+testsudoers: test5.inc should be owned by gid 4294967294
e7179e
 Parse error in sudoers near line 1.
e7179e
 
e7179e
 Entries for user root:
e7179e
diff -up ./plugins/sudoers/regress/testsudoers/test5.sh.CVE-strtouid-test ./plugins/sudoers/regress/testsudoers/test5.sh
e7179e
--- ./plugins/sudoers/regress/testsudoers/test5.sh.CVE-strtouid-test	2018-04-29 21:59:23.000000000 +0200
e7179e
+++ ./plugins/sudoers/regress/testsudoers/test5.sh	2019-10-16 09:29:50.246761680 +0200
e7179e
@@ -24,7 +24,7 @@ EOF
e7179e
 
e7179e
 # Test group writable
e7179e
 chmod 664 $TESTFILE
e7179e
-./testsudoers -U $MYUID -G -1 root id <
e7179e
+./testsudoers -U $MYUID -G -2 root id <
e7179e
 #include $TESTFILE
e7179e
 EOF
e7179e