Added missing check for in_len in _old_apply_rule function
authorGabriele 'matrix' Gristina <gm4tr1x@users.noreply.github.com>
Sun, 24 Jan 2016 14:13:43 +0000 (15:13 +0100)
committerGabriele 'matrix' Gristina <gm4tr1x@users.noreply.github.com>
Sun, 24 Jan 2016 14:13:43 +0000 (15:13 +0100)
src/shared.c

index 6af7ca8..34bca2c 100644 (file)
@@ -20372,13 +20372,13 @@ int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u3
 
 int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE])
 {
-  char mem[BLOCK_SIZE];
+  char mem[BLOCK_SIZE] = { 0 };
 
   if (in == NULL) return (RULE_RC_REJECT_ERROR);
 
   if (out == NULL) return (RULE_RC_REJECT_ERROR);
 
-  if (in_len < 1) return (RULE_RC_REJECT_ERROR);
+  if (in_len < 1 || in_len > BLOCK_SIZE) return (RULE_RC_REJECT_ERROR);
 
   if (rule_len < 1) return (RULE_RC_REJECT_ERROR);