diff options
author | grant <grant@pkgsrc.org> | 2002-12-22 12:15:11 +0000 |
---|---|---|
committer | grant <grant@pkgsrc.org> | 2002-12-22 12:15:11 +0000 |
commit | 4c9c04ddc9869a6bf461465bc5091fa539974203 (patch) | |
tree | 0ddb8ee20e5031decdd2010910233059bf8d675f /pkgtools | |
parent | d33c431bc70aa8b022bf6f9c2019dd4870ca053f (diff) | |
download | pkgsrc-4c9c04ddc9869a6bf461465bc5091fa539974203.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 |