From e67489c6ddd7a229c68027eb673605dad7f64254 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 17 Nov 2013 00:38:25 +0100 Subject: Fix some compiler warnings - Remove some unused variables - Explicitly cast =tbuff= to a pointer to =unsigned char= when using =SHA512=. - Use =long long unsigned= as =seqno=, since there is no theoretical limit to it. - Use =size_t= for the =tbufflen= variable in =dispass1= since technically that is what =strlen= returns. --- sha1.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sha1.c b/sha1.c index 5198a19..3024845 100644 --- a/sha1.c +++ b/sha1.c @@ -71,18 +71,17 @@ rmchar(char rm, char **s) } char * -dispass1(char *label, char *password, int len, int seqno) +dispass1(char *label, char *password, int len, long long unsigned seqno) { - int i; unsigned char *d; - long tbufflen = strlen(label) + strlen(password) + 1; + size_t tbufflen = strlen(label) + strlen(password) + 1; char *tbuff = calloc(tbufflen, sizeof(char)); char buff[MAXLEN + 1] = { '\0' }; char *b64; strcat(tbuff, label); strcat(tbuff, password); - d = SHA512(tbuff, strlen(tbuff), 0); + d = SHA512((unsigned char *)tbuff, strlen(tbuff), 0); free(tbuff); sha512_to_string(d, buff); b64 = base64encode(buff, strlen(buff)); @@ -93,9 +92,8 @@ dispass1(char *label, char *password, int len, int seqno) } char * -dispass2(char *label, char *password, int len, int seqno) +dispass2(char *label, char *password, int len, long long unsigned seqno) { - int i; unsigned char *d; char ibuff[300]; char *tbuff, *b64; @@ -107,7 +105,7 @@ dispass2(char *label, char *password, int len, int seqno) strcat(tbuff, label); strcat(tbuff, ibuff); strcat(tbuff, password); - d = SHA512(tbuff, strlen(tbuff), 0); + d = SHA512((unsigned char *)tbuff, strlen(tbuff), 0); free(tbuff); sha512_to_string(d, buff); b64 = base64encode(buff, strlen(buff)); -- cgit v1.2.3-54-g00ecf