summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-05-05 14:44:18 +0000
committerkrw <krw@openbsd.org>2014-05-05 14:44:18 +0000
commit6d189339c495029312c5782db5b6916a429ab37e (patch)
treeb2baaa30d3f0791b6101293aaa71a5f8178c9ab2
parentPlug a memory leak related to HID descriptor parsing. (diff)
downloadwireguard-openbsd-6d189339c495029312c5782db5b6916a429ab37e.tar.xz
wireguard-openbsd-6d189339c495029312c5782db5b6916a429ab37e.zip
A couple of malloc()+memset(0) -> calloc.
-rw-r--r--sbin/dhclient/clparse.c7
-rw-r--r--sbin/dhclient/dhclient.c6
2 files changed, 5 insertions, 8 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 31c1a39ce64..1632bd17ff7 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.83 2014/01/25 05:21:23 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.84 2014/05/05 14:44:18 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -454,12 +454,11 @@ parse_client_lease_statement(FILE *cfile, int is_static)
return;
}
- lease = malloc(sizeof(struct client_lease));
+ lease = calloc(1, sizeof(struct client_lease));
if (!lease)
error("no memory for lease.");
- memset(lease, 0, sizeof(*lease));
- lease->is_static = is_static;
+ lease->is_static = is_static;
do {
token = peek_token(NULL, cfile);
if (token == EOF) {
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index e8fa989b994..8c4e3743094 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.301 2014/05/04 21:07:50 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.302 2014/05/05 14:44:18 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -991,14 +991,12 @@ packet_to_lease(struct in_addr client_addr, struct option_data *options)
char *pretty;
int i;
- lease = malloc(sizeof(struct client_lease));
+ lease = calloc(1, sizeof(struct client_lease));
if (!lease) {
warning("dhcpoffer: no memory to record lease.");
return (NULL);
}
- memset(lease, 0, sizeof(*lease));
-
/* Copy the lease options. */
for (i = 0; i < 256; i++) {
if (options[i].len == 0)