udhcp: fix use of trim() in udhcp_str2optset()
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 14 May 2018 04:29:15 +0000 (14:29 +1000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 14 May 2018 08:46:00 +0000 (10:46 +0200)
trim() modifies the string in place if needed and returns a pointer to
the end of the resulting string. Update udhcp_str2optset() so it no
longer sets the value of 'val' to the return value of trim().

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/common.c

index fbf9c6878a3b2d80403b6323f4a96dedb3e61778..b7c04da738dc703aa91c4870be3e932cf07ee6f5 100644 (file)
@@ -489,9 +489,10 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg, const struct dh
                int length;
                char *val;
 
-               if (optflag->flags == OPTION_BIN)
-                       val = trim(strtok(NULL, "")); /* do not split "'q w e'" */
-               else
+               if (optflag->flags == OPTION_BIN) {
+                       val = strtok(NULL, ""); /* do not split "'q w e'" */
+                       trim(val);
+               } else
                        val = strtok(NULL, ", \t");
                if (!val)
                        break;