aboutsummaryrefslogtreecommitdiff
path: root/libbb/getopt32.c
diff options
context:
space:
mode:
authorRostislav Skudnov <rostislav@tuxera.com>2017-02-01 18:35:13 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2017-02-04 23:10:22 +0100
commit8762512fdb088acefb9f3ea5f7b1e1bf2d336ff3 (patch)
tree309e04746b4bcb6f2ad645b29f7fcecfbff339e5 /libbb/getopt32.c
parentc31b54fd81690b3df3898437f5865674d06e6577 (diff)
downloadbusybox-w32-8762512fdb088acefb9f3ea5f7b1e1bf2d336ff3.tar.gz
busybox-w32-8762512fdb088acefb9f3ea5f7b1e1bf2d336ff3.tar.bz2
busybox-w32-8762512fdb088acefb9f3ea5f7b1e1bf2d336ff3.zip
Replace int -> uint to avoid signed integer overflow
An example of such an error (should be compiled with DEBUG_SANITIZE): runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/getopt32.c')
-rw-r--r--libbb/getopt32.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index 15b6efc09..497fc016f 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -404,7 +404,7 @@ getopt32(char **argv, const char *applet_opts, ...)
404 if (c >= 32) 404 if (c >= 32)
405 break; 405 break;
406 on_off->opt_char = *s; 406 on_off->opt_char = *s;
407 on_off->switch_on = (1 << c); 407 on_off->switch_on = (1U << c);
408 if (*++s == ':') { 408 if (*++s == ':') {
409 on_off->optarg = va_arg(p, void **); 409 on_off->optarg = va_arg(p, void **);
410 if (s[1] == '+' || s[1] == '*') { 410 if (s[1] == '+' || s[1] == '*') {
@@ -454,7 +454,7 @@ getopt32(char **argv, const char *applet_opts, ...)
454 if (c >= 32) 454 if (c >= 32)
455 break; 455 break;
456 on_off->opt_char = l_o->val; 456 on_off->opt_char = l_o->val;
457 on_off->switch_on = (1 << c); 457 on_off->switch_on = (1U << c);
458 if (l_o->has_arg != no_argument) 458 if (l_o->has_arg != no_argument)
459 on_off->optarg = va_arg(p, void **); 459 on_off->optarg = va_arg(p, void **);
460 c++; 460 c++;