]> granicus.if.org Git - php/commitdiff
fix potential buffer overrun
authorStanislav Malyshev <stas@php.net>
Sun, 7 Dec 2003 12:57:26 +0000 (12:57 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 7 Dec 2003 12:57:26 +0000 (12:57 +0000)
sapi/cgi/libfcgi/os_unix.c

index de4da1014d2ac71d21c3d9807ed114ed88368890..217df79a9efe3d1db38cb04ce53234245c409a7e 100644 (file)
@@ -103,6 +103,11 @@ static int volatile maxFd = -1;
 static int shutdownPending = FALSE;
 static int shutdownNow = FALSE;
 
+#ifndef HAVE_STRLCPY
+#define strlcpy php_strlcpy
+#endif
+size_t strlcpy(char *dst, const char *src, size_t siz);
+
 void OS_ShutdownPending()
 {
     shutdownPending = TRUE;
@@ -293,7 +298,7 @@ int OS_CreateLocalIpcFd(const char *bindPath, int backlog)
     short   port = 0;
     char    host[MAXPATHLEN];
 
-    strcpy(host, bindPath);
+    strlcpy(host, bindPath, MAXPATHLEN-1);
     if((tp = strchr(host, ':')) != 0) {
        *tp++ = 0;
        if((port = atoi(tp)) == 0) {
@@ -396,7 +401,7 @@ int OS_FcgiConnect(char *bindPath)
     short   port = 0;
     int            tcp = FALSE;
 
-    strcpy(host, bindPath);
+    strlcpy(host, bindPath, MAXPATHLEN-1);
     if((tp = strchr(host, ':')) != 0) {
        *tp++ = 0;
        if((port = atoi(tp)) == 0) {