[PATCH] evaluate: print error for null string befort assert statement

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

 



Print error "Null string is not allowed" before assert statement.
For e.g.
nft add rule filter input meta iifname '""'
Error: Null String is not allowed
add rule filter input meta iifname ""

Signed-off-by: Harsha Sharma <harshasharmaiitr@xxxxxxxxx>
---
 src/evaluate.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/evaluate.c b/src/evaluate.c
index fd61e75..ad044a4 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -235,6 +235,10 @@ static int expr_evaluate_string(struct eval_ctx *ctx, struct expr **exprp)
 	memset(data + len, 0, data_len - len);
 	mpz_export_data(data, expr->value, BYTEORDER_HOST_ENDIAN, len);
 
+	if (strlen(data) == 0) {
+		return expr_error(ctx->msgs, expr,
+				  "Null String is not allowed");
+	}
 	assert(strlen(data) > 0);
 	datalen = strlen(data) - 1;
 	if (data[datalen] != '*') {
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux