Thanks, commited.
On Mon, 26 May 2014 22:24:23 +0200
Benjamin Baier <program...@netzbasis.de> wrote:
> and a big one.
>
> Index: common/bytebuf.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/common/bytebuf.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 bytebuf.c
> --- common/bytebuf.c 8 May 2012 13:15:11 -0000 1.5
> +++ common/bytebuf.c 26 May 2014 20:16:32 -0000
> @@ -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;
>
> Index: npppd/npppd_auth.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd_auth.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 npppd_auth.c
> --- npppd/npppd_auth.c 22 Mar 2014 04:23:17 -0000 1.13
> +++ npppd/npppd_auth.c 26 May 2014 20:16:32 -0000
> @@ -73,8 +73,7 @@ npppd_auth_create(int auth_type, const c
>
> 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 c
>
> #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));
>
> Index: npppd/npppd_ctl.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/npppd/npppd_ctl.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 npppd_ctl.c
> --- npppd/npppd_ctl.c 22 Mar 2014 04:30:31 -0000 1.11
> +++ npppd/npppd_ctl.c 26 May 2014 20:16:32 -0000
> @@ -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);
>
> Index: npppd/ppp.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/npppd/ppp.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 ppp.c
> --- npppd/ppp.c 22 Mar 2014 04:32:39 -0000 1.20
> +++ npppd/ppp.c 26 May 2014 20:16:32 -0000
> @@ -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);
>
> Index: npppd/radius_req.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/npppd/radius_req.c,v
> retrieving revision 1.7
> diff -u -p -r1.7 radius_req.c
> --- npppd/radius_req.c 22 Mar 2014 04:25:00 -0000 1.7
> +++ npppd/radius_req.c 26 May 2014 20:16:33 -0000
> @@ -275,11 +275,10 @@ radius_prepare(radius_req_setting *setti
>
> 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
>
> Index: pptp/pptpd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/npppd/pptp/pptpd.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 pptpd.c
> --- pptp/pptpd.c 22 Mar 2014 04:32:39 -0000 1.21
> +++ pptp/pptpd.c 26 May 2014 20:16:33 -0000
> @@ -166,12 +166,11 @@ pptpd_add_listener(pptpd *_this, int idx
> __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);
>