Skip to content

Commit f80076f

Browse files
committed
Fixed compiler warnings regarding signed vs. unsigned char pointers.
Explicitly NUL-terminate the output buffer (even though it's static and thus is normally zero-initialized as part of .bss, and the output string is always same length so the NUL byte stayed intact across calls anyway). CVS-ID: c/crypt_private.c 1.5
1 parent e38ded4 commit f80076f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: c/crypt_private.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* http://www.openwall.com/crypt/
1111
*
1212
* Written by Solar Designer <solar at openwall.com> in 2005 and placed in
13-
* the public domain.
13+
* the public domain. Revised in subsequent years, still public domain.
1414
*
1515
* There's absolutely no warranty.
1616
*/
@@ -25,7 +25,7 @@
2525
static char *itoa64 =
2626
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
2727

28-
static void encode64(char *dst, char *src, int count)
28+
static void encode64(char *dst, unsigned char *src, int count)
2929
{
3030
int i, value;
3131

@@ -45,13 +45,15 @@ static void encode64(char *dst, char *src, int count)
4545
break;
4646
*dst++ = itoa64[(value >> 18) & 0x3f];
4747
} while (i < count);
48+
49+
*dst = 0;
4850
}
4951

5052
char *crypt_private(char *password, char *setting)
5153
{
5254
static char output[35];
5355
MD5_CTX ctx;
54-
char hash[MD5_DIGEST_LENGTH];
56+
unsigned char hash[MD5_DIGEST_LENGTH];
5557
char *p, *salt;
5658
int count_log2, length, count;
5759

0 commit comments

Comments
 (0)