summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-06-19 14:34:51 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-06-19 15:04:52 +1000
commit81e8b72daf3ad0a3f36e4ae0ef6b38e427e251b5 (patch)
treed5a46905548bcaacee355881d08c553024429cc6
parent6c4de3386ee102040fc567708958a60a9d254b02 (diff)
Escape non-printable characters correctly
This is the equivalent patch to xserver commit eaf1f72ed8994b708d94ec2de7b1a99f5c4a39b8: XkbStringText escapes non-printable characters using octal numbers. Such escape sequence would be at most 5 characters long ("\0123"), so it reserves 5 bytes in the buffer. Due to char->unsigned int conversion, it would print much longer string for negative numbers. Fixes https://gitlab.freedesktop.org/xorg/lib/libxkbfile/-/issues/8 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/xkbtext.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/xkbtext.c b/src/xkbtext.c
index 6741d1a..91c3c33 100644
--- a/src/xkbtext.c
+++ b/src/xkbtext.c
@@ -733,7 +733,7 @@ XkbStringText(char *str, unsigned format)
}
else {
*out++ = '0';
- sprintf(out, "%o", *in);
+ sprintf(out, "%o", (unsigned char)*in);
while (*out != '\0')
out++;
}