summaryrefslogtreecommitdiff
path: root/lib/libutil
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-02-10 00:08:51 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-02-10 00:08:51 +0000
commit78e6be6e43440e498ea6fd69e8a477c15f368d1d (patch)
treef465785d769592288d951ba36ff13f6bf757cd2a /lib/libutil
parente4af2f21822ec3c89b346f67ff88190765ed64e2 (diff)
Notes
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/kinfo_getfile.c4
-rw-r--r--lib/libutil/kinfo_getvmmap.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/libutil/kinfo_getfile.c b/lib/libutil/kinfo_getfile.c
index 84b64db20204..8a5477f40654 100644
--- a/lib/libutil/kinfo_getfile.c
+++ b/lib/libutil/kinfo_getfile.c
@@ -44,6 +44,8 @@ kinfo_getfile(pid_t pid, int *cntp)
eb = buf + len;
while (bp < eb) {
kf = (struct kinfo_file *)(uintptr_t)bp;
+ if (kf->kf_structsize == 0)
+ break;
bp += kf->kf_structsize;
cnt++;
}
@@ -59,6 +61,8 @@ kinfo_getfile(pid_t pid, int *cntp)
/* Pass 2: unpack */
while (bp < eb) {
kf = (struct kinfo_file *)(uintptr_t)bp;
+ if (kf->kf_structsize == 0)
+ break;
/* Copy/expand into pre-zeroed buffer */
memcpy(kp, kf, kf->kf_structsize);
/* Advance to next packed record */
diff --git a/lib/libutil/kinfo_getvmmap.c b/lib/libutil/kinfo_getvmmap.c
index 129aa036bd90..9d9e4273a110 100644
--- a/lib/libutil/kinfo_getvmmap.c
+++ b/lib/libutil/kinfo_getvmmap.c
@@ -44,6 +44,8 @@ kinfo_getvmmap(pid_t pid, int *cntp)
eb = buf + len;
while (bp < eb) {
kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+ if (kv->kve_structsize == 0)
+ break;
bp += kv->kve_structsize;
cnt++;
}
@@ -59,6 +61,8 @@ kinfo_getvmmap(pid_t pid, int *cntp)
/* Pass 2: unpack */
while (bp < eb) {
kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+ if (kv->kve_structsize == 0)
+ break;
/* Copy/expand into pre-zeroed buffer */
memcpy(kp, kv, kv->kve_structsize);
/* Advance to next packed record */