udhcpc: fix segmentation fault on empty bin opt
authorMichal Kazior <michal@plume.com>
Wed, 25 Sep 2019 12:03:13 +0000 (14:03 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 8 Oct 2019 13:14:46 +0000 (15:14 +0200)
The following caused udhcpc to segfault:
  busybox udhcpc -i lo -s /dev/null -x 0x3d:

function                                             old     new   delta
udhcp_str2optset                                     629     641     +12

Signed-off-by: Michal Kazior <michal@plume.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/common.c

index 4a452cdb93995aafe64263fb54ac5d8e0679b233..9ec752dfc9be63d36fccf2d1993923b65f4861db 100644 (file)
@@ -539,7 +539,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg,
 
                if (optflag->flags == OPTION_BIN) {
                        val = strtok(NULL, ""); /* do not split "'q w e'" */
-                       trim(val);
+                       if (val) trim(val);
                } else
                        val = strtok(NULL, ", \t");
                if (!val)