diff --git a/libclamav/htmlnorm.c b/libclamav/htmlnorm.c index cf22c9d025..9eaf5259e4 100644 --- a/libclamav/htmlnorm.c +++ b/libclamav/htmlnorm.c @@ -52,8 +52,6 @@ #include "clamav_rust.h" #include "scanners.h" -extern bool fail_realloc; - #define HTML_STR_LENGTH 1024 #define MAX_TAG_CONTENTS_LENGTH HTML_STR_LENGTH @@ -377,14 +375,6 @@ void html_tag_arg_add(tag_arguments_t *tags, int contentCnt = 0; unsigned char ** tmp = NULL; - static int cnt = 0; - cnt++; - -#if 0 - if (cnt > 2) { - fail_realloc = true; - } -#endif tmp = (unsigned char **) cli_max_realloc(tags->tag, (tagCnt+1) * sizeof(char *)); if (!tmp) { goto done; @@ -392,11 +382,6 @@ void html_tag_arg_add(tag_arguments_t *tags, tags->tag = tmp; tagCnt++; -#if 0 - if (cnt > 2) { - fail_realloc = true; - } -#endif tmp = (unsigned char **)cli_max_realloc(tags->value, (valueCnt+1) * sizeof(char *)); if (!tmp) { goto done; @@ -406,11 +391,6 @@ void html_tag_arg_add(tag_arguments_t *tags, if (tags->scanContents) { contentCnt = tags->count; -#if 0 - if (cnt > 2) { - fail_realloc = true; - } -#endif tmp = (unsigned char **)cli_max_realloc(tags->contents, (contentCnt+1) * sizeof(*tags->contents)); if (!tmp) { goto done; @@ -423,9 +403,6 @@ void html_tag_arg_add(tag_arguments_t *tags, tags->tag[tags->count] = (unsigned char *)cli_safer_strdup(tag); if (value) { if (*value == '"') { - if (cnt > 2) { - fail_realloc = true; - } tags->value[tags->count] = (unsigned char *)cli_safer_strdup(value + 1); if (NULL == tags->value[tags->count]) { goto done; @@ -700,22 +677,12 @@ bool html_insert_form_data(const char * const value, form_data_t *tags) { * Do NOT use cli_max_realloc_or_free because all the previously malloc'd tag * values will be leaked when tag is free'd in the case where realloc fails. */ - static int runCnt = 1; - runCnt++; -#if 0 - if (runCnt > 3) { - fail_realloc = true; - } -#endif tmp = cli_max_realloc(tags->urls, cnt * sizeof(unsigned char *)); if (!tmp) { goto done; } tags->urls = tmp; - if (runCnt > 2) { - fail_realloc = true; - } tags->urls[tags->count] = cli_safer_strdup(value); if (tags->urls[tags->count]) { tags->count = cnt; diff --git a/libclamav/others_common.c b/libclamav/others_common.c index 2ed958d596..60d0179d2d 100644 --- a/libclamav/others_common.c +++ b/libclamav/others_common.c @@ -63,8 +63,6 @@ #include "entconv.h" #include "clamav_rust.h" -bool fail_realloc = false; - #define MSGBUFSIZ 8192 static bool rand_seeded = false; @@ -316,12 +314,7 @@ void *cli_max_realloc(void *ptr, size_t size) return NULL; } - if (fail_realloc){ - alloc = NULL; - } else { alloc = realloc(ptr, size); - } - fail_realloc = false; if (!alloc) { perror("realloc_problem"); @@ -344,21 +337,6 @@ void *cli_max_realloc_or_free(void *ptr, size_t size) alloc = realloc(ptr, size); -#if 0 - if (fail_realloc) { - fprintf(stderr, "%s::%d::Forcing realloc to actually fail\n", __FUNCTION__, __LINE__); - fprintf(stderr, "%s::%d::ptr = %p\n", __FUNCTION__, __LINE__, ptr); - fprintf(stderr, "%s::%d::alloc = %p\n", __FUNCTION__, __LINE__, alloc); - free(alloc); - if (alloc != ptr){ - ptr = NULL; - } - alloc = NULL; - } - fail_realloc = false; - -#endif - if (!alloc) { perror("realloc_problem"); cli_errmsg("cli_max_realloc_or_free(): Can't re-allocate memory to %zu bytes.\n", size); @@ -383,11 +361,6 @@ char *cli_safer_strdup(const char *s) return NULL; } - if (fail_realloc){ - fail_realloc = false; - return NULL; - } - alloc = strdup(s); if (!alloc) {