aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/playerdb.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-12-02 15:18:53 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-12-02 15:18:53 +0100
commit796a9c0565610447a890d1576880ae52b7e1680b (patch)
treed0636d04e276590f233e62e6e4de3c78e7173079 /FICS/playerdb.c
parent551f882ff20ac6f902e38e6591fe57484a1da2ef (diff)
got_attr_value_player: check the return of fgets()
Diffstat (limited to 'FICS/playerdb.c')
-rw-r--r--FICS/playerdb.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index a82f3b9..2ac7389 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -795,7 +795,12 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
if (parray[p].num_plan > 0) {
for (i = 0; i < parray[p].num_plan; i++) {
- fgets(tmp, sizeof tmp, fp);
+
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad plan: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp))) {
fprintf(stderr, "FICS: Error bad plan "
@@ -818,7 +823,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
if (parray[p].num_formula > 0) {
for (i = 0; i < parray[p].num_formula; i++) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad formula: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp))) {
fprintf(stderr, "FICS: Error bad "
@@ -847,7 +856,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
if (parray[p].numAlias > 0) {
for (i = 0; i < parray[p].numAlias; i++) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad alias: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp))) {
fprintf(stderr, "FICS: Error bad alias "
@@ -877,7 +890,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
i = atoi(value);
while (i--) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad censor: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp)) || len == 1) { // blank lines
// do occur!
@@ -892,7 +909,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
i = atoi(value);
while (i--) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad notify: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp)) || len == 1) { // blank lines
// do occur!
@@ -907,7 +928,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
i = atoi(value);
while (i--) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad noplay: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp)) || len == 1) { // blank lines
// do occur!
@@ -922,7 +947,11 @@ got_attr_value_player(int p, char *attr, char *value, FILE *fp, char *file)
i = atoi(value);
while (i--) {
- fgets(tmp, sizeof tmp, fp);
+ if (fgets(tmp, sizeof tmp, fp) == NULL) {
+ warnx("%s: bad gnotify: feof %s",
+ __func__, file);
+ return -1;
+ }
if (!(len = strlen(tmp)) || len == 1) { // blank lines
// do occur!