diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2026-03-24 21:25:15 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2026-03-24 21:25:15 +0100 |
| commit | d0787f963e3d7d918bac3ee1e072f233b070fb5d (patch) | |
| tree | 85d5d46c2327ef065d5651802df422bee64cb379 /FICS/eco.c | |
| parent | 89e6b8decafe1526f685d760e1e8e73e8432a390 (diff) | |
Check for too long filenames
Diffstat (limited to 'FICS/eco.c')
| -rw-r--r-- | FICS/eco.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -13,6 +13,7 @@ #include "eco.h" #include "gamedb.h" #include "gameproc.h" +#include "maxxes-utils.h" #include "obsproc.h" #include "playerdb.h" #include "utils.h" @@ -139,9 +140,12 @@ ECO_init(void) char tmp[ECO_MAXTMP] = { '\0' }; char *ptmp = tmp; int i = 0; + int ret; - snprintf(filename, sizeof filename, "%s/eco999.idx", book_dir); + ret = snprintf(filename, sizeof filename, "%s/eco999.idx", book_dir); + if (is_too_long(ret, sizeof filename)) + errx(1, "%s: fatal: too long filename", __func__); if ((fp = fopen(filename, "r")) == NULL) err(1, "Could not open ECO file (%s)", filename); @@ -210,9 +214,12 @@ NIC_init(void) char tmp[ECO_MAXTMP] = { '\0' }; char *ptmp = tmp; int i = 0; + int ret; - snprintf(filename, sizeof filename, "%s/nic999.idx", book_dir); + ret = snprintf(filename, sizeof filename, "%s/nic999.idx", book_dir); + if (is_too_long(ret, sizeof filename)) + errx(1, "%s: fatal: too long filename", __func__); if ((fp = fopen(filename, "r")) == NULL) err(1, "Could not open NIC file (%s)", filename); @@ -274,9 +281,12 @@ LONG_init(void) char tmp[ECO_MAXTMP] = { '\0' }; char *ptmp = tmp; int i = 0; + int ret; - snprintf(filename, sizeof filename, "%s/long999.idx", book_dir); + ret = snprintf(filename, sizeof filename, "%s/long999.idx", book_dir); + if (is_too_long(ret, sizeof filename)) + errx(1, "%s: fatal: too long filename", __func__); if ((fp = fopen(filename, "r")) == NULL) err(1, "Could not open LONG file (%s)", filename); |
