Fixed section iteration crashing on padding entries & typos

This commit is contained in:
Snaipe 2015-08-03 15:37:12 +02:00
parent 86762f8ff7
commit 567e4731a7
2 changed files with 11 additions and 4 deletions

View file

@ -1,3 +1,4 @@
#include <assert.h>
#include "posix-compat.h"
#include "process.h"
@ -219,8 +220,8 @@ void *get_win_section_start(const char *section) {
PIMAGE_SECTION_HEADER pSecHeader = IMAGE_FIRST_SECTION(ntHeader);
for(int i = 0; i < ntHeader->FileHeader.NumberOfSections; i++, pSecHeader++) {
if (!strncmp(pSecHeader->Name, section, 8)) {
return (void*) pSecHeader->VirtualAddress;
if (!strncmp((char*) pSecHeader->Name, section, 8)) {
return (char*) dosHeader + pSecHeader->VirtualAddress;
}
}
return NULL;
@ -235,8 +236,8 @@ void *get_win_section_end(const char *section) {
PIMAGE_SECTION_HEADER pSecHeader = IMAGE_FIRST_SECTION(ntHeader);
for(int i = 0; i < ntHeader->FileHeader.NumberOfSections; i++, pSecHeader++) {
if (!strncmp(pSecHeader->Name, section, 8)) {
return (char*) pSecHeader->VirtualAddress + pSecHeader->SizeOfRawData;
if (!strncmp((char*) pSecHeader->Name, section, 8)) {
return (char*) dosHeader + (size_t) pSecHeader->VirtualAddress + pSecHeader->SizeOfRawData;
}
}
return NULL;

View file

@ -67,6 +67,9 @@ struct criterion_test_set *criterion_init(void) {
struct criterion_ordered_set *suites = new_ordered_set(cmp_suite, dtor_suite_set);
FOREACH_SUITE_SEC(s) {
if (!s->name)
break;
struct criterion_suite_set css = {
.suite = *s,
};
@ -75,6 +78,9 @@ struct criterion_test_set *criterion_init(void) {
size_t nb_tests = 0;
FOREACH_TEST_SEC(test) {
if (!test->category)
break;
if (!*test->category)
continue;