[ovs-dev] [PATCH v1 ovn] Fix seg fault while encoding DHCP domain search option.

svc.eng.git-patch at nutanix.com svc.eng.git-patch at nutanix.com
Tue Jun 30 17:04:38 UTC 2020


From: Dhathri Purohith <dhathri.purohith at nutanix.com>

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 <dhathri.purohith at nutanix.com>
---
 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



More information about the dev mailing list