From: Adhemerval Zanella Date: Fri, 25 Apr 2025 18:26:35 +0000 (-0300) Subject: gmon: Fix UB in tst-sprofil.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=646598785915b6599596e8456567bfb5aff36a26;p=thirdparty%2Fglibc.git gmon: Fix UB in tst-sprofil.c UBSAN: Undefined behaviour in tst-sprofil.c:140:6 unsigned integer overflow: 2432902008176640000 + 7812407968270641256 cannot be represened in type 'long int' Use unsigned types for the fibonacci. --- diff --git a/gmon/tst-sprofil.c b/gmon/tst-sprofil.c index 55cf99abf4..15d71762c8 100644 --- a/gmon/tst-sprofil.c +++ b/gmon/tst-sprofil.c @@ -45,8 +45,8 @@ unsigned int bshort[5][0x100 / sizeof (int)]; unsigned int blong[1][0x1000 / sizeof (int)]; unsigned int vlong[1][0x2000 / sizeof (int)]; -static long int -fac (long int n) +static long unsigned int +fac (long int unsigned n) { if (n == 0) return 1; @@ -60,7 +60,7 @@ main (int argc, char **argv) struct timeval tv, start; struct prof prof[32]; double t_tick, delta; - long int sum = 0; + long int unsigned sum = 0; int i, j; for (i = 0; i < NELEMS (taddr); ++i)