]> granicus.if.org Git - strace/commitdiff
tests: fix abbreviated octal escape check in print_quoted_memory
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 2 Feb 2018 12:39:30 +0000 (13:39 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 1 Mar 2018 01:00:24 +0000 (01:00 +0000)
* tests/print_quoted_string.c (print_quoted_memory): Check the next
character after octal-escaped one instead of the first one in the
string.

tests/print_quoted_string.c

index 2894e49bc35e8edbecdb62106adc6c01c6d8ac9f..4107e256056364b99b9ed300211df0a8df5b42dc 100644 (file)
@@ -68,7 +68,9 @@ print_quoted_memory(const void *const instr, const size_t len)
                                        char c2 = '0' + ((c >> 3) & 0x7);
                                        char c3 = '0' + (c >> 6);
 
-                                       if (*str >= '0' && *str <= '9') {
+                                       if (i < (len - 1) &&
+                                           str[i + 1] >= '0' &&
+                                           str[i + 1] <= '9') {
                                                /* Print \octal */
                                                putchar(c3);
                                                putchar(c2);