From 8a9732c33888462d6fb34f693688e43ff1e31eaa Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Tue, 28 May 2019 20:57:17 +0100 Subject: Fix BLABOUNCER REPLAY time values of "0" (e.g. 1:00:00 for one hour). --- blabouncer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index e67c083..5fa2e5d 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1915,8 +1915,12 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli // Make sure all the components are numbers for (int i = 0; i < timecounter; i++) { - int check; - if ((check = strtol(timetokens[i], NULL, 10)) == 0) { + // Temporary number and pointer for checking errors + long check; + char *str_end; + errno = 0; + check = strtol(timetokens[i], &str_end, 10); + if (str_end == timetokens[i] || ((check == LONG_MAX || check == LONG_MIN) && errno == ERANGE)) { debugprint("Invalid number '%s' requested by REPLAY command. Telling client.\n", timetokens[i]); if (!snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Invalid number '%s' requested by REPLAY command.", ircdstrings->ircnick, timetokens[i])) { fprintf(stderr, "Error while preparing REPLAY invalid number response!\n"); -- cgit v1.2.3