case ZMAGIC:
case QMAGIC:
case OMAGIC:
+ if (e.a_text + e.a_data > max_sz)
+ goto fail;
lseek(fd, N_TXTOFF(e), SEEK_SET);
- size = qemu_read(fd, addr, e.a_text + e.a_data);
+ size = read_targphys(fd, addr, e.a_text + e.a_data);
- if (size < 0)
+ if (size != e.a_text + e.a_data)
goto fail;
break;
case NMAGIC:
+ if (N_DATADDR(e) + e.a_data > max_sz)
+ goto fail;
lseek(fd, N_TXTOFF(e), SEEK_SET);
- size = qemu_read(fd, addr, e.a_text);
+ size = read_targphys(fd, addr, e.a_text);
- if (size < 0)
+ if (size != e.a_text)
goto fail;
- ret = qemu_read(fd, addr + N_DATADDR(e), e.a_data);
+ ret = read_targphys(fd, addr + N_DATADDR(e), e.a_data);
- if (ret < 0)
+ if (ret != e.a_data)
goto fail;
size += ret;
break;
int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm);
+#define CTYPE(isfoobar,argumentchar) (isfoobar((unsigned char)(argumentchar)))
+ /* One must not pass a plain `char' to isupper, toupper, et al. If
+ * it has the top bit set (ie, is negative if your chars are
+ * signed), undefined behaviour results. The <ctype.h> functions
+ * are defined to take the value of an unsigned char, as an int.
+ * So use this macro. You may pass toupper et al for isfoobar.
+ * Do not pass EOF as a character to this macro. If you might have
+ * EOF then you ought to have it in an int representing an unsigned
+ * char, which is safe for the ctype macros directly. Or test separately.
+ * Obviously don't use this for floating point things like isnan! */
+
+ void *qemu_malloc(size_t size);
+ void *qemu_mallocz(size_t size);
+ void qemu_free(void *ptr);
+ char *qemu_strdup(const char *str);
+
+ void *get_mmap_addr(unsigned long size);
+
+
/* Error handling. */
void hw_error(const char *fmt, ...)