General problems revolving around perl_access

Erik Klavon erik at eriq.org
Fri Aug 30 01:07:00 UTC 2002


On Wed, Aug 28, 2002 at 10:08:01PM -0400, Jeffrey M. Vinocur wrote:
> Perhaps Erik can have a look [...]

Here is a patch. It also contains some additional changes made while
debugging to comply with the new string handling guidelines in
HACKING.

diff -ur inn/lib/conffile.c inn_fix/lib/conffile.c
--- inn/lib/conffile.c	Wed Aug 14 22:00:10 2002
+++ inn_fix/lib/conffile.c	Thu Aug 29 17:34:59 2002
@@ -16,7 +16,7 @@
       return 1;
     }
   } else if (F->array) {
-    strncpy(buffer, F->array[F->lineno], length);
+    strlcpy(buffer, F->array[F->lineno], F->sbuf);
   }
   F->lineno++;
   if (strlen (F->buf) == F->sbuf) {
diff -ur inn/nnrpd/perl.c inn_fix/nnrpd/perl.c
--- inn/nnrpd/perl.c	Sun Aug 11 15:36:11 2002
+++ inn_fix/nnrpd/perl.c	Thu Aug 29 17:16:58 2002
@@ -204,7 +204,7 @@
   HV              *attribs;
   SV              *sv;
   int             rc, i;
-  char            *p, *key, *val;
+  char            *p, *key, *val, *buffer;
 
   if (!PerlFilterActive)
     return;
@@ -245,22 +245,23 @@
 
   vector_resize(access_vec, (rc / 2));
 
+  buffer = NEW(char, BIG_BUFFER);
+
   for (i = (rc / 2); i >= 1; i--) {
     sv = POPs;
-    p = SvPV(sv, PL_na);
-    val = COPY(p);
+    val = SvPV(sv, PL_na);
     sv = POPs;
-    p = SvPV(sv, PL_na);
-    key = COPY(p);
-
-    key = strcat(key, ": \"");
-    key = strcat(key, val);
-    key = strcat(key, "\"\n");
-    vector_add(access_vec, key);
+    key = SvPV(sv, PL_na);
 
-    free(key);
-    free(val);
+    strlcpy(buffer, key, BIG_BUFFER);
+    strlcat(buffer, ": \"", BIG_BUFFER);
+    strlcat(buffer, val, BIG_BUFFER);
+    strlcat(buffer, "\"\n", BIG_BUFFER);
+ 
+    vector_add(access_vec, COPY(buffer));
   }
+
+  free(buffer);
 
   PUTBACK;
   FREETMPS;
diff -ur inn/nnrpd/perm.c inn_fix/nnrpd/perm.c
--- inn/nnrpd/perm.c	Sun Aug 11 22:34:50 2002
+++ inn_fix/nnrpd/perm.c	Thu Aug 29 16:31:51 2002
@@ -1511,7 +1513,6 @@
         free(perl_path);
 
         uname = COPY(PERMuser);
-        DISPOSE(args);        
         
         access_vec = vector_new();
 


-- 
erik         | "It is idle to think that, by means of words, | Maurice
  kl at von     | any real communication can ever pass | Maeterlinck
    eriq.org | from one [human] to another." | Silence





More information about the inn-workers mailing list