summaryrefslogtreecommitdiff
path: root/src/htssafe.h
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2014-05-04 15:17:21 +0000
committerXavier Roche <xroche@users.noreply.github.com>2014-05-04 15:17:21 +0000
commit76dc4d04fccb69366c9006e993eadbbc7bcb5048 (patch)
tree40b5b2c2fb51c7f3f6912ae94b3c1a861e4b1ab5 /src/htssafe.h
parent5b0c24aa715b8dab77e2b156b880df545516852a (diff)
Added strlcatbuff
Diffstat (limited to 'src/htssafe.h')
-rw-r--r--src/htssafe.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/htssafe.h b/src/htssafe.h
index 33a3490..1181bde 100644
--- a/src/htssafe.h
+++ b/src/htssafe.h
@@ -119,6 +119,14 @@ static HTS_UNUSED void abortf_(const char *exp, const char *file, int line) {
*/
#define strcpybuff(A, B) (clear_buffer_(A), strcatbuff(A, B))
+/**
+ * Append characters of "B" to "A", "A" having a maximum capacity of "S".
+ */
+#define strlcatbuff(A, B, S) \
+ strncat_safe_(A, S, B, \
+ HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), (size_t) -1, \
+ "overflow while copying '" #B "' to '"#A"'", __FILE__, __LINE__)
+
static HTS_INLINE HTS_UNUSED size_t strlen_safe_(const char *source, const size_t sizeof_source,
const char *file, int line) {
size_t size;