Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Jul 10, 2024
1 parent 30a78cb commit 7693070
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
33 changes: 0 additions & 33 deletions libclamav/htmlnorm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -377,26 +375,13 @@ 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;
}
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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 0 additions & 27 deletions libclamav/others_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
#include "entconv.h"
#include "clamav_rust.h"

bool fail_realloc = false;

#define MSGBUFSIZ 8192

static bool rand_seeded = false;
Expand Down Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 7693070

Please sign in to comment.