diff options
author | jhb <jhb@FreeBSD.org> | 2009-11-04 16:03:47 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-11-04 16:03:47 +0000 |
commit | c84a25c8eab521fbfbc1b30463e2ffd67467c237 (patch) | |
tree | 2fa7cde075a712d0fa3ee378a4934b6790e73ab0 /sbin | |
parent | 4d34fdb382f7bfd134efd42ee3fd2344edd5391f (diff) | |
download | FreeBSD-src-c84a25c8eab521fbfbc1b30463e2ffd67467c237.zip FreeBSD-src-c84a25c8eab521fbfbc1b30463e2ffd67467c237.tar.gz |
MFC 198585:
When extracting the capture buffer from a crashdump, only read the valid
portion of the capture buffer.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ddb/ddb_capture.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sbin/ddb/ddb_capture.c b/sbin/ddb/ddb_capture.c index 9f83acb..ffc9b91 100644 --- a/sbin/ddb/ddb_capture.c +++ b/sbin/ddb/ddb_capture.c @@ -95,24 +95,24 @@ kread_symbol(kvm_t *kvm, int index, void *address, size_t size, static void ddb_capture_print_kvm(kvm_t *kvm) { - u_int db_capture_bufsize; + u_int db_capture_bufoff; char *buffer, *db_capture_buf; if (kread_symbol(kvm, X_DB_CAPTURE_BUF, &db_capture_buf, sizeof(db_capture_buf), 0) < 0) errx(-1, "kvm: unable to read db_capture_buf"); - if (kread_symbol(kvm, X_DB_CAPTURE_BUFSIZE, &db_capture_bufsize, - sizeof(db_capture_bufsize), 0) < 0) - errx(-1, "kvm: unable to read db_capture_bufsize"); + if (kread_symbol(kvm, X_DB_CAPTURE_BUFOFF, &db_capture_bufoff, + sizeof(db_capture_bufoff), 0) < 0) + errx(-1, "kvm: unable to read db_capture_bufoff"); - buffer = malloc(db_capture_bufsize + 1); + buffer = malloc(db_capture_bufoff + 1); if (buffer == NULL) - err(-1, "malloc: db_capture_bufsize (%u)", - db_capture_bufsize); - bzero(buffer, db_capture_bufsize + 1); + err(-1, "malloc: db_capture_bufoff (%u)", + db_capture_bufoff); + bzero(buffer, db_capture_bufoff + 1); - if (kread(kvm, db_capture_buf, buffer, db_capture_bufsize, 0) < 0) + if (kread(kvm, db_capture_buf, buffer, db_capture_bufoff, 0) < 0) errx(-1, "kvm: unable to read buffer"); printf("%s\n", buffer); @@ -161,7 +161,7 @@ ddb_capture_status_kvm(kvm_t *kvm) errx(-1, "kvm: unable to read db_capture_bufsize"); if (kread_symbol(kvm, X_DB_CAPTURE_INPROGRESS, &db_capture_inprogress, sizeof(db_capture_inprogress), 0) < 0) - err(-1, "kvm: unable to read db_capture_inpgoress"); + err(-1, "kvm: unable to read db_capture_inprogress"); printf("%u/%u bytes used\n", db_capture_bufoff, db_capture_bufsize); if (db_capture_inprogress) printf("capture is on\n"); |