mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
Fix to match new MD5 api. Faster, fixes memory leak.
This commit is contained in:
parent
9010366de8
commit
15abc19f5d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9491
3 changed files with 15 additions and 12 deletions
|
@ -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'); /* <MD5> */
|
||||
|
|
|
@ -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'); /* <MD5> */
|
||||
if(strcmp(q,p)) WRONG
|
||||
if (-1 != getc(fd)) WRONG
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue