From: Dhathri Purohith <[email protected]>

Some versions of strtok_r make the original string NULL at the
end of parsing. Adding Null check before ovs_strlcpy() to
prevent segfault in such cases.

Fixes: d79bb92c4b49 ("Add support for DHCP domain search option (119)")

Signed-off-by: Dhathri Purohith <[email protected]>
---
 lib/actions.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/actions.c b/lib/actions.c
index ee7c825..c435188 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -2382,7 +2382,9 @@ encode_put_dhcpv4_option(const struct ovnact_gen_option 
*o,
                     memcpy(dns_encoded + encode_offset, label, len);
                     encode_offset += len;
                 }
-               ovs_strlcpy(suffix, domain, strlen(domain));
+                if (domain != NULL) {
+                    ovs_strlcpy(suffix, domain, strlen(domain));
+                }
             }
             /* Add the end marker (0 byte) to determine the end of the
              * domain. */
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to