--- a/src/compat.c
+++ b/src/compat.c
@@ -19,3 +19,18 @@
return buf;
}
+
+char *safe_strncpy (char *dest, const char *src, size_t size)
+{
+ size_t i;
+
+ for (i = 0; i < size - 1; i++) {
+ if (src[i] == '\0')
+ break;
+ dest[i] = src[i];
+ }
+
+ dest[i] = '\0';
+
+ return dest;
+}