dir: fileserver leaks names of file and directories
[openafs.git] / src / dir / buffer.c
index 2197b27..1a8da8f 100644 (file)
@@ -11,6 +11,7 @@
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #include <lock.h>
 
@@ -121,9 +122,9 @@ DInit(int abuffers)
     Lock_Init(&afs_bufferLock);
     /* Align each element of Buffers on a doubleword boundary */
     tsize = (sizeof(struct buffer) + 7) & ~7;
-    tp = (char *)malloc(abuffers * tsize);
-    Buffers = (struct buffer **)malloc(abuffers * sizeof(struct buffer *));
-    BufferData = (char *)malloc(abuffers * BUFFER_PAGE_SIZE);
+    tp = malloc(abuffers * tsize);
+    Buffers = malloc(abuffers * sizeof(struct buffer *));
+    BufferData = malloc(abuffers * BUFFER_PAGE_SIZE);
     timecounter = 0;
     LastBuffer = (struct buffer *)tp;
     nbuffers = abuffers;
@@ -312,6 +313,7 @@ newslot(dir_file_t dir, afs_int32 apage, struct buffer *lp)
     /* Now fill in the header. */
     FidZap(bufferDir(lp));
     FidCpy(bufferDir(lp), dir);        /* set this */
+    memset(lp->data, 0, BUFFER_PAGE_SIZE);  /* Don't leak stale data. */
     lp->page = apage;
     lp->accesstime = ++timecounter;