Hi list,

After testing on amd64 and i386 I found a segmentation fault in
the_silver_searcher and wrote a patch for it: With the patch I did not
have any segmentation faults or problems with the port so far on the
architectures amd64 and i386.

I will of course send the patch upstream, but I'd like to know if you
have anything to say about the patch.

Regards,
Florian

Attachment: the_silver_searcher.tar.gz
Description: application/tar-gz

--- src/scandir.c
+++ src/scandir.c
@@ -44,12 +44,16 @@ int ag_scandir(const char *dirname,
         */
         d = malloc(sizeof(struct dirent) + strlen(entry->d_name) + 1);
 #else
-        d = malloc(sizeof(struct dirent));
+        d = malloc(entry->d_reclen);
 #endif
         if (d == NULL) {
             goto fail;
         }
-        memcpy(d, entry, sizeof(struct dirent));
+        /* Use d_reclen instead of calculating the size with sizeof. This
+         * avoids reading beyound the internal buffer of dirp on some
+         * implementations like OpenBSD's.
+         */
+        memcpy(d, entry, entry->d_reclen);
 #if defined (__SVR4) && defined (__sun)
         strcpy(d->d_name, entry->d_name);
 #endif

Attachment: pgpniaODway2z.pgp
Description: PGP signature

Reply via email to