libmultipath: scan_devname: fix int overflow detection
authorMartin Wilck <mwilck@suse.com>
Sat, 12 Oct 2019 21:27:44 +0000 (21:27 +0000)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 2 Mar 2020 08:16:30 +0000 (09:16 +0100)
commita27c2e1ab5e5342a74138467487752e7225d675b
tree11a363a8e88528df6d40425384580908bf659aa0
parentf41b8f6d8d0341aef841dab53f82f84a2771b7c1
libmultipath: scan_devname: fix int overflow detection

For an int n, it's possible that n > 0 and (26 * n) > 0, but
and still 26 * n overflows the int.
E.g. n = 0x0ec4ec4e; 26 * n = 0x17fffffec, truncated to 32 bit
yields 0x7fffffec, which is > 0.

And anyway, relying on a signed int overflow to detect a problem
is wrong, as the result of such operations is undefined in C.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/alias.c