Package: minicom
Version: 2.2-5
Severity: important
Tags: patch, upstream

Hello,

When I ask to upload a file a dialog listing the files is displayed.
Some files are missing from the listing.

I found the bug. minicom assumes that '.' and '..' files are the first
and second answers from readdir(). This is not correct for every
filesystem but generaly is. I guess ext3 has some optimisations and then
reorder the entries.

With the simple test program bellow:
  #include <stdio.h>
  #include <sys/types.h>
  #include <dirent.h>
  
  int main(int argc, char *argv[])
  {
      DIR *d;
      struct dirent *s;
  
      d = opendir(argv[1]);
      if (NULL == d)
          return 0;
  
      while ((s = readdir(d)) != NULL)
          printf("%s\n", s->d_name);
  
      closedir(d);
  }


I have:
  ccidusbout7.hex
  usbsnoop.log
  ccidusbout-20070313.hex
  ccidusblnux-20070307.hex
  ccidusbout4.hex
  ccidusbout5.hex
  USBDrivers.zip
  .
  Demo4.zip
  ccidusbout-20070314.hex
  floppy
  programmer.sh
  ..
  ccidusbout-20070316.hex
  ccidusbout6.hex
  usbsnoop.txt


Note that the first entry is ccidusbout7.hex and this is exactly the
file I want to select but I can't see it from minicom selection dialog.


The patch is simple:
diff -ru minicom-2.2/src/getsdir.c minicom-2.2.new/src/getsdir.c
--- minicom-2.2/src/getsdir.c   2007-03-24 15:13:36.000000000 +0100
+++ minicom-2.2.new/src/getsdir.c       2007-03-24 15:09:24.000000000 +0100
@@ -151,15 +151,6 @@
   if ((dirp = opendir(dirpath)) == NULL)
     return -1;

-  /* discard current, and possibly parent, dir entries */
-  if (readdir(dirp) == NULL ||
-      (!(sortflags & GETSDIR_PARNT) && readdir(dirp) == NULL)) {
-    fprintf(stderr, _("DBUG: initial readdir() failed (errno == %d)\n"),
-            errno);
-    perror("readdir");
-    fflush(stderr);
-  }
-
   for(cnt = 1;; ++cnt) {        /* for buffer count 1 to whatever... */
     datb_sav = datb_cur;       /* save pointer to previous buffer */

@@ -180,6 +171,8 @@
     /* while the current buffer is not full, get directory entries */
     for (datb_cur->cnt = 0; datb_cur->cnt < MAX_CNT;)
       if ((dp = readdir(dirp)) != NULL) {/* get next directory entry */
+        if (strcmp(dp->d_name, ".") == 0)
+          continue;
         if ((sortflags & GETSDIR_PARNT) && strcmp(dp->d_name, "..") == 0)
           cmprstat = 1;
         else if (pattern && strlen(pattern))


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing'), (90, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-686
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)

Versions of packages minicom depends on:
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libncurses5                 5.5-5        Shared libraries for terminal hand

Versions of packages minicom recommends:
pn  lrzsz                         <none>     (no description available)

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to