static int elf_find_section(char *map, const char *section, unsigned int *offset, unsigned int *size)
{
int clazz = map[EI_CLASS];
+ int endian = map[EI_DATA];
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ if (endian != ELFDATA2LSB)
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ if (endian != ELFDATA2MSB)
+#else
+#error "unsupported endian"
+#endif
+ {
+ ULOG_ERR("invalid endianess: %d\n", endian);
+ return -1;
+ }
if (clazz == ELFCLASS32)
return elf32_find_section(map, section, offset, size);
}
data = malloc(s.st_size);
+ if (!data)
+ goto out;
+
if (read(fd, data, s.st_size) == s.st_size) {
ret = syscall(__NR_init_module, data, (unsigned long) s.st_size, options);
if (errno == EEXIST)
else
ULOG_ERR("failed to read full module %s\n", path);
+out:
close(fd);
free(data);
len += strlen(argv[i]) + 1;
options = malloc(len);
+ if (!options) {
+ ret = -1;
+ goto err;
+ }
+
options[0] = 0;
cur = options;
for (i = 2; i < argc; i++) {
dir = argv[1];
path = malloc(strlen(dir) + 2);
+ if (!path)
+ return -1;
+
strcpy(path, dir);
strcat(path, "*");