]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: avoid UB on signed multiplication in resolve_symbol_value()
authorJan Beulich <jbeulich@suse.com>
Fri, 13 Dec 2024 08:42:55 +0000 (09:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 13 Dec 2024 08:42:55 +0000 (09:42 +0100)
Commit 487b0ff02dda ("ubsan: signed integer multiply overflow") touched
only one of the two affected places (the 3rd, resolve_expression(), is
already using valueT type local variables).

gas/symbols.c

index fa3aaa37ed4691c3b6e7cd40a3b09d5c7479dbe5..8401b4e425e95d6a68316f6415ddcc7aaf8dd786 100644 (file)
@@ -1721,7 +1721,8 @@ resolve_symbol_value (symbolS *symp)
 
          switch (symp->x->value.X_op)
            {
-           case O_multiply:            left *= right; break;
+           /* See expr() for reasons of the use of valueT casts here.  */
+           case O_multiply:            left *= (valueT) right; break;
            case O_divide:              left /= right; break;
            case O_modulus:             left %= right; break;
            case O_left_shift: