Re: ftpget sig11+core (1.1.16+retry)

From: Philippe Michel <Philippe.Michel@dont-contact.us>
Date: Mon, 29 Sep 1997 10:18:52 +0200

Roberto A. Lumbreras Pastor wrote:
>
> Hi all.
>
> Ftpget seems to dump core for me sometimes. It's version
> 1.1.16+retry patches, Linux 2.0.x system.
>
> gdb output...
>
> 1st core:
> Core was generated by `/usr/lib/squid/bin/ftpget -t 900 -n 300 -P 21 -H central.lander.es -h - ftp.red'.
> Program terminated with signal 11, Segmentation fault.
> find_solib: Can't read pathname for load map: Input/output error
>
> #0 0x804a6c2 in mime_get_type (r=0x807a048) at ftpget.c:925
> 925 if (!strcmp(enc, "x-gzip"))

ftpget 1.1.16 crashes this way for all "unknown" filenames suffixes
(like .red). They cause enc to be NULL in the strcmp().

The attached patch seems to work to fix this.

*** include/mime_table.h.orig Fri Aug 8 22:25:55 1997
--- include/mime_table.h Fri Sep 19 15:22:56 1997
***************
*** 1,6 ****
! #define EXT_TABLE_LEN 96
  static ext_table_entry ext_mime_table[] =
  {
      {"Z", "application/x-compressed", "x-compress", "binary"},
      {"ai", "application/postscript", "8bit", "text"},
      {"aif", "audio/x-aiff", "binary", "sound"},
--- 1,7 ----
! #define EXT_TABLE_LEN 97
  static ext_table_entry ext_mime_table[] =
  {
+ {"", "application/octet-stream", "binary", "binary"}, /* default */
      {"Z", "application/x-compressed", "x-compress", "binary"},
      {"ai", "application/postscript", "8bit", "text"},
      {"aif", "audio/x-aiff", "binary", "sound"},
***************
*** 24,30 ****
      {"f90", "text/plain", "7bit", "text"},
      {"gif", "image/gif", "binary", "image"},
      {"gtar", "application/x-gtar", "binary", "binary"},
! {"gz", "text/plain", "x-gzip", "binary"},
      {"h", "text/plain", "7bit", "text"},
      {"hdf", "application/x-hdf", "binary", "binary"},
      {"hh", "text/plain", "7bit", "text"},
--- 25,31 ----
      {"f90", "text/plain", "7bit", "text"},
      {"gif", "image/gif", "binary", "image"},
      {"gtar", "application/x-gtar", "binary", "binary"},
! {"gz", "application/x-gzip", "x-gzip", "binary"},
      {"h", "text/plain", "7bit", "text"},
      {"hdf", "application/x-hdf", "binary", "binary"},
      {"hh", "text/plain", "7bit", "text"},
*** src/mime.c.orig Wed Jul 9 21:35:42 1997
--- src/mime.c Fri Sep 19 15:25:21 1997
***************
*** 188,194 ****
      for (cp = ext; *cp; cp++)
          if (isupper(*cp))
              *cp = tolower(*cp);
! low = 0;
      high = EXT_TABLE_LEN - 1;
      while (low <= high) {
          i = (low + high) / 2;
--- 188,194 ----
      for (cp = ext; *cp; cp++)
          if (isupper(*cp))
              *cp = tolower(*cp);
! low = 1; /* 0 is used for default mime type in ftpget.c */
      high = EXT_TABLE_LEN - 1;
      while (low <= high) {
          i = (low + high) / 2;
*** src/ftpget.c.orig Thu Aug 21 01:28:33 1997
--- src/ftpget.c Fri Sep 19 15:30:40 1997
***************
*** 884,891 ****
      char *filename = NULL;
      char *ext = NULL;
      char *t = NULL;
! const char *type = NULL;
! const char *enc = NULL;
      int i;
  
      if (r->flags & F_ISDIR) {
--- 884,891 ----
      char *filename = NULL;
      char *ext = NULL;
      char *t = NULL;
! const char *type = ext_mime_table[0].mime_type;
! const char *enc = ext_mime_table[0].mime_encoding;
      int i;
  
      if (r->flags & F_ISDIR) {
***************
*** 903,909 ****
          goto mime_get_type_done;
      ext = xstrdup(t + 1);
      /* CASE SENSITIVE FIRST */
! for (i = 0; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              type = ext_mime_table[i].mime_type;
              enc = ext_mime_table[i].mime_encoding;
--- 903,909 ----
          goto mime_get_type_done;
      ext = xstrdup(t + 1);
      /* CASE SENSITIVE FIRST */
! for (i = 1; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              type = ext_mime_table[i].mime_type;
              enc = ext_mime_table[i].mime_encoding;
***************
*** 912,918 ****
      }
      /* CASE INSENSITIVE NEXT */
      if (i == EXT_TABLE_LEN) {
! for (i = 0; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  type = ext_mime_table[i].mime_type;
                  enc = ext_mime_table[i].mime_encoding;
--- 912,918 ----
      }
      /* CASE INSENSITIVE NEXT */
      if (i == EXT_TABLE_LEN) {
! for (i = 1; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  type = ext_mime_table[i].mime_type;
                  enc = ext_mime_table[i].mime_encoding;
***************
*** 930,936 ****
          goto mime_get_type_done;
      xfree(ext);
      ext = xstrdup(t + 1);
! for (i = 0; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              type = ext_mime_table[i].mime_type;
              break;
--- 930,936 ----
          goto mime_get_type_done;
      xfree(ext);
      ext = xstrdup(t + 1);
! for (i = 1; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              type = ext_mime_table[i].mime_type;
              break;
***************
*** 937,943 ****
          }
      }
      if (i == EXT_TABLE_LEN) {
! for (i = 0; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  type = ext_mime_table[i].mime_type;
                  break;
--- 937,943 ----
          }
      }
      if (i == EXT_TABLE_LEN) {
! for (i = 1; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  type = ext_mime_table[i].mime_type;
                  break;
***************
*** 965,971 ****
          return xstrdup("unknown");
      ext = xstrdup(t + 1);
      debug(38, 3, "mime_get_icon: ext = '%s'\n", ext);
! for (i = 0; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              debug(38, 3, "mime_get_icon: matched entry #%d\n", i);
              debug(38, 3, "mime_get_icon: returning '%s'\n",
--- 965,971 ----
          return xstrdup("unknown");
      ext = xstrdup(t + 1);
      debug(38, 3, "mime_get_icon: ext = '%s'\n", ext);
! for (i = 1; i < EXT_TABLE_LEN; i++) {
          if (!strcmp(ext, ext_mime_table[i].name)) {
              debug(38, 3, "mime_get_icon: matched entry #%d\n", i);
              debug(38, 3, "mime_get_icon: returning '%s'\n",
***************
*** 976,982 ****
          }
      }
      if (i == EXT_TABLE_LEN) {
! for (i = 0; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  debug(38, 3, "mime_get_icon: matched entry #%d\n", i);
                  debug(38, 3, "mime_get_icon: returning '%s'\n",
--- 976,982 ----
          }
      }
      if (i == EXT_TABLE_LEN) {
! for (i = 1; i < EXT_TABLE_LEN; i++) {
              if (!strcasecmp(ext, ext_mime_table[i].name)) {
                  debug(38, 3, "mime_get_icon: matched entry #%d\n", i);
                  debug(38, 3, "mime_get_icon: returning '%s'\n",
Received on Mon Sep 29 1997 - 01:39:07 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:37:12 MST