From: Lennart Poettering Date: Fri, 1 Mar 2024 22:36:15 +0000 (+0100) Subject: escape: teach octescape() to work with NUL terminated strings X-Git-Tag: v256-rc1~624^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6342e35b07f750771f0fdb3c80a27d3272e8001;p=thirdparty%2Fsystemd.git escape: teach octescape() to work with NUL terminated strings --- diff --git a/src/basic/escape.c b/src/basic/escape.c index d95f35e7980..e7f90a45946 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -451,6 +451,12 @@ char* octescape(const char *s, size_t len) { assert(s || len == 0); + if (len == SIZE_MAX) + len = strlen(s); + + if (len > (SIZE_MAX)-1/4) + return NULL; + t = buf = new(char, len * 4 + 1); if (!buf) return NULL;