summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/npppd/common/bytebuf.c11
-rw-r--r--usr.sbin/npppd/npppd/npppd_auth.c10
-rw-r--r--usr.sbin/npppd/npppd/npppd_ctl.c5
-rw-r--r--usr.sbin/npppd/npppd/ppp.c9
-rw-r--r--usr.sbin/npppd/npppd/radius_req.c17
-rw-r--r--usr.sbin/npppd/pptp/pptpd.c11
6 files changed, 24 insertions, 39 deletions
diff --git a/usr.sbin/npppd/common/bytebuf.c b/usr.sbin/npppd/common/bytebuf.c
index 786fdfc15a9..a4fe5c17a81 100644
--- a/usr.sbin/npppd/common/bytebuf.c
+++ b/usr.sbin/npppd/common/bytebuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bytebuf.c,v 1.5 2012/05/08 13:15:11 yasuoka Exp $ */
+/* $OpenBSD: bytebuf.c,v 1.6 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
* All rights reserved.
@@ -41,7 +41,7 @@
* }</pre>
*
* @author Yasuoka Masahiko
- * $Id: bytebuf.c,v 1.5 2012/05/08 13:15:11 yasuoka Exp $
+ * $Id: bytebuf.c,v 1.6 2014/05/30 05:06:00 yasuoka Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -96,15 +96,12 @@ bytebuffer_create(size_t capacity)
{
bytebuffer *_this = NULL;
- if ((_this = malloc(sizeof(bytebuffer))) == NULL)
+ if ((_this = calloc(1, sizeof(bytebuffer))) == NULL)
return NULL;
- memset(_this, 0, sizeof(bytebuffer));
-
if (capacity > 0) {
- if ((_this->data = malloc(capacity)) == NULL)
+ if ((_this->data = calloc(1, capacity)) == NULL)
goto fail;
- memset(_this->data, 0, capacity);
_this->capacity = capacity;
} else
_this->capacity = 0;
diff --git a/usr.sbin/npppd/npppd/npppd_auth.c b/usr.sbin/npppd/npppd/npppd_auth.c
index 0c70ec7824d..f3e90a5b00b 100644
--- a/usr.sbin/npppd/npppd/npppd_auth.c
+++ b/usr.sbin/npppd/npppd/npppd_auth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npppd_auth.c,v 1.13 2014/03/22 04:23:17 yasuoka Exp $ */
+/* $OpenBSD: npppd_auth.c,v 1.14 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
/**@file authentication realm */
-/* $Id: npppd_auth.c,v 1.13 2014/03/22 04:23:17 yasuoka Exp $ */
+/* $Id: npppd_auth.c,v 1.14 2014/05/30 05:06:00 yasuoka Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -73,8 +73,7 @@ npppd_auth_create(int auth_type, const char *name, void *_npppd)
switch (auth_type) {
case NPPPD_AUTH_TYPE_LOCAL:
- if ((base = malloc(sizeof(npppd_auth_local))) != NULL) {
- memset(base, 0, sizeof(npppd_auth_local));
+ if ((base = calloc(1, sizeof(npppd_auth_local))) != NULL) {
base->type = NPPPD_AUTH_TYPE_LOCAL;
base->strip_nt_domain = 1;
base->strip_atmark_realm = 0;
@@ -87,9 +86,8 @@ npppd_auth_create(int auth_type, const char *name, void *_npppd)
#ifdef USE_NPPPD_RADIUS
case NPPPD_AUTH_TYPE_RADIUS:
- if ((base = malloc(sizeof(npppd_auth_radius))) != NULL) {
+ if ((base = calloc(1, sizeof(npppd_auth_radius))) != NULL) {
npppd_auth_radius *_this = (npppd_auth_radius *)base;
- memset(base, 0, sizeof(npppd_auth_radius));
base->type = NPPPD_AUTH_TYPE_RADIUS;
base->strip_nt_domain = 0;
strlcpy(base->name, name, sizeof(base->name));
diff --git a/usr.sbin/npppd/npppd/npppd_ctl.c b/usr.sbin/npppd/npppd/npppd_ctl.c
index 70cd7c7e1bb..7ef66e11f05 100644
--- a/usr.sbin/npppd/npppd/npppd_ctl.c
+++ b/usr.sbin/npppd/npppd/npppd_ctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npppd_ctl.c,v 1.11 2014/03/22 04:30:31 yasuoka Exp $ */
+/* $OpenBSD: npppd_ctl.c,v 1.12 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -71,9 +71,8 @@ npppd_ctl_create(npppd *_this)
{
struct npppd_ctl *ctl;
- if ((ctl = malloc(sizeof(struct npppd_ctl))) == NULL)
+ if ((ctl = calloc(1, sizeof(struct npppd_ctl))) == NULL)
return (NULL);
- memset(ctl, 0, sizeof(struct npppd_ctl));
ctl->npppd = _this;
TAILQ_INIT(&ctl->stopped_ppps);
diff --git a/usr.sbin/npppd/npppd/ppp.c b/usr.sbin/npppd/npppd/ppp.c
index 19cd85051e8..10ec94123e7 100644
--- a/usr.sbin/npppd/npppd/ppp.c
+++ b/usr.sbin/npppd/npppd/ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ppp.c,v 1.20 2014/03/22 04:32:39 yasuoka Exp $ */
+/* $OpenBSD: ppp.c,v 1.21 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: ppp.c,v 1.20 2014/03/22 04:32:39 yasuoka Exp $ */
+/* $Id: ppp.c,v 1.21 2014/05/30 05:06:00 yasuoka Exp $ */
/**@file
* This file provides PPP(Point-to-Point Protocol, RFC 1661) and
* {@link :: _npppd_ppp PPP instance} related functions.
@@ -109,11 +109,10 @@ ppp_create()
{
npppd_ppp *_this;
- if ((_this = malloc(sizeof(npppd_ppp))) == NULL) {
- log_printf(LOG_ERR, "malloc() failed in %s(): %m", __func__ );
+ if ((_this = calloc(1, sizeof(npppd_ppp))) == NULL) {
+ log_printf(LOG_ERR, "calloc() failed in %s(): %m", __func__ );
return NULL;
}
- memset(_this, 0, sizeof(npppd_ppp));
_this->snp.snp_family = AF_INET;
_this->snp.snp_len = sizeof(_this->snp);
diff --git a/usr.sbin/npppd/npppd/radius_req.c b/usr.sbin/npppd/npppd/radius_req.c
index 7c3b33e30f0..5477e060100 100644
--- a/usr.sbin/npppd/npppd/radius_req.c
+++ b/usr.sbin/npppd/npppd/radius_req.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radius_req.c,v 1.7 2014/03/22 04:25:00 yasuoka Exp $ */
+/* $OpenBSD: radius_req.c,v 1.8 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
/**@file
* This file provides functions for RADIUS request using radius+.c and event(3).
* @author Yasuoka Masahiko
- * $Id: radius_req.c,v 1.7 2014/03/22 04:25:00 yasuoka Exp $
+ * $Id: radius_req.c,v 1.8 2014/05/30 05:06:00 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -275,11 +275,10 @@ radius_prepare(radius_req_setting *setting, void *context,
if (setting->server[setting->curr_server].enabled == 0)
return 1;
- if ((lap = malloc(sizeof(struct overlapped))) == NULL) {
- log_printf(LOG_ERR, "malloc() failed in %s: %m", __func__);
+ if ((lap = calloc(1, sizeof(struct overlapped))) == NULL) {
+ log_printf(LOG_ERR, "calloc() failed in %s: %m", __func__);
goto fail;
}
- memset(lap, 0, sizeof(struct overlapped));
lap->context = context;
lap->response_fn = response_fn;
lap->socket = -1;
@@ -534,13 +533,7 @@ fail:
radius_req_setting *
radius_req_setting_create(void)
{
- radius_req_setting *setting;
-
- if ((setting = malloc(sizeof(radius_req_setting))) == NULL)
- return NULL;
- memset(setting, 0, sizeof(radius_req_setting));
-
- return setting;
+ return calloc(1, sizeof(radius_req_setting));
}
int
diff --git a/usr.sbin/npppd/pptp/pptpd.c b/usr.sbin/npppd/pptp/pptpd.c
index fbc095e9f9d..acf5e9af5ba 100644
--- a/usr.sbin/npppd/pptp/pptpd.c
+++ b/usr.sbin/npppd/pptp/pptpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pptpd.c,v 1.21 2014/03/22 04:32:39 yasuoka Exp $ */
+/* $OpenBSD: pptpd.c,v 1.22 2014/05/30 05:06:00 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -25,12 +25,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: pptpd.c,v 1.21 2014/03/22 04:32:39 yasuoka Exp $ */
+/* $Id: pptpd.c,v 1.22 2014/05/30 05:06:00 yasuoka Exp $ */
/**@file
* This file provides a implementation of PPTP daemon. Currently it
* provides functions for PAC (PPTP Access Concentrator) only.
- * $Id: pptpd.c,v 1.21 2014/03/22 04:32:39 yasuoka Exp $
+ * $Id: pptpd.c,v 1.22 2014/05/30 05:06:00 yasuoka Exp $
*/
#include <sys/types.h>
#include <sys/param.h>
@@ -166,12 +166,11 @@ pptpd_add_listener(pptpd *_this, int idx, struct pptp_conf *conf,
__func__, slist_length(&_this->listener), idx);
goto fail;
}
- if ((plistener = malloc(sizeof(pptpd_listener))) == NULL) {
- pptpd_log(_this, LOG_ERR, "malloc() failed in %s: %m",
+ if ((plistener = calloc(1, sizeof(pptpd_listener))) == NULL) {
+ pptpd_log(_this, LOG_ERR, "calloc() failed in %s: %m",
__func__);
goto fail;
}
- memset(plistener, 0, sizeof(pptpd_listener));
PPTPD_ASSERT(sizeof(plistener->bind_sin) >= addr->sa_len);
memcpy(&plistener->bind_sin, addr, addr->sa_len);