From 1e1f566194e494df47e4c8269325505fe7bdf391 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 12 Jul 1995 09:16:13 +0000 Subject: Fix to match new MD5 api. Faster, fixes memory leak. --- usr.sbin/ctm/ctm/ctm_pass1.c | 7 ++++--- usr.sbin/ctm/ctm/ctm_pass2.c | 9 +++++---- usr.sbin/ctm/ctm/ctm_pass3.c | 11 ++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'usr.sbin/ctm') diff --git a/usr.sbin/ctm/ctm/ctm_pass1.c b/usr.sbin/ctm/ctm/ctm_pass1.c index 6b00fcc..223d66c 100644 --- a/usr.sbin/ctm/ctm/ctm_pass1.c +++ b/usr.sbin/ctm/ctm/ctm_pass1.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm_pass1.c,v 1.9 1995/03/26 20:09:52 phk Exp $ + * $Id: ctm_pass1.c,v 1.10 1995/05/30 03:47:23 rgrimes Exp $ * */ @@ -27,6 +27,7 @@ Pass1(FILE *fd, unsigned applied) struct CTM_Syntax *sp; int slashwarn=0; unsigned current; + char md5_1[33]; if(Verbose>3) printf("Pass1 -- Checking integrity of incoming CTM-patch\n"); @@ -166,7 +167,7 @@ Pass1(FILE *fd, unsigned applied) case CTM_F_Bytes: if(cnt < 0) WRONG GETDATA(trash,cnt); - p = MD5Data(trash,cnt); + p = MD5Data(trash,cnt,md5_1); if(md5 && strcmp(md5,p)) { Fatal("Internal MD5 failed."); return 1; @@ -183,7 +184,7 @@ Pass1(FILE *fd, unsigned applied) putc('\n',stderr); continue; } - q = MD5End (&ctx); + q = MD5End (&ctx,md5_1); if(Verbose > 2) printf("Expecting Global MD5 <%s>\n",q); GETFIELD(p,'\n'); /* */ diff --git a/usr.sbin/ctm/ctm/ctm_pass2.c b/usr.sbin/ctm/ctm/ctm_pass2.c index 7ce55e2..bbf2e4e 100644 --- a/usr.sbin/ctm/ctm/ctm_pass2.c +++ b/usr.sbin/ctm/ctm/ctm_pass2.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm_pass2.c,v 1.7 1995/03/19 12:01:23 roberto Exp $ + * $Id: ctm_pass2.c,v 1.8 1995/05/30 03:47:24 rgrimes Exp $ * */ @@ -27,6 +27,7 @@ Pass2(FILE *fd) struct CTM_Syntax *sp; struct stat st; int ret = 0; + char md5_1[33]; if(Verbose>3) printf("Pass2 -- Checking if CTM-patch will apply\n"); @@ -117,7 +118,7 @@ Pass2(FILE *fd) if(j & CTM_Q_MD5_Before) { GETFIELD(p,sep); if((st.st_mode & S_IFMT) == S_IFREG && - strcmp(MD5File(name),p)) { + strcmp(MD5File(name,md5_1),p)) { fprintf(stderr," %s: %s md5 mismatch.\n", sp->Key,name); if(j & CTM_Q_MD5_Force) { @@ -153,7 +154,7 @@ Pass2(FILE *fd) sp->Key,name,j); ret |= j; return ret; - } else if(strcmp(md5,MD5File(p))) { + } else if(strcmp(md5,MD5File(p,md5_1))) { fprintf(stderr," %s: %s edit fails.\n", sp->Key,name); ret |= Exit_Mess; @@ -168,7 +169,7 @@ Pass2(FILE *fd) } } } - q = MD5End (&ctx); + q = MD5End (&ctx,md5_1); GETFIELD(p,'\n'); /* */ if(strcmp(q,p)) WRONG if (-1 != getc(fd)) WRONG diff --git a/usr.sbin/ctm/ctm/ctm_pass3.c b/usr.sbin/ctm/ctm/ctm_pass3.c index 049648d..8cef972 100644 --- a/usr.sbin/ctm/ctm/ctm_pass3.c +++ b/usr.sbin/ctm/ctm/ctm_pass3.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ctm_pass3.c,v 1.9 1995/03/25 20:46:51 joerg Exp $ + * $Id: ctm_pass3.c,v 1.10 1995/05/30 03:47:27 rgrimes Exp $ * */ @@ -27,6 +27,7 @@ Pass3(FILE *fd) struct CTM_Syntax *sp; FILE *ed=0; struct stat st; + char md5_1[33]; if(Verbose>3) printf("Pass3 -- Applying the CTM-patch\n"); @@ -99,7 +100,7 @@ Pass3(FILE *fd) WRONG } close(i); - if(strcmp(md5,MD5File(name))) { + if(strcmp(md5,MD5File(name,md5_1))) { fprintf(stderr," %s %s MD5 didn't come out right\n", sp->Key,name); WRONG @@ -122,7 +123,7 @@ Pass3(FILE *fd) perror("ed"); WRONG } - if(strcmp(md5,MD5File(name))) { + if(strcmp(md5,MD5File(name,md5_1))) { fprintf(stderr," %s %s MD5 didn't come out right\n", sp->Key,name); WRONG @@ -139,7 +140,7 @@ Pass3(FILE *fd) WRONG } rename(buf,name); - if(strcmp(md5,MD5File(name))) { + if(strcmp(md5,MD5File(name,md5_1))) { fprintf(stderr," %s %s Edit failed MD5 check.\n", sp->Key,name); WRONG @@ -176,7 +177,7 @@ Pass3(FILE *fd) } WRONG } - q = MD5End (&ctx); + q = MD5End (&ctx,md5_1); GETFIELD(p,'\n'); if(strcmp(q,p)) WRONG if (-1 != getc(fd)) WRONG -- cgit v1.1