~dax/xdcc-legacy

440f8c942509532861b888f471cd68c56c3cbdeb — dax 1 year, 4 months ago daa7119 0.1.0
rand_nick: pass NICKLEN instead of using sizeof()
1 files changed, 5 insertions(+), 6 deletions(-)

M main.c
M main.c => main.c +5 -6
@@ 25,14 25,13 @@ static int noconfirm = 0;
 * Generate a random nickname
 */
static void
rand_nick(char *nick)
rand_nick(char *nick, size_t nicklen)
{
	size_t len = sizeof(nick);
	for (int i=0; i < len-1; i++)
	for (int i=0; i < nicklen-1; i++)
	{
		nick[i] = rand() % 25 + 97;
	}
	nick[len-1] = '\0';
	nick[nicklen-1] = '\0';
}




@@ 52,7 51,7 @@ processmsg(int serverfd, Message msg)
	/* ERR_NICKNAMEINUSE */
	if (atoi(msg.cmd) == 432 || atoi(msg.cmd) == 433) {
		char new_nick[8];
		rand_nick(new_nick);
		rand_nick(new_nick, 8);
		nick(serverfd, new_nick);
	}



@@ 209,7 208,7 @@ main(int argc, char **argv)
		login(serverfd, nick);
	} else {
		char new_nick[8];
		rand_nick(new_nick);
		rand_nick(new_nick, 8);
		login(serverfd, new_nick);
	}