aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2026-03-08 01:11:47 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2026-03-08 01:11:47 +0100
commit43ab3781a768f8071c6e061fd451973e623bb326 (patch)
treeee31d0217468095d33c34538eef8a737602bfb7d
parent9c26b2d50fd35b9d8d040eb4449c38d6a15874b3 (diff)
Added is_too_long()
-rw-r--r--FICS/maxxes-utils.c8
-rw-r--r--FICS/maxxes-utils.h3
2 files changed, 10 insertions, 1 deletions
diff --git a/FICS/maxxes-utils.c b/FICS/maxxes-utils.c
index 7db8369..987be47 100644
--- a/FICS/maxxes-utils.c
+++ b/FICS/maxxes-utils.c
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2024 Markus Uhlin <maxxe@rpblc.net>
+// SPDX-FileCopyrightText: 2024-2026 Markus Uhlin <maxxe@rpblc.net>
// SPDX-License-Identifier: ISC
#include <err.h>
@@ -12,6 +12,12 @@
#include "maxxes-utils.h"
+bool
+is_too_long(const int p_ret, const size_t p_maxlen)
+{
+ return (p_ret < 0 || (size_t)p_ret >= p_maxlen);
+}
+
void
snprintf_trunc_chk(const char *file, const long int line,
char *str, size_t size, const char *format, ...)
diff --git a/FICS/maxxes-utils.h b/FICS/maxxes-utils.h
index 667151f..034c7ee 100644
--- a/FICS/maxxes-utils.h
+++ b/FICS/maxxes-utils.h
@@ -1,6 +1,7 @@
#ifndef MAXXES_UTILITIES_H
#define MAXXES_UTILITIES_H
+#include <stdbool.h>
#include <stddef.h>
#include "common.h"
@@ -12,6 +13,8 @@
#define mstrlcat(p_dst, p_src, p_dstsize) \
strlcat_trunc_chk((p_dst), (p_src), (p_dstsize), __FILE__, __LINE__)
+bool is_too_long(const int, const size_t);
+
void snprintf_trunc_chk(const char *file, const long int line,
char *str, size_t size, const char *format, ...) PRINTFLIKE(5);
void strlcpy_trunc_chk(char *dst, const char *src, size_t dstsize,