Skip to content

Commit cdbb4b8

Browse files
authored
Fix divide by zero crash loading LDB signature
If a byte compare subsignature specifies a 0-byte length then the process may crash with a divide-by-zero exception while loading the signature. byte_length had validation for invalid characters, but nothing for a zero value. Added validation for a zero value.
1 parent c34dd0f commit cdbb4b8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

libclamav/matcher-byte-comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ cl_error_t cli_bcomp_addpatt(struct cli_matcher *root, const char *virname, cons
292292
/* parse out the byte length parameter */
293293
buf_end = NULL;
294294
byte_length = strtol(buf_start, (char **)&buf_end, 0);
295-
if (buf_end && buf_end + 1 != tokens[2]) {
295+
if ((buf_end && buf_end + 1 != tokens[2]) || (0 == byte_length)) {
296296
cli_errmsg("cli_bcomp_addpatt: while parsing (%s#%s#%s), byte length parameter included invalid characters\n", tokens[0], tokens[1], tokens[2]);
297297
free(buf);
298298
cli_bcomp_freemeta(root, bcomp);

0 commit comments

Comments
 (0)