[nft PATCH] misspell: Avoid segfault with anonymous chains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When trying to add a rule which contains an anonymous chain to a
non-existent chain, string_misspell_update() is called with a NULL
string because the anonymous chain has no name. Avoid this by making the
function NULL-pointer tolerant.

c330152b7f777 ("src: support for implicit chain bindings")

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/misspell.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/misspell.c b/src/misspell.c
index 6536d7557a445..f213a240005e6 100644
--- a/src/misspell.c
+++ b/src/misspell.c
@@ -80,8 +80,8 @@ int string_misspell_update(const char *a, const char *b,
 {
 	unsigned int len_a, len_b, max_len, min_len, distance, threshold;
 
-	len_a = strlen(a);
-	len_b = strlen(b);
+	len_a = a ? strlen(a) : 0;
+	len_b = b ? strlen(b) : 0;
 
 	max_len = max(len_a, len_b);
 	min_len = min(len_a, len_b);
-- 
2.34.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux