httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] make mod_include use ap_cpystrn
Date Thu, 08 Jan 1998 02:29:11 GMT
The safe_copy() routine was put in there to ease the 1.2 version during
the security patch.  Ditch it in favour of the fancy new ap_cpystrn(). 

Dean

Index: modules/standard/mod_include.c
===================================================================
RCS file: /export/home/cvs/apachen/src/modules/standard/mod_include.c,v
retrieving revision 1.61
diff -u -r1.61 mod_include.c
--- mod_include.c	1998/01/07 22:24:11	1.61
+++ mod_include.c	1998/01/08 02:25:19
@@ -97,12 +97,6 @@
 #define SIZEFMT_KMG 1
 
 
-static ap_inline void safe_copy(char *dest, const char *src, size_t max_len)
-{
-    strncpy(dest, src, max_len - 1);
-    dest[max_len - 1] = '\0';
-}
-
 /* ------------------------ Environment function -------------------------- */
 
 static void add_include_vars(request_rec *r, char *timefmt)
@@ -366,7 +360,7 @@
                 GET_CHAR(in, c, NULL, p);
             } while (isspace(c));
             if (c == '>') {
-                safe_copy(tag, "done", tagbuf_len);
+                ap_cpystrn(tag, "done", tagbuf_len);
                 return tag;
             }
         }
@@ -1574,7 +1568,7 @@
             rputs("     Evaluate string\n", r);
 #endif
             parse_string(r, current->token.value, buffer, sizeof(buffer), 0);
-	    safe_copy(current->token.value, buffer, sizeof(current->token.value));
+	    ap_cpystrn(current->token.value, buffer, sizeof(current->token.value));
             current->value = (current->token.value[0] != '\0');
             current->done = 1;
             current = current->parent;
@@ -1598,7 +1592,7 @@
                 case token_string:
                     parse_string(r, current->left->token.value,
                                  buffer, sizeof(buffer), 0);
-                    safe_copy(current->left->token.value, buffer,
+                    ap_cpystrn(current->left->token.value, buffer,
                             sizeof(current->left->token.value));
 		    current->left->value = (current->left->token.value[0] != '\0');
                     current->left->done = 1;
@@ -1613,7 +1607,7 @@
                 case token_string:
                     parse_string(r, current->right->token.value,
                                  buffer, sizeof(buffer), 0);
-                    safe_copy(current->right->token.value, buffer,
+                    ap_cpystrn(current->right->token.value, buffer,
                             sizeof(current->right->token.value));
 		    current->right->value = (current->right->token.value[0] != '\0');
                     current->right->done = 1;
@@ -1660,11 +1654,11 @@
             }
             parse_string(r, current->left->token.value,
                          buffer, sizeof(buffer), 0);
-            safe_copy(current->left->token.value, buffer,
+            ap_cpystrn(current->left->token.value, buffer,
 			sizeof(current->left->token.value));
             parse_string(r, current->right->token.value,
                          buffer, sizeof(buffer), 0);
-            safe_copy(current->right->token.value, buffer,
+            ap_cpystrn(current->right->token.value, buffer,
 			sizeof(current->right->token.value));
             if (current->right->token.value[0] == '/') {
                 int len;
@@ -1725,11 +1719,11 @@
             }
             parse_string(r, current->left->token.value,
                          buffer, sizeof(buffer), 0);
-            safe_copy(current->left->token.value, buffer,
+            ap_cpystrn(current->left->token.value, buffer,
 			sizeof(current->left->token.value));
             parse_string(r, current->right->token.value,
                          buffer, sizeof(buffer), 0);
-            safe_copy(current->right->token.value, buffer,
+            ap_cpystrn(current->right->token.value, buffer,
 			sizeof(current->right->token.value));
 #ifdef DEBUG_INCLUDE
             rvputs(r, "     Compare (", current->left->token.value,
@@ -2056,8 +2050,8 @@
     int printing;
     int conditional_status;
 
-    safe_copy(error, DEFAULT_ERROR_MSG, sizeof(error));
-    safe_copy(timefmt, DEFAULT_TIME_FORMAT, sizeof(timefmt));
+    ap_cpystrn(error, DEFAULT_ERROR_MSG, sizeof(error));
+    ap_cpystrn(timefmt, DEFAULT_TIME_FORMAT, sizeof(timefmt));
     sizefmt = SIZEFMT_KMG;
 
 /*  Turn printing on */



Mime
View raw message