From: ArtSin Date: Mon, 21 Oct 2024 15:48:37 +0000 (+0400) Subject: mprintf: do not ignore length modifiers of `%o`, `%x`, `%X` X-Git-Tag: curl-8_11_0~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ca164fabaf3731f29d7de79951e0d6f70cdaeb7;p=thirdparty%2Fcurl.git mprintf: do not ignore length modifiers of `%o`, `%x`, `%X` There are uses of `%lx` and `%zx` in the codebase, but `parsefmt` interpreted them as `%x`. Closes #15348 --- diff --git a/lib/mprintf.c b/lib/mprintf.c index 6a41d36f62..11551a5d7a 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -455,15 +455,30 @@ static int parsefmt(const char *format, flags |= FLAGS_UNSIGNED; break; case 'o': - type = FORMAT_INT; + if(flags & FLAGS_LONGLONG) + type = FORMAT_LONGLONG; + else if(flags & FLAGS_LONG) + type = FORMAT_LONG; + else + type = FORMAT_INT; flags |= FLAGS_OCTAL; break; case 'x': - type = FORMAT_INTU; + if(flags & FLAGS_LONGLONG) + type = FORMAT_LONGLONGU; + else if(flags & FLAGS_LONG) + type = FORMAT_LONGU; + else + type = FORMAT_INTU; flags |= FLAGS_HEX|FLAGS_UNSIGNED; break; case 'X': - type = FORMAT_INTU; + if(flags & FLAGS_LONGLONG) + type = FORMAT_LONGLONGU; + else if(flags & FLAGS_LONG) + type = FORMAT_LONGU; + else + type = FORMAT_INTU; flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED; break; case 'c':