Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,21 @@ int testUtility()

if(readFromFile(TEST_FILE_LOCATION, &data, &test_dataSize) == 1)
{
if(data != NULL && test_dataSize == 0)
{
WebcfgError("Test file is empty\n");
return 0;
}
set_g_testfile(1);
WebcfgInfo("Using Test file \n");

char * data_body = malloc(sizeof(char) * test_dataSize+1);
memset(data_body, 0, sizeof(char) * test_dataSize+1);
if( NULL == data_body )
{
WebcfgError("Memory allocation for data_body failed.\n");
return 0;
}
memset(data_body, 0, sizeof(char) * (test_dataSize + 1));
data_body = memcpy(data_body, data, test_dataSize+1);
data_body[test_dataSize] = '\0';
char *ptr_count = data_body;
Expand Down Expand Up @@ -904,10 +914,6 @@ int testUtility()
{
WebcfgInfo("Test webConfigData applied successfully\n");
}
else
{
WebcfgError("Failed to apply Test root webConfigData received from server\n");
}
}
else
{
Expand Down
12 changes: 9 additions & 3 deletions src/webcfg_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
}
else
{
WebcfgDebug("processMsgpackSubdoc done,docs are sent for apply\n");
WebcfgInfo("processMsgpackSubdoc done,docs are sent for apply\n");
}
return WEBCFG_FAILURE;
}
Expand Down Expand Up @@ -1323,13 +1323,19 @@
ch_count = ftell(fp);
fseek(fp, 0, SEEK_SET);
*data = (char *) malloc(sizeof(char) * (ch_count + 1));
sz = fread(*data, 1, ch_count-1,fp);
if( NULL == *data )
{
WebcfgError("Memory allocation for data failed.\n");
fclose(fp);
return 0;
}
sz = fread(*data, 1, ch_count,fp);

Check warning on line 1332 in src/webcfg_multipart.c

View check run for this annotation

Codecov / codecov/patch

src/webcfg_multipart.c#L1329-L1332

Added lines #L1329 - L1332 were not covered by tests
if (!sz)
{
fclose(fp);
WebcfgError("fread failed.\n");
WEBCFG_FREE(*data);
return WEBCFG_FAILURE;
return 0;
}
*len = ch_count;
(*data)[ch_count] ='\0';
Expand Down
Loading