From 4b11f39115bedeb138377c2883675cafec574c2b Mon Sep 17 00:00:00 2001 From: Matt Ullman Date: Wed, 23 Mar 2016 19:11:42 -0400 Subject: [PATCH] Move away from BSD data types --- include/match.h | 4 ++-- ircd/chmode.c | 8 ++++---- ircd/match.c | 6 +++--- librb/src/crypt.c | 38 +++++++++++++++++++------------------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/match.h b/include/match.h index c49e12e9..151ad4bf 100644 --- a/include/match.h +++ b/include/match.h @@ -46,8 +46,8 @@ extern int match_ips(const char *mask, const char *name); /* * comp_with_mask - compares to IP address */ -int comp_with_mask(void *addr, void *dest, u_int mask); -int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask); +int comp_with_mask(void *addr, void *dest, unsigned int mask); +int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, unsigned int mask); /* * collapse - collapse a string in place, converts multiple adjacent *'s diff --git a/ircd/chmode.c b/ircd/chmode.c index 6ec2f497..cefcdbd3 100644 --- a/ircd/chmode.c +++ b/ircd/chmode.c @@ -535,9 +535,9 @@ check_forward(struct Client *source_p, struct Channel *chptr, static char * fix_key(char *arg) { - u_char *s, *t, c; + unsigned char *s, *t, c; - for(s = t = (u_char *) arg; (c = *s); s++) + for(s = t = (unsigned char *) arg; (c = *s); s++) { c &= 0x7f; if(c != ':' && c != ',' && c > ' ') @@ -558,9 +558,9 @@ fix_key(char *arg) static char * fix_key_remote(char *arg) { - u_char *s, *t, c; + unsigned char *s, *t, c; - for(s = t = (u_char *) arg; (c = *s); s++) + for(s = t = (unsigned char *) arg; (c = *s); s++) { c &= 0x7f; if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' ')) diff --git a/ircd/match.c b/ircd/match.c index 87a1c7ef..66ffe236 100644 --- a/ircd/match.c +++ b/ircd/match.c @@ -308,13 +308,13 @@ match_esc(const char *mask, const char *name) return 0; } -int comp_with_mask(void *addr, void *dest, u_int mask) +int comp_with_mask(void *addr, void *dest, unsigned int mask) { if (memcmp(addr, dest, mask / 8) == 0) { int n = mask / 8; int m = ((-1) << (8 - (mask % 8))); - if (mask % 8 == 0 || (((u_char *) addr)[n] & m) == (((u_char *) dest)[n] & m)) + if (mask % 8 == 0 || (((unsigned char *) addr)[n] & m) == (((unsigned char *) dest)[n] & m)) { return (1); } @@ -322,7 +322,7 @@ int comp_with_mask(void *addr, void *dest, u_int mask) return (0); } -int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask) +int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, unsigned int mask) { void *iaddr = NULL; void *idest = NULL; diff --git a/librb/src/crypt.c b/librb/src/crypt.c index 206027fd..4b807c7e 100644 --- a/librb/src/crypt.c +++ b/librb/src/crypt.c @@ -1072,8 +1072,8 @@ rb_md5_crypt(const char *pw, const char *salt) MD5_CTX ctx,ctx1; unsigned long l; int sl, pl; - u_int i; - u_char final[MD5_SIZE]; + unsigned int i; + unsigned char final[MD5_SIZE]; static const char *sp, *ep; static char passwd[120], *p; static const char *magic = "$1$"; @@ -1095,23 +1095,23 @@ rb_md5_crypt(const char *pw, const char *salt) MD5Init(&ctx); /* The password first, since that is what is most unknown */ - MD5Update(&ctx, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx, (const unsigned char *)pw, strlen(pw)); /* Then our magic string */ - MD5Update(&ctx, (const u_char *)magic, strlen(magic)); + MD5Update(&ctx, (const unsigned char *)magic, strlen(magic)); /* Then the raw salt */ - MD5Update(&ctx, (const u_char *)sp, (u_int)sl); + MD5Update(&ctx, (const unsigned char *)sp, (unsigned int)sl); /* Then just as many characters of the MD5(pw,salt,pw) */ MD5Init(&ctx1); - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); - MD5Update(&ctx1, (const u_char *)sp, (u_int)sl); - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)sp, (unsigned int)sl); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); MD5Final(final, &ctx1); for(pl = (int)strlen(pw); pl > 0; pl -= MD5_SIZE) - MD5Update(&ctx, (const u_char *)final, - (u_int)(pl > MD5_SIZE ? MD5_SIZE : pl)); + MD5Update(&ctx, (const unsigned char *)final, + (unsigned int)(pl > MD5_SIZE ? MD5_SIZE : pl)); /* Don't leave anything around in vm they could use. */ memset(final, 0, sizeof(final)); @@ -1119,13 +1119,13 @@ rb_md5_crypt(const char *pw, const char *salt) /* Then something really weird... */ for (i = strlen(pw); i; i >>= 1) if(i & 1) - MD5Update(&ctx, (const u_char *)final, 1); + MD5Update(&ctx, (const unsigned char *)final, 1); else - MD5Update(&ctx, (const u_char *)pw, 1); + MD5Update(&ctx, (const unsigned char *)pw, 1); /* Now make the output string */ rb_strlcpy(passwd, magic, sizeof(passwd)); - strncat(passwd, sp, (u_int)sl); + strncat(passwd, sp, (unsigned int)sl); rb_strlcat(passwd, "$", sizeof(passwd)); MD5Final(final, &ctx); @@ -1138,20 +1138,20 @@ rb_md5_crypt(const char *pw, const char *salt) for(i = 0; i < 1000; i++) { MD5Init(&ctx1); if(i & 1) - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); else - MD5Update(&ctx1, (const u_char *)final, MD5_SIZE); + MD5Update(&ctx1, (const unsigned char *)final, MD5_SIZE); if(i % 3) - MD5Update(&ctx1, (const u_char *)sp, (u_int)sl); + MD5Update(&ctx1, (const unsigned char *)sp, (unsigned int)sl); if(i % 7) - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); if(i & 1) - MD5Update(&ctx1, (const u_char *)final, MD5_SIZE); + MD5Update(&ctx1, (const unsigned char *)final, MD5_SIZE); else - MD5Update(&ctx1, (const u_char *)pw, strlen(pw)); + MD5Update(&ctx1, (const unsigned char *)pw, strlen(pw)); MD5Final(final, &ctx1); }