diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-04-05 13:22:14 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-04-05 13:22:14 +0200 |
commit | 0c8edb2939d5359266bb00cb5ec6f8cfe3d8fef4 (patch) | |
tree | f9d633ef9f425ab2523cc82af819732f41b3c3e6 /FICS | |
parent | c24bfddeae8d9997cdedf643b551577ff6af136c (diff) |
Check for negative values
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/playerdb.c | 20 |
1 files changed, 16 insertions, 4 deletions
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) { |