summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2011-05-18 00:01:55 +0100
committerPádraig Brady <P@draigBrady.com>2011-05-18 07:33:04 +0100
commitbeaa94931345271fd288480d7ea952f9551ef991 (patch)
tree8ba8a455a5ed0d95d310f40ae48569c847404f3d /tests/misc
parent50ca38e523b5434fd6d7b98ed87a310179e9967a (diff)
downloadcoreutils-beaa94931345271fd288480d7ea952f9551ef991.tar.xz
printf: fix an out-of-bounds memory access
* src/printf.c (STRTOX): Don't access memory after a string containing a single quote character. * tests/misc/printf: Add tests for various combinations of single quote characters combined with a numeric format. * THANKS.in: Add bug reporter. * NEWS: Mention the fix. Reported-by: Paul Marinescu <paul.marinescu@imperial.ac.uk>
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/printf23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/misc/printf b/tests/misc/printf
index 64047614b..fd1275dfe 100755
--- a/tests/misc/printf
+++ b/tests/misc/printf
@@ -96,4 +96,27 @@ EOF
compare out exp || fail=1
+# Verify handling of single quote chars (\' or \")
+
+"$prog" '%d\n' '"a' >out 2>err # valid
+"$prog" '%d\n' '"a"' >>out 2>>err # invalid
+"$prog" '%d\n' '"' >>out 2>>err # invalid
+"$prog" '%d\n' 'a' >>out 2>>err # invalid
+
+cat <<EOF > exp
+97
+97
+0
+0
+EOF
+
+cat <<EOF > exp_err
+$prog: warning: ": character(s) following character constant have been ignored
+$prog: ": expected a numeric value
+$prog: a: expected a numeric value
+EOF
+
+compare out exp || fail=1
+compare err exp_err || fail=1
+
Exit $fail