loadfile_*() must set errno when it returns -1.
This commit is contained in:
parent
1effb490f2
commit
33469b0e28
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: loadfile_aout.c,v 1.9 2007/06/05 08:48:50 martin Exp $ */
|
||||
/* $NetBSD: loadfile_aout.c,v 1.10 2007/11/23 04:32:14 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -105,6 +105,7 @@ loadfile_aout(fd, x, marks, flags)
|
|||
paddr_t offset = marks[MARK_START];
|
||||
u_long magic = N_GETMAGIC(*x);
|
||||
int sub;
|
||||
ssize_t nr;
|
||||
|
||||
/* some ports dont use the offset */
|
||||
offset = offset;
|
||||
|
@ -144,8 +145,13 @@ loadfile_aout(fd, x, marks, flags)
|
|||
if (flags & LOAD_TEXT) {
|
||||
PROGRESS(("%ld", x->a_text));
|
||||
|
||||
if (READ(fd, maxp, x->a_text - sub) !=
|
||||
(ssize_t)(x->a_text - sub)) {
|
||||
nr = READ(fd, maxp, x->a_text - sub);
|
||||
if (nr == -1) {
|
||||
WARN(("read text"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != (ssize_t)(x->a_text - sub)) {
|
||||
errno = ESHORT;
|
||||
WARN(("read text"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -180,7 +186,13 @@ loadfile_aout(fd, x, marks, flags)
|
|||
PROGRESS(("+%ld", x->a_data));
|
||||
|
||||
marks[MARK_DATA] = LOADADDR(maxp);
|
||||
if (READ(fd, maxp, x->a_data) != (ssize_t)x->a_data) {
|
||||
nr = READ(fd, maxp, x->a_data);
|
||||
if (nr == -1) {
|
||||
WARN(("read data"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != (ssize_t)x->a_data) {
|
||||
errno = ESHORT;
|
||||
WARN(("read data"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -225,7 +237,13 @@ loadfile_aout(fd, x, marks, flags)
|
|||
if (flags & LOAD_SYM) {
|
||||
PROGRESS(("+[%ld", x->a_syms));
|
||||
|
||||
if (READ(fd, maxp, x->a_syms) != (ssize_t)x->a_syms) {
|
||||
nr = READ(fd, maxp, x->a_syms);
|
||||
if (nr == -1) {
|
||||
WARN(("read symbols"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != (ssize_t)x->a_syms) {
|
||||
errno = ESHORT;
|
||||
WARN(("read symbols"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -238,7 +256,13 @@ loadfile_aout(fd, x, marks, flags)
|
|||
if (flags & (LOAD_SYM|COUNT_SYM))
|
||||
maxp += x->a_syms;
|
||||
|
||||
if (read(fd, &cc, sizeof(cc)) != sizeof(cc)) {
|
||||
nr = read(fd, &cc, sizeof(cc));
|
||||
if (nr == -1) {
|
||||
WARN(("read string table"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != sizeof(cc)) {
|
||||
errno = ESHORT;
|
||||
WARN(("read string table"));
|
||||
return 1;
|
||||
}
|
||||
|
@ -260,7 +284,13 @@ loadfile_aout(fd, x, marks, flags)
|
|||
}
|
||||
|
||||
if (flags & LOAD_SYM) {
|
||||
if (READ(fd, maxp, cc) != cc) {
|
||||
nr = READ(fd, maxp, cc);
|
||||
if (nr == -1) {
|
||||
WARN(("read strings"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != cc) {
|
||||
errno = ESHORT;
|
||||
WARN(("read strings"));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: loadfile_ecoff.c,v 1.8 2007/06/06 07:56:39 martin Exp $ */
|
||||
/* $NetBSD: loadfile_ecoff.c,v 1.9 2007/11/23 04:32:14 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -66,6 +66,7 @@ loadfile_coff(fd, coff, marks, flags)
|
|||
{
|
||||
paddr_t offset = marks[MARK_START];
|
||||
paddr_t minp = ~0, maxp = 0, pos;
|
||||
ssize_t nr;
|
||||
|
||||
/* some ports dont use the offset */
|
||||
offset = offset;
|
||||
|
@ -79,8 +80,12 @@ loadfile_coff(fd, coff, marks, flags)
|
|||
if (coff->a.tsize != 0) {
|
||||
if (flags & LOAD_TEXT) {
|
||||
PROGRESS(("%lu", coff->a.tsize));
|
||||
if (READ(fd, coff->a.text_start, coff->a.tsize) !=
|
||||
coff->a.tsize) {
|
||||
nr = READ(fd, coff->a.text_start, coff->a.tsize);
|
||||
if (nr == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (nr != coff->a.tsize) {
|
||||
errno = ESHORT;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +109,13 @@ loadfile_coff(fd, coff, marks, flags)
|
|||
if (coff->a.dsize != 0) {
|
||||
if (flags & LOAD_DATA) {
|
||||
PROGRESS(("+%lu", coff->a.dsize));
|
||||
if (READ(fd, coff->a.data_start, coff->a.dsize) !=
|
||||
coff->a.dsize) {
|
||||
nr = READ(fd, coff->a.data_start, coff->a.dsize);
|
||||
if (nr == -1) {
|
||||
WARN(("read data"));
|
||||
return 1;
|
||||
}
|
||||
if (nr != coff->a.dsize) {
|
||||
errno = ESHORT;
|
||||
WARN(("read data"));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: loadfile_elf32.c,v 1.17 2007/06/05 08:48:50 martin Exp $ */
|
||||
/* $NetBSD: loadfile_elf32.c,v 1.18 2007/11/23 04:32:14 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -276,6 +276,7 @@ ELFNAMEEND(loadfile)(fd, elf, marks, flags)
|
|||
int first;
|
||||
paddr_t minp = ~0, maxp = 0, pos = 0;
|
||||
paddr_t offset = marks[MARK_START], shpp, elfp = 0;
|
||||
ssize_t nr;
|
||||
|
||||
/* some ports dont use the offset */
|
||||
offset = offset;
|
||||
|
@ -289,7 +290,13 @@ ELFNAMEEND(loadfile)(fd, elf, marks, flags)
|
|||
WARN(("lseek phdr"));
|
||||
goto freephdr;
|
||||
}
|
||||
if (read(fd, phdr, sz) != sz) {
|
||||
nr = read(fd, phdr, sz);
|
||||
if (nr == -1) {
|
||||
WARN(("read program headers"));
|
||||
goto freephdr;
|
||||
}
|
||||
if (nr != sz) {
|
||||
errno = ESHORT;
|
||||
WARN(("read program headers"));
|
||||
goto freephdr;
|
||||
}
|
||||
|
@ -329,8 +336,13 @@ ELFNAMEEND(loadfile)(fd, elf, marks, flags)
|
|||
WARN(("lseek text"));
|
||||
goto freephdr;
|
||||
}
|
||||
if (READ(fd, phdr[i].p_vaddr, phdr[i].p_filesz) !=
|
||||
(ssize_t)phdr[i].p_filesz) {
|
||||
nr = READ(fd, phdr[i].p_vaddr, phdr[i].p_filesz);
|
||||
if (nr == -1) {
|
||||
WARN(("read text error"));
|
||||
goto freephdr;
|
||||
}
|
||||
if (nr != (ssize_t)phdr[i].p_filesz) {
|
||||
errno = ESHORT;
|
||||
WARN(("read text"));
|
||||
goto freephdr;
|
||||
}
|
||||
|
@ -380,7 +392,13 @@ ELFNAMEEND(loadfile)(fd, elf, marks, flags)
|
|||
|
||||
shp = ALLOC(sz);
|
||||
|
||||
if (read(fd, shp, sz) != sz) {
|
||||
nr = read(fd, shp, sz);
|
||||
if (nr == -1) {
|
||||
WARN(("read section headers"));
|
||||
goto freeshp;
|
||||
}
|
||||
if (nr != sz) {
|
||||
errno = ESHORT;
|
||||
WARN(("read section headers"));
|
||||
goto freeshp;
|
||||
}
|
||||
|
@ -422,8 +440,13 @@ ELFNAMEEND(loadfile)(fd, elf, marks, flags)
|
|||
WARN(("lseek symbols"));
|
||||
goto freeshp;
|
||||
}
|
||||
if (READ(fd, maxp, shp[i].sh_size) !=
|
||||
(ssize_t)shp[i].sh_size) {
|
||||
nr = READ(fd, maxp, shp[i].sh_size);
|
||||
if (nr == -1) {
|
||||
WARN(("read symbols"));
|
||||
goto freeshp;
|
||||
}
|
||||
if (nr != (ssize_t)shp[i].sh_size) {
|
||||
errno = ESHORT;
|
||||
WARN(("read symbols"));
|
||||
goto freeshp;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: saerrno.h,v 1.9 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: saerrno.h,v 1.10 2007/11/23 04:32:14 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
|
@ -48,4 +48,5 @@ extern int errno;
|
|||
#define EWCK (ELAST+10) /* write check error */
|
||||
#define EECC (ELAST+11) /* uncorrectable ecc error */
|
||||
#define EHER (ELAST+12) /* hard error */
|
||||
#define ESALAST (ELAST+12) /* */
|
||||
#define ESHORT (ELAST+13) /* short read */
|
||||
#define ESALAST (ELAST+13) /* */
|
||||
|
|
Loading…
Reference in New Issue