From: Adhemerval Zanella Date: Thu, 24 Apr 2025 12:41:11 +0000 (-0300) Subject: stdio-common: Fix UB on stdio-common/vfprintf-process-arg.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b3a4a701dc570fa806eac0a0aec12f12ee719ab;p=thirdparty%2Fglibc.git stdio-common: Fix UB on stdio-common/vfprintf-process-arg.c On i686 debug/tst-sprintf-fortify-unchecked triggers: UBSAN: Undefined behaviour in vfprintf-process-arg.c:41:57 negation of 9223372036854775808 cannot be represented in type 'long long int' --- diff --git a/stdio-common/vfprintf-process-arg.c b/stdio-common/vfprintf-process-arg.c index a41feb2c47..fd23213e7e 100644 --- a/stdio-common/vfprintf-process-arg.c +++ b/stdio-common/vfprintf-process-arg.c @@ -38,7 +38,8 @@ LABEL (form_integer): { long long int signed_number = process_arg_long_long_int (); is_negative = signed_number < 0; - number.longlong = is_negative ? (- signed_number) : signed_number; + number.longlong = is_negative ? (- (unsigned long long) signed_number) + : signed_number; goto LABEL (longlong_number); }