diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-02 20:35:30 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-02 20:35:30 +0000 |
commit | 55b34ca7e0525ae9bd2611568866c727065141a5 (patch) | |
tree | a7e8861a87b4216de8893856064e3a2fad530d88 /lib | |
parent | 227a63abf6365e2a71a51c7b0f068093ea8cbcaa (diff) |
Use snprintf instead of a strcpy(), strncat() and strcat() sequence
deraadt@ OK
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/crypt/md5crypt.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libc/crypt/md5crypt.c b/lib/libc/crypt/md5crypt.c index 56ab66fbb59..048858494c2 100644 --- a/lib/libc/crypt/md5crypt.c +++ b/lib/libc/crypt/md5crypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5crypt.c,v 1.10 2002/02/16 21:27:22 millert Exp $ */ +/* $OpenBSD: md5crypt.c,v 1.11 2003/04/02 20:35:29 millert Exp $ */ /* * ---------------------------------------------------------------------------- @@ -13,7 +13,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: md5crypt.c,v 1.10 2002/02/16 21:27:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: md5crypt.c,v 1.11 2003/04/02 20:35:29 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <unistd.h> @@ -108,9 +108,8 @@ md5crypt(pw, salt) MD5Update(&ctx, (const unsigned char *)pw, 1); /* Now make the output string */ - strcpy(passwd,(const char *)magic); - strncat(passwd,(const char *)sp,sl); - strcat(passwd,"$"); + snprintf(passwd, sizeof(passwd), "%s%.*s$", (char *)magic, + sl, (const char *)sp); MD5Final(final,&ctx); |