aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'FICS/command.c')
-rw-r--r--FICS/command.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/FICS/command.c b/FICS/command.c
index fdf7cbb..569c27a 100644
--- a/FICS/command.c
+++ b/FICS/command.c
@@ -33,6 +33,9 @@
check_news() and
rscan_news().
Markus Uhlin 24/11/25 Null checks
+ Markus Uhlin 25/03/09 Fixed double free()
+ Markus Uhlin 25/03/11 Fixed memleak
+ Markus Uhlin 25/03/16 Fixed use of 32-bit 'time_t'
*/
#include "stdinclude.h"
@@ -129,7 +132,11 @@ parse_command(char *com_string, char **comm, char **parameters)
PUBLIC int
alias_lookup(char *tmp, alias_type *alias_list, int numalias)
{
- for (int i = 0; (alias_list[i].comm_name && i < numalias); i++) {
+ if (numalias >= MAX_ALIASES)
+ return -1;
+ for (int i = 0;
+ (i < numalias && alias_list[i].comm_name != NULL);
+ i++) {
if (!strcmp(tmp, alias_list[i].comm_name))
return i;
}
@@ -571,12 +578,18 @@ process_login(int p, char *loginname)
if (!alphastring(loginname)) {
pprintf(p, "\nSorry, names can only consist of lower "
"and upper case letters. Try again.\n");
+ rfree(loginnameii);
+ loginnameii = NULL;
} else if (strlen(loginname) < 3) {
pprintf(p, "\nA name should be at least three "
"characters long! Try again.\n");
+ rfree(loginnameii);
+ loginnameii = NULL;
} else if (strlen(loginname) > 17) {
pprintf(p, "\nSorry, names may be at most 17 "
"characters long. Try again.\n");
+ rfree(loginnameii);
+ loginnameii = NULL;
} else if (in_list(p, L_BAN, loginnameii)) {
pprintf(p, "\nPlayer \"%s\" is banned.\n", loginname);
rfree(loginnameii);
@@ -636,12 +649,12 @@ process_login(int p, char *loginname)
parray[p].status = PLAYER_PASSWORD;
turn_echo_off(parray[p].socket);
rfree(loginnameii);
+ loginnameii = NULL; // XXX
if (strcasecmp(loginname, parray[p].name)) {
pprintf(p, "\nYou've got a bad name field in "
"your playerfile -- please report this to "
"an admin!\n");
- rfree(loginnameii);
return COM_LOGOUT;
}
@@ -652,7 +665,6 @@ process_login(int p, char *loginname)
pprintf(p, "Your handle is missing!");
pprintf(p, "Please log on as an unreg until "
"an admin can correct this.\n");
- rfree(loginnameii);
return COM_LOGOUT;
}
@@ -663,7 +675,6 @@ process_login(int p, char *loginname)
pprintf(p, "Your FullName is missing!");
pprintf(p, "Please log on as an unreg until "
"an admin can correct this.\n");
- rfree(loginnameii);
return COM_LOGOUT;
}
@@ -674,7 +685,6 @@ process_login(int p, char *loginname)
pprintf(p, "Your Email address is missing\n");
pprintf(p, "Please log on as an unreg until "
"an admin can correct this.\n");
- rfree(loginnameii);
return COM_LOGOUT;
}
}
@@ -704,7 +714,7 @@ boot_out(int p, int p1)
}
PUBLIC void
-rscan_news(FILE *fp, int p, int lc)
+rscan_news(FILE *fp, int p, time_t lc)
{
char *junkp = NULL;
char count[10] = { '\0' };
@@ -1214,10 +1224,10 @@ PUBLIC int
process_heartbeat(int *fd)
{
time_t now = time(NULL);
- int time_since_last;
- static int last_comfile = 0;
- static int last_space = 0;
- static int lastcalled = 0;
+ time_t time_since_last;
+ static time_t last_comfile = 0;
+ static time_t last_space = 0;
+ static time_t lastcalled = 0;
if (lastcalled == 0)
time_since_last = 0;