diff --git a/src/basic/device-nodes.c b/src/basic/device-nodes.c index 8d4e38ec06..37af18fce4 100644 --- a/src/basic/device-nodes.c +++ b/src/basic/device-nodes.c @@ -6,6 +6,7 @@ #include "device-nodes.h" #include "path-util.h" +#include "stdio-util.h" #include "string-util.h" #include "utf8.h" @@ -38,10 +39,10 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) { } else if (str[i] == '\\' || !allow_listed_char_for_devnode(str[i], NULL)) { - if (len-j < 4) + if (len-j < 5) return -EINVAL; - sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]); + assert_se(snprintf_ok(&str_enc[j], 5, "\\x%02x", (unsigned char) str[i])); j += 4; } else {