Skip to contentSkip to conversation

Fix evil strtol bug (breaks booleans)

SEMANAGE 3 Ivan Gyurdiev 1 participant 1 message Nov 4, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

I mentioned earlier that strtol wasn't behaving according to manpage. That's actually not true - it works fine, and that was just covering up a much worse bug. The bug caused fetch_int() to always return 0, and as a result to reset all booleans to 0. It wasn't noticed, because my test boolean was explicitly set to 1, and I wasn't paying attention to the other one that I have in booleans.local.

Changes:
- fix the bug (pass right value into strtol)
- remove errno printing - the errno doesn't make any sense most of the time

libsemanage/src/parse_utils.c +3 -3
diff -Naurp --exclude CVS --exclude ChangeLog --exclude VERSION --exclude Makefile old/libsemanage/src/parse_utils.c new/libsemanage/src/parse_utils.c
@@ -256,10 +256,10 @@ int parse_fetch_int(
 		goto err;
 	}
 
-	value = strtol(info->ptr, &test, 10);
+	value = strtol(str, &test, 10);
 	if (*test != '\0') {
-		ERR(handle, "could not parse numeric value: %s (%s: %u)\n%s",
-			strerror(errno), info->filename, 
+		ERR(handle, "could not parse numeric value \"%s\": "
+			"(%s: %u)\n%s", str, info->filename, 
 			info->lineno, info->orig_line);
 		goto err;
 	}