summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure13
-rw-r--r--include/inspstring.h11
-rw-r--r--src/Makefile2
-rw-r--r--src/channels.cpp1
-rw-r--r--src/commands.cpp1
-rw-r--r--src/connection.cpp1
-rw-r--r--src/dynamic.cpp3
-rw-r--r--src/inspircd.cpp1
-rw-r--r--src/inspircd_io.cpp1
-rw-r--r--src/inspircd_util.cpp1
-rw-r--r--src/inspstring.cpp89
-rw-r--r--src/message.cpp1
-rw-r--r--src/mode.cpp1
-rw-r--r--src/modules.cpp1
-rw-r--r--src/servers.cpp1
-rw-r--r--src/users.cpp1
-rw-r--r--src/wildcard.cpp1
-rw-r--r--src/xline.cpp1
18 files changed, 126 insertions, 5 deletions
diff --git a/configure b/configure
index 6f54c5386..ecc48d7dc 100755
--- a/configure
+++ b/configure
@@ -100,6 +100,12 @@ exists () { # because some shells don't have test -e
fi
}
+echo "#include <string.h>">.test.cpp
+echo >"int main() { char a[10]; char b[10]; strlcpy(a,b,10); sprintf("999"); }" >>.test.cpp
+gcc -o .test .test.cpp
+$HAS_STRLCPY=`./.test`
+rm -f .test.cpp .test
+
clear
echo -e "'\033[1;33m####\033[0;37m:'\033[1;33m##\033[0;37m::: \033[1;33m##\033[0;37m::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::'\033[1;33m####\033[0;37m:'\033[1;33m########\033[0;37m:::'\033[1;33m######\033[0;37m::'\033[1;33m########\033[0;37m::"
echo -e ". \033[1;33m##\033[0;37m:: \033[1;33m###\033[0;37m:: \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:. \033[1;33m##\033[0;37m:: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:'\033[1;33m##\033[0;37m... \033[1;33m##\033[0;37m: \033[1;33m##\033[0;37m.... \033[1;33m##\033[0;37m:"
@@ -399,7 +405,7 @@ echo -e "\033[0;37mGCC Version Found:\033[1;32m\t\t$GCCVER.$GCC34"
echo -e "\033[0;37mOptimatizaton Flag:\033[1;32m\t\t$OPTIMISATI"
echo -e "\033[0;37m"
-echo "Writing cache file for future ./configures ..."
+yyecho "Writing cache file for future ./configures ..."
if [ "$CONFIG_DIR" != "$ME/conf" ] ; then
COPY_CONF=1
@@ -419,6 +425,7 @@ echo "MAXI_MODES=\"$MAXI_MODES\"" >> .config.cache
echo "OPTIMITEMP=\"$OPTIMITEMP\"" >> .config.cache
echo "OPTIMISATI=\"$OPTIMISATI\"" >> .config.cache
echo "GCC34=\"$GCC34\"" >> .config.cache
+echo "HAS_STRLCPY=\"$HAS_STRLCPY\"" >> .config.cache
echo "COPY_CONF=\"$COPY_CONF\"" >> .config.cache
echo "Writing include/inspircd_config.h ..."
@@ -431,6 +438,9 @@ echo "#define GCC3" >>include/inspircd_config.h
echo "#define GCC34" >>include/inspircd_config.h
fi
fi
+if [ "$HAS_STRLCPY" -eq "999" ] ; then
+ echo "#define HAS_STRLCPY" >>include/inspircd_config.h
+fi
echo "#define SYSLOG_FACILITY LOG_DAEMON" >>include/inspircd_config.h
echo "#define SYSLOG_LEVEL LOG_NOTICE" >>include/inspircd_config.h
echo "#define CONFIG_FILE \"$CONFIG_DIR/inspircd.conf\"" >>include/inspircd_config.h
@@ -508,4 +518,3 @@ fi
echo -e "*** \033[1;32mRemember to edit your configuration files!!!\033[0;37m ***"
echo ""
-
diff --git a/include/inspstring.h b/include/inspstring.h
new file mode 100644
index 000000000..f13f098dd
--- /dev/null
+++ b/include/inspstring.h
@@ -0,0 +1,11 @@
+#ifndef __IN_INSPSTRING_H
+#define __IN_INSPSTRING_H
+
+#include "inspircd_config.h"
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dst, const char *src, size_t siz);
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#endif
diff --git a/src/Makefile b/src/Makefile
index 03c795c62..47b7c99bf 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@
CC = im a cheezeball
SRC_1 = base.cpp inspircd.cpp inspircd_util.cpp inspircd_io.cpp connection.cpp message.cpp commands.cpp
-SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp channels.cpp mode.cpp xline.cpp
+SRC_2 = dynamic.cpp users.cpp modules.cpp wildcard.cpp servers.cpp channels.cpp mode.cpp xline.cpp inspstring.cpp
SRC = $(SRC_1) $(SRC_2)
OBJS = $(SRC:.cpp=.o)
diff --git a/src/channels.cpp b/src/channels.cpp
index 7cc6506f8..379339c47 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -50,6 +50,7 @@
#include "message.h"
#include "mode.h"
#include "xline.h"
+#include "inspstring.h"
#ifdef GCC3
#define nspace __gnu_cxx
diff --git a/src/commands.cpp b/src/commands.cpp
index 0173f9113..dbb7a43a4 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -50,6 +50,7 @@
#include "message.h"
#include "mode.h"
#include "xline.h"
+#include "inspstring.h"
#ifdef GCC3
#define nspace __gnu_cxx
diff --git a/src/connection.cpp b/src/connection.cpp
index d60da90ac..475e9ade5 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -25,6 +25,7 @@
#include <deque>
#include "inspircd.h"
#include "modules.h"
+#include "inspstring.h"
using namespace std;
diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index c97420820..9cc68fc5f 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -17,8 +17,7 @@
#include "globals.h"
#include <dlfcn.h>
#include "dynamic.h"
-
-
+#include "inspstring.h"
DLLManager::DLLManager(const char *fname)
{
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ecfbd6b0f..c39389f88 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -55,6 +55,7 @@ using namespace std;
#include "mode.h"
#include "commands.h"
#include "xline.h"
+#include "inspstring.h"
#ifdef GCC3
#define nspace __gnu_cxx
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index 2e9a350f1..d412cee93 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -25,6 +25,7 @@
#include "inspircd.h"
#include "inspircd_io.h"
#include "inspircd_util.h"
+#include "inspstring.h"
using namespace std;
diff --git a/src/inspircd_util.cpp b/src/inspircd_util.cpp
index a0a7e9f0f..fd1cc5249 100644
--- a/src/inspircd_util.cpp
+++ b/src/inspircd_util.cpp
@@ -17,6 +17,7 @@
#include "inspircd.h"
#include "inspircd_io.h"
#include "inspircd_util.h"
+#include "inspstring.h"
char *SafeStrncpy (char *dest, const char *src, size_t size)
{
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
new file mode 100644
index 000000000..7b9624fcf
--- /dev/null
+++ b/src/inspstring.cpp
@@ -0,0 +1,89 @@
+#include "inspircd_config.h"
+#include "inspstring.h"
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HAVE_STRLCPY
+size_t strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz, dlen;
+
+ while (n-- != 0 && *d != '\0')
+ d++;
+
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+
+ while (*s != '\0')
+ {
+ if (n != 1)
+ {
+ *d++ = *s;
+ n--;
+ }
+
+ s++;
+ }
+
+ *d = '\0';
+ return(dlen + (s - src)); /* count does not include NUL */
+}
+
+size_t strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0)
+ {
+ do
+ {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0)
+ {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+#endif
diff --git a/src/message.cpp b/src/message.cpp
index bb27ceff4..6c09096d2 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -48,6 +48,7 @@
#include "dynamic.h"
#include "wildcard.h"
#include "message.h"
+#include "inspstring.h"
using namespace std;
diff --git a/src/mode.cpp b/src/mode.cpp
index d2a119895..eaee04f75 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -50,6 +50,7 @@
#include "message.h"
#include "commands.h"
#include "xline.h"
+#include "inspstring.h"
using namespace std;
diff --git a/src/modules.cpp b/src/modules.cpp
index 7f3603fb7..ac47544c0 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -51,6 +51,7 @@
#include "mode.h"
#include "xline.h"
#include "commands.h"
+#include "inspstring.h"
#ifdef GCC3
#define nspace __gnu_cxx
diff --git a/src/servers.cpp b/src/servers.cpp
index 5bf694183..1ea20a5c2 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -19,6 +19,7 @@
#include "inspircd.h"
#include <stdio.h>
#include <map>
+#include "inspstring.h"
serverrec::serverrec()
{
diff --git a/src/users.cpp b/src/users.cpp
index b940bd6af..46dfb35d7 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -19,6 +19,7 @@
#include "users.h"
#include "inspircd.h"
#include <stdio.h>
+#include "inspstring.h"
extern std::stringstream config_f;
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index ce4d7d314..8b4190539 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -17,6 +17,7 @@
#include <string>
#include "inspircd_config.h"
#include "inspircd.h"
+#include "inspstring.h"
void Delete(char* str,int pos)
{
diff --git a/src/xline.cpp b/src/xline.cpp
index 5559390e7..15032b32a 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -50,6 +50,7 @@
#include "message.h"
#include "commands.h"
#include "xline.h"
+#include "inspstring.h"
#ifdef GCC3
#define nspace __gnu_cxx