loc = contents + sym->value;
if (*pinfo == 'c') {
- if (!isdigit(*(pinfo + 1))) {
+ if (!isdigit(pinfo[1])) {
bb_error_msg_and_die("parameter type 'c' for %s must be followed by"
" the maximum size", param);
}
- charssize = strtoul(pinfo + 1, (char **) NULL, 10);
+ charssize = strtoul(pinfo + 1, NULL, 10);
}
if (val == NULL) {
n = 0;
p = val;
while (*p != 0) {
+ char *endp;
+
if (++n > max)
bb_error_msg_and_die("too many values for %s (max %d)", param, max);
p += len;
break;
case 'b':
- *loc++ = strtoul(p, &p, 0);
+ *loc++ = strtoul(p, &endp, 0);
+ p = endp; /* gcc likes temp var for &endp */
break;
case 'h':
- *(short *) loc = strtoul(p, &p, 0);
+ *(short *) loc = strtoul(p, &endp, 0);
loc += tgt_sizeof_short;
+ p = endp;
break;
case 'i':
- *(int *) loc = strtoul(p, &p, 0);
+ *(int *) loc = strtoul(p, &endp, 0);
loc += tgt_sizeof_int;
+ p = endp;
break;
case 'l':
- *(long *) loc = strtoul(p, &p, 0);
+ *(long *) loc = strtoul(p, &endp, 0);
loc += tgt_sizeof_long;
+ p = endp;
break;
default:
bb_error_msg_and_die("unknown parameter type '%c' for %s",
int m_has_modinfo;
#endif
char *image;
- size_t image_size = 64 * 1024 * 1024;
-
- /* Load module into memory and unzip if compressed */
- image = xmalloc_open_zipped_read_close(m_filename, &image_size);
- if (!image)
- return EXIT_FAILURE;
+ size_t image_size;
+ bool mmaped;
+
+ image_size = INT_MAX - 4095;
+ mmaped = 0;
+ image = try_to_mmap_module(m_filename, &image_size);
+ if (image) {
+ mmaped = 1;
+ } else {
+ /* Load module into memory and unzip if compressed */
+ image = xmalloc_open_zipped_read_close(m_filename, &image_size);
+ if (!image)
+ return EXIT_FAILURE;
+ }
m_name = xstrdup(bb_basename(m_filename));
/* "module.o[.gz]" -> "module" */
exit_status = EXIT_SUCCESS;
out:
- free(image);
+ if (mmaped)
+ munmap(image, image_size);
+ else
+ free(image);
free(m_name);
return exit_status;