|
|
bb31b40 |
This is the strlcat function from openbsd:
|
|
|
bb31b40 |
http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/libc/string/strlcat.c
|
|
|
bb31b40 |
|
|
|
bb31b40 |
It is of course BSD-licensed, just like milter-regex itself.
|
|
|
bb31b40 |
|
|
|
bb31b40 |
--- /dev/null 2010-08-02 01:13:15.113045120 +0100
|
|
|
bb31b40 |
+++ strlcat.c 2005-08-08 09:05:37.000000000 +0100
|
|
|
bb31b40 |
@@ -0,0 +1,55 @@
|
|
|
bb31b40 |
+/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+/*
|
|
|
bb31b40 |
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
|
bb31b40 |
+ *
|
|
|
bb31b40 |
+ * Permission to use, copy, modify, and distribute this software for any
|
|
|
bb31b40 |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
|
bb31b40 |
+ * copyright notice and this permission notice appear in all copies.
|
|
|
bb31b40 |
+ *
|
|
|
bb31b40 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
bb31b40 |
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
bb31b40 |
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
bb31b40 |
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
bb31b40 |
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
bb31b40 |
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
bb31b40 |
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
bb31b40 |
+ */
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+#include <sys/types.h>
|
|
|
bb31b40 |
+#include <string.h>
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+/*
|
|
|
bb31b40 |
+ * Appends src to string dst of size siz (unlike strncat, siz is the
|
|
|
bb31b40 |
+ * full size of dst, not space left). At most siz-1 characters
|
|
|
bb31b40 |
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
|
|
bb31b40 |
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
|
|
bb31b40 |
+ * If retval >= siz, truncation occurred.
|
|
|
bb31b40 |
+ */
|
|
|
bb31b40 |
+size_t
|
|
|
bb31b40 |
+strlcat(char *dst, const char *src, size_t siz)
|
|
|
bb31b40 |
+{
|
|
|
bb31b40 |
+ char *d = dst;
|
|
|
bb31b40 |
+ const char *s = src;
|
|
|
bb31b40 |
+ size_t n = siz;
|
|
|
bb31b40 |
+ size_t dlen;
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+ /* Find the end of dst and adjust bytes left but don't go past end */
|
|
|
bb31b40 |
+ while (n-- != 0 && *d != '\0')
|
|
|
bb31b40 |
+ d++;
|
|
|
bb31b40 |
+ dlen = d - dst;
|
|
|
bb31b40 |
+ n = siz - dlen;
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+ if (n == 0)
|
|
|
bb31b40 |
+ return(dlen + strlen(s));
|
|
|
bb31b40 |
+ while (*s != '\0') {
|
|
|
bb31b40 |
+ if (n != 1) {
|
|
|
bb31b40 |
+ *d++ = *s;
|
|
|
bb31b40 |
+ n--;
|
|
|
bb31b40 |
+ }
|
|
|
bb31b40 |
+ s++;
|
|
|
bb31b40 |
+ }
|
|
|
bb31b40 |
+ *d = '\0';
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
+ return(dlen + (s - src)); /* count does not include NUL */
|
|
|
bb31b40 |
+}
|
|
|
bb31b40 |
--- Makefile.linux.orig 2007-01-11 15:49:52.000000000 +0000
|
|
|
bb31b40 |
+++ Makefile.linux 2010-08-13 09:55:38.047330128 +0100
|
|
|
bb31b40 |
@@ -11,8 +11,8 @@
|
|
|
bb31b40 |
|
|
|
bb31b40 |
all: milter-regex milter-regex.cat8
|
|
|
bb31b40 |
|
|
|
bb31b40 |
-milter-regex: milter-regex.o eval.o strlcpy.o y.tab.o
|
|
|
bb31b40 |
- gcc -o milter-regex milter-regex.o eval.o strlcpy.o y.tab.o $(LDFLAGS)
|
|
|
bb31b40 |
+milter-regex: milter-regex.o eval.o strlcat.o strlcpy.o y.tab.o
|
|
|
bb31b40 |
+ gcc -o milter-regex milter-regex.o eval.o strlcat.o strlcpy.o y.tab.o $(LDFLAGS)
|
|
|
bb31b40 |
|
|
|
bb31b40 |
milter-regex.o: milter-regex.c eval.h
|
|
|
bb31b40 |
gcc $(CFLAGS) -c milter-regex.c
|
|
|
bb31b40 |
@@ -20,6 +20,9 @@
|
|
|
bb31b40 |
eval.o: eval.c eval.h
|
|
|
bb31b40 |
gcc $(CFLAGS) -c eval.c
|
|
|
bb31b40 |
|
|
|
bb31b40 |
+strlcat.o: strlcat.c
|
|
|
bb31b40 |
+ gcc $(CFLAGS) -c strlcat.c
|
|
|
bb31b40 |
+
|
|
|
bb31b40 |
strlcpy.o: strlcpy.c
|
|
|
bb31b40 |
gcc $(CFLAGS) -c strlcpy.c
|
|
|
bb31b40 |
|
|
|
bb31b40 |
--- milter-regex.c.orig 2010-08-13 09:18:07.433332449 +0100
|
|
|
bb31b40 |
+++ milter-regex.c 2010-08-13 09:58:12.098393196 +0100
|
|
|
bb31b40 |
@@ -135,6 +135,7 @@
|
|
|
bb31b40 |
|
|
|
bb31b40 |
#if __linux__ || __sun__
|
|
|
bb31b40 |
#define ST_MTIME st_mtime
|
|
|
bb31b40 |
+extern size_t strlcat(char *, const char *, size_t);
|
|
|
bb31b40 |
extern size_t strlcpy(char *, const char *, size_t);
|
|
|
bb31b40 |
#else
|
|
|
bb31b40 |
#define ST_MTIME st_mtimespec
|