summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-10-18 05:03:23 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-10-18 05:03:23 +0000
commit0628a4e05d8f47debab845e121e3d232087da68e (patch)
treee4c2ee2cdb1594cbe828aff673fc6b06eb298a4d
parent733221d522176437a93aa21b75e6e58df9890db5 (diff)
Use offsetof() instead of adding the sizes of the preceeding struct members
ok millert@
-rw-r--r--usr.bin/kdump/ktrstruct.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/kdump/ktrstruct.c b/usr.bin/kdump/ktrstruct.c
index a19971ee077..609e6a4acc0 100644
--- a/usr.bin/kdump/ktrstruct.c
+++ b/usr.bin/kdump/ktrstruct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ktrstruct.c,v 1.12 2015/10/09 01:37:08 deraadt Exp $ */
+/* $OpenBSD: ktrstruct.c,v 1.13 2015/10/18 05:03:22 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -45,6 +45,7 @@
#include <netdb.h>
#include <poll.h>
#include <signal.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -117,13 +118,12 @@ ktrsockaddr(struct sockaddr *sa)
struct sockaddr_un *sa_un;
sa_un = (struct sockaddr_un *)sa;
- if (sa_un->sun_len <= sizeof(sa_un->sun_len) +
- sizeof(sa_un->sun_family)) {
+ if (sa_un->sun_len <= offsetof(struct sockaddr_un, sun_path)) {
printf("invalid");
break;
}
printf("\"%.*s\"", (int)(sa_un->sun_len -
- sizeof(sa_un->sun_len) - sizeof(sa_un->sun_family)),
+ offsetof(struct sockaddr_un, sun_path)),
sa_un->sun_path);
break;
}