Skip to content

Commit

Permalink
Fixes from Jakub Bogusz <qboosh@pld-linux.org>, stack overwrite, elf …
Browse files Browse the repository at this point in the history
…overread.
  • Loading branch information
zoulasc committed Nov 24, 2004
1 parent a5c145f commit 60cbd2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/readelf.c
Expand Up @@ -37,7 +37,7 @@
#include "readelf.h"

#ifndef lint
FILE_RCSID("@(#)$Id: readelf.c,v 1.44 2004/11/21 05:20:31 christos Exp $")
FILE_RCSID("@(#)$Id: readelf.c,v 1.45 2004/11/24 17:38:24 christos Exp $")
#endif

#ifdef ELFCORE
Expand Down Expand Up @@ -254,7 +254,8 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
file_badseek(ms);
return -1;
}
bufsize = read(fd, nbuf, sizeof(nbuf));
bufsize = read(fd, nbuf,
((ph_filesz < sizeof(nbuf)) ? ph_filesz : sizeof(nbuf)));
if (bufsize == -1) {
file_badread(ms);
return -1;
Expand Down Expand Up @@ -325,7 +326,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
}

offset = ELF_ALIGN(doff + descsz);
if (offset + descsz > size) {
if (doff + descsz > size) {
return offset;
}

Expand Down Expand Up @@ -710,7 +711,8 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
file_badseek(ms);
return -1;
}
bufsize = read(fd, nbuf, sizeof(nbuf));
bufsize = read(fd, nbuf, ((ph_filesz < sizeof(nbuf)) ?
ph_filesz : sizeof(nbuf)));
if (bufsize == -1) {
file_badread(ms);
return -1;
Expand Down
4 changes: 2 additions & 2 deletions src/softmagic.c
Expand Up @@ -39,7 +39,7 @@


#ifndef lint
FILE_RCSID("@(#)$Id: softmagic.c,v 1.71 2004/11/21 06:09:43 christos Exp $")
FILE_RCSID("@(#)$Id: softmagic.c,v 1.72 2004/11/24 17:38:25 christos Exp $")
#endif /* lint */

private int match(struct magic_set *, struct magic *, uint32_t,
Expand Down Expand Up @@ -663,7 +663,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
* might even cause problems
*/
if (nbytes < sizeof(*p))
(void)memset(p + nbytes, '\0', sizeof(*p) - nbytes);
(void)memset(((char *)p) + nbytes, '\0', sizeof(*p) - nbytes);
return 0;
}

Expand Down

0 comments on commit 60cbd2f

Please sign in to comment.