]> git.ozlabs.org Git - ppp.git/commitdiff
pppd: Fix sign-extension when displaying bytes in octal
authorPhilip A. Prindeville <philipp@redfish-solutions.com>
Sat, 20 Dec 2014 00:52:58 +0000 (17:52 -0700)
committerPhilip A. Prindeville <philipp@redfish-solutions.com>
Sat, 20 Dec 2014 00:59:37 +0000 (17:59 -0700)
print_string() displays characters as \\%.03o but without first
casting it from "char" to "unsigned char" so it gets sign-extended
to an int. This causes output like \37777777630 instead of \230.

Signed-off-by: Philip A. Prindeville <philipp@redfish-solutions.com>
pppd/utils.c

index 29bf970905d58ffdcba9fe68cc7c62526fc9430e..3ac1b60926d20014808dcaf708d59f6adb33ee1a 100644 (file)
@@ -625,7 +625,7 @@ print_string(p, len, printer, arg)
                printer(arg, "\\t");
                break;
            default:
-               printer(arg, "\\%.3o", c);
+               printer(arg, "\\%.3o", (unsigned char) c);
            }
        }
     }