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.
This commit is contained in:
Tom Willemse 2013-11-17 00:38:25 +01:00
parent 6e7e8e9ba2
commit e67489c6dd

12
sha1.c
View file

@ -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));