diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-03-29 00:01:47 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-03-29 00:01:47 +0000 |
commit | 49bd19dbd2e547c87d083c64cf4998afcb72f3cb (patch) | |
tree | f2d8ab1b2076919b64c5938edaf24d4aca650ca2 /usr.bin | |
parent | ff248f6e62eaee84255dc0f4e484582ca74dd0c8 (diff) |
implement short reads at the end of the core segement
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pmdb/core.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/pmdb/core.c b/usr.bin/pmdb/core.c index 7370da9f0cb..21763b25147 100644 --- a/usr.bin/pmdb/core.c +++ b/usr.bin/pmdb/core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: core.c,v 1.4 2003/03/28 23:33:27 mickey Exp $ */ +/* $OpenBSD: core.c,v 1.5 2003/03/29 00:01:46 mickey Exp $ */ /* * Copyright (c) 2002 Jean-Francois Brousseau <krapht@secureops.com> * All rights reserved. @@ -155,9 +155,13 @@ core_read(struct pstate *ps, off_t from, void *to, size_t size) for (i = 0; i < ps->ps_core->chdr->c_nseg; i++) { cs = ps->ps_core->segs[i]; - if ((from >= cs->c_addr) && (from < (cs->c_addr + cs->c_size))) { + if ((from >= cs->c_addr) && + (from < (cs->c_addr + cs->c_size))) { read = size; - fp = cs + sizeof(*cs) + ((u_long)from - cs->c_addr); + if ((from + size) > (cs->c_addr + cs->c_size)) + read = (cs->c_addr + cs->c_size) - from; + fp = (void *)cs + sizeof(*cs) + + ((u_long)from - cs->c_addr); memcpy(to, fp, read); return (read); } |