diff options
author | grant <grant> | 2002-12-22 12:15:11 +0000 |
---|---|---|
committer | grant <grant> | 2002-12-22 12:15:11 +0000 |
commit | f7f7745ff3692ac8fc86d457bdbe630ac36c25ac (patch) | |
tree | 0ddb8ee20e5031decdd2010910233059bf8d675f /pkgtools | |
parent | a19d585365f32e1468d5b1e9660cbdbb02478626 (diff) | |
download | pkgsrc-f7f7745ff3692ac8fc86d457bdbe630ac36c25ac.tar.gz |
fix MD5File() compatibility function to accept NULL second argument.
fixes problem with `pkg_admin check'.
Fix from Frank Cusack in PR pkg/19492.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/lib/digest.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pkgtools/pkg_install/files/lib/digest.c b/pkgtools/pkg_install/files/lib/digest.c index 53a623796fc..f0ae0b8a146 100644 --- a/pkgtools/pkg_install/files/lib/digest.c +++ b/pkgtools/pkg_install/files/lib/digest.c @@ -1,4 +1,4 @@ -/* $NetBSD: digest.c,v 1.1.1.1 2002/12/20 18:13:59 schmonz Exp $ */ +/* $NetBSD: digest.c,v 1.2 2002/12/22 12:15:11 grant Exp $ */ /* * Copyright (c) 2002 Alistair G. Crooks. All rights reserved. @@ -36,7 +36,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 2002 \ The NetBSD Foundation, Inc. All rights reserved."); -__RCSID("$NetBSD: digest.c,v 1.1.1.1 2002/12/20 18:13:59 schmonz Exp $"); +__RCSID("$NetBSD: digest.c,v 1.2 2002/12/22 12:15:11 grant Exp $"); #endif #endif @@ -83,8 +83,15 @@ MD5File(char *filename, char *buf) } (void) pclose(pp); cp = strrchr(in, ' '); - (void) strcpy(buf, cp + 1); - buf[_MD5_ASCII_BUF_SIZE - 1] = 0; + if (buf) + (void) strncpy(buf, cp + 1, _MD5_ASCII_BUF_SIZE); + else { + buf = malloc(_MD5_ASCII_BUF_SIZE); + if (buf == NULL) + return NULL; + (void) strncpy(buf, cp + 1, _MD5_ASCII_BUF_SIZE); + } + buf[_MD5_ASCII_BUF_SIZE - 1] = '\0'; return buf; } #endif |