From d001a573f3c03b304bd0d4cb6a391090374e5281 Mon Sep 17 00:00:00 2001 From: Charles Forsyth Date: Sun, 4 Oct 2015 21:22:17 +0100 Subject: [PATCH] zero structure size, not pointer --- authp9any.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/authp9any.c b/authp9any.c index ad12ac8..2b784dc 100644 --- a/authp9any.c +++ b/authp9any.c @@ -317,10 +317,10 @@ p9anyinit(void) passtokey(authkey, f[0]); authid = strdup(f[1]); authdom = strdup(f[2]); - haveprotosmsg = malloc(strlen("p9sk1") + 1 + strlen(authdom) + 1); - sprint(haveprotosmsg, "p9sk1@%s", authdom); - needprotomsg = malloc(strlen("p9sk1") + 1 + strlen(authdom) + 1); - sprint(needprotomsg, "p9sk1 %s", authdom); + haveprotosmsg = smprint("p9sk1@%s", authdom); + needprotomsg = smprint("p9sk1 %s", authdom); + if(haveprotosmsg == nil || needprotomsg == nil) + sysfatal("out of memory"); } typedef struct AuthSession { @@ -525,7 +525,7 @@ p9anyclunk(Fcall *rx, Fcall *tx) fprint(2, "p9anyclunk: afid %d\n", rx->fid); safefree(sp->uname); safefree(sp->aname); - memset(sp, 0, sizeof(sp)); + memset(sp, 0, sizeof(*sp)); free(sp); return nil; }