From 0c8edb2939d5359266bb00cb5ec6f8cfe3d8fef4 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 5 Apr 2025 13:22:14 +0200 Subject: Check for negative values --- FICS/playerdb.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'FICS') diff --git a/FICS/playerdb.c b/FICS/playerdb.c index eedaf39..18c3188 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -969,7 +969,10 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file) * num_censor */ - i = atoi(value); + if ((i = atoi(value)) < 0) { + warnx("%s: num censor negative", __func__); + return -1; + } while (i--) { if (fgets(tmp, sizeof tmp, fp) == NULL) { @@ -988,7 +991,10 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file) } } } else if (!strcmp(attr, "num_notify:")) { - i = atoi(value); + if ((i = atoi(value)) < 0) { + warnx("%s: num notify negative", __func__); + return -1; + } while (i--) { if (fgets(tmp, sizeof tmp, fp) == NULL) { @@ -1007,7 +1013,10 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file) } } } else if (!strcmp(attr, "num_noplay:")) { - i = atoi(value); + if ((i = atoi(value)) < 0) { + warnx("%s: num noplay negative", __func__); + return -1; + } while (i--) { if (fgets(tmp, sizeof tmp, fp) == NULL) { @@ -1026,7 +1035,10 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file) } } } else if (!strcmp(attr, "num_gnotify:")) { - i = atoi(value); + if ((i = atoi(value)) < 0) { + warnx("%s: num gnotify negative", __func__); + return -1; + } while (i--) { if (fgets(tmp, sizeof tmp, fp) == NULL) { -- cgit v1.2.3