From f1198f411ff0ca77fef0957107cd07ff2ed9bed6 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Thu, 15 May 2003 18:10:39 +0000 Subject: [PATCH] stifle-valgrind-20030515 FIXES 1379 shut up valgrind on zeroing allocations --- src/auth/authcon.c | 1 + src/auth/ktc.c | 2 ++ src/des/des.c | 4 ++-- src/viced/callback.c | 16 ++++++++-------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/auth/authcon.c b/src/auth/authcon.c index f532e450a..2935863d1 100644 --- a/src/auth/authcon.c +++ b/src/auth/authcon.c @@ -110,6 +110,7 @@ rxkad_level enclevel; { /* now create the actual ticket */ ticketLen = sizeof(tbuffer); + memset(tbuffer, '\0', sizeof(tbuffer)); code = tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0, 0xffffffff, &session, 0, "afs", ""); /* parms were buffer, ticketlen, key to seal ticket with, principal diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 52fe63e17..2c3848340 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -656,6 +656,8 @@ struct ktc_principal *aserver; { register char *tp; afs_int32 temp, index; + memset(tbuffer, 0, sizeof(tbuffer)); + LOCK_GLOBAL_MUTEX #ifndef NO_AFS_CLIENT TRY_KERNEL (KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0); diff --git a/src/des/des.c b/src/des/des.c index 20f79f142..63ab00655 100644 --- a/src/des/des.c +++ b/src/des/des.c @@ -75,8 +75,8 @@ afs_int32 des_ecb_encrypt(afs_uint32 *clear, afs_uint32 *cipher, { /* better pass 8 bytes, length not checked here */ - register afs_uint32 R1, L1; /* R1 = r10, L1 = r9 */ - register afs_uint32 R2, L2; /* R2 = r8, L2 = r7 */ + register afs_uint32 R1 = 0, L1 = 0; /* R1 = r10, L1 = r9 */ + register afs_uint32 R2 = 0, L2 = 0; /* R2 = r8, L2 = r7 */ afs_int32 i; /* one more registers left on VAX, see below P_temp_p */ #ifdef BITS16 diff --git a/src/viced/callback.c b/src/viced/callback.c index 441d087c4..086a5b292 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -518,7 +518,7 @@ int InitCallBack(int nblks) tfirst = CBtime(FT_ApproxTime()); /* N.B. The "-1", below, is because FE[0] and CB[0] are not used--and not allocated */ - FE = ((struct FileEntry *)(malloc(sizeof(struct FileEntry)*nblks)))-1; + FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry))))-1; if (!FE) { ViceLog(0, ("Failed malloc in InitCallBack\n")); assert(0); @@ -526,7 +526,7 @@ int InitCallBack(int nblks) cbstuff.nFEs = nblks; while (cbstuff.nFEs) FreeFE(&FE[cbstuff.nFEs]); /* This is correct */ - CB = ((struct CallBack *)(malloc(sizeof(struct CallBack)*nblks)))-1; + CB = ((struct CallBack *)(calloc(nblks, sizeof(struct CallBack))))-1; if (!CB) { ViceLog(0, ("Failed malloc in InitCallBack\n")); assert(0); @@ -1688,8 +1688,8 @@ time_t ReadDump(char *file) read(fd, timeout, sizeof(timeout)); read(fd, &tfirst, sizeof(tfirst)); read(fd, &freelisthead, sizeof(freelisthead)); - CB = ((struct CallBack *)(malloc(sizeof(struct FileEntry)*cbstuff.nblks)))-1; - FE = ((struct FileEntry *)(malloc(sizeof(struct FileEntry)*cbstuff.nblks)))-1; + CB = ((struct CallBack *)(calloc(cbstuff.nblks,sizeof(struct FileEntry))))-1; + FE = ((struct FileEntry *)(calloc(cbstuff.nblks,sizeof(struct FileEntry))))-1; CBfree = (struct CallBack *) itocb(freelisthead); read(fd, &freelisthead, sizeof(freelisthead)); FEfree = (struct FileEntry *) itofe(freelisthead); @@ -1874,8 +1874,8 @@ int MultiBreakCallBackAlternateAddress_r(struct host *host, struct AFSCBFids *af sc = rxnull_NewClientSecurityObject(); i = host->interface->numberOfInterfaces; - addr = malloc(i * sizeof(afs_int32)); - conns = malloc(i * sizeof(struct rx_connection *)); + addr = calloc(i, sizeof(afs_int32)); + conns = calloc(i, sizeof(struct rx_connection *)); if (!addr || !conns) { ViceLog(0, ("Failed malloc in MultiBreakCallBackAlternateAddress_r\n")); assert(0); @@ -1962,8 +1962,8 @@ int MultiProbeAlternateAddress_r(struct host *host) sc = rxnull_NewClientSecurityObject(); i = host->interface->numberOfInterfaces; - addr = malloc(i * sizeof(afs_int32)); - conns = malloc(i * sizeof(struct rx_connection *)); + addr = calloc(i, sizeof(afs_int32)); + conns = calloc(i, sizeof(struct rx_connection *)); if (!addr || !conns) { ViceLog(0, ("Failed malloc in MultiProbeAlternateAddress_r\n")); assert(0); -- 2.39.5