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

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