aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-05-01 15:06:46 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-05-01 15:06:46 +0200
commit7b368abe5174317220183c7ecef31155ecc55e38 (patch)
tree17885bdc3938e9982c0d2487ce8dca0c195715c4
parent3b4cea758d73f6488d8c1c79c4ee448ed3622e0e (diff)
Added check
-rw-r--r--FICS/command.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/FICS/command.c b/FICS/command.c
index 3e85169..e934dcc 100644
--- a/FICS/command.c
+++ b/FICS/command.c
@@ -188,8 +188,16 @@ alias_substitute(alias_type *alias_list, int num_alias, char *com_str,
atpos = strchr(aliasval, '@');
if (atpos != NULL) {
- strncpy(outalias, aliasval, atpos - aliasval);
- outalias[atpos - aliasval] = '\0';
+ const size_t diff = atpos - aliasval;
+
+ if (diff >= size) { // XXX
+ warnx("%s: diff out of bounds!", __func__);
+ return;
+ }
+
+ strncpy(outalias, aliasval, diff);
+ outalias[diff] = '\0';
+
mstrlcat(outalias, s, size);
mstrlcat(outalias, atpos + 1, size);
} else {