Use fseeko and uintptr_t to make sure that we get a sensible offset

when trying to read from the stack.

PR:		37104
Submitted by:	Thomas Quinot <thomas@cuivre.fr.eu.org>
MFC after:	3 weeks
This commit is contained in:
David Malone 2002-04-21 19:04:26 +00:00
parent 603498c75d
commit 7c8225cab8

View File

@ -137,7 +137,7 @@ get_struct(int procfd, void *offset, void *buf, int len) {
err(1, "dup");
if ((p = fdopen(fd, "r")) == NULL)
err(1, "fdopen");
fseek(p, (long)offset, SEEK_SET);
fseeko(p, (uintptr_t)offset, SEEK_SET);
for (pos = (char *)buf; len--; pos++) {
if ((c = fgetc(p)) == EOF)
return -1;
@ -167,7 +167,7 @@ get_string(int procfd, void *offset, int max) {
buf = malloc( size = (max ? max : 64 ) );
len = 0;
buf[0] = 0;
fseek(p, (long)offset, SEEK_SET);
fseeko(p, (uintptr_t)offset, SEEK_SET);
while ((c = fgetc(p)) != EOF) {
buf[len++] = c;
if (c == 0 || len == max) {