tmpfiles: take 8 and 9 as hex digits in an \x escape

An f or w entry with \x39 in the argument writes the byte 3 followed
by a 9, where it should write a 9:

    f /tmp/file - - - - \x39

write_hex() only takes the digits 0 to 7, as for an octal escape.
Take all hex digits.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-21 17:13:53 +01:00
1 parent 64e299bedc
commit 7ec4376eb0
3 files changed
+12 -3

No files matched your search

+2 -3
View File
@@ -23,6 +23,7 @@
#include "config.h" /* Generated by configure script */
#include <ctype.h>
#include <dirent.h>
#include <endian.h>
#include <fcntl.h>
@@ -190,9 +191,7 @@ static char *write_hex(FILE *fp, char *p)
for (i = 0; p[i] && len < 2; i++) {
char c = p[i];
if ((c >= '0' && c <= '7') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F'))
if (isxdigit((unsigned char)c))
num[len++] = c;
else
break;