From 37c9bf3f7515c22f6d9e6e553de834f60185cac9 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 15 Dec 2006 22:34:56 +0100 Subject: [PATCH 1/7] Test response from server mentioned in debian bug 403139 The problem is in the FTP directory listing and number parser which stores it intermediate results in a variable of type long. --- src/protocol/ftp/test-ftp-parser | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/protocol/ftp/test-ftp-parser b/src/protocol/ftp/test-ftp-parser index 860056dd..0af924ed 100644 --- a/src/protocol/ftp/test-ftp-parser +++ b/src/protocol/ftp/test-ftp-parser @@ -73,6 +73,11 @@ test_ftp_response_expect_success \ -------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit\r\n drwxrwxr-x folder 2 May 10 1996 network\r\n" +test_ftp_response_expect_success \ +'Response from server mentioned in debian bug 403139' \ +" +-rw-r--r-- 1 root root 1126400 Jul 28 2003 client.tar\r\n +-rw-r--r-- 1 root root 3146776576 Dec 15 19:08 dontlook\r\n" ############################################################################# # From f7be8f7dfcbe4b24efa6876c67fcae5c649dc3b9 Mon Sep 17 00:00:00 2001 From: "M. Levinson" Date: Fri, 8 Dec 2006 23:29:00 +0100 Subject: [PATCH 2/7] Python: Don't complain if hooks.py does not exist. Nor if -no-home prevents it from being found. This patch is from bug 880, comment 5, attachment 305. http://bugzilla.elinks.cz/show_bug.cgi?id=880#c5 --- src/scripting/python/core.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/scripting/python/core.c b/src/scripting/python/core.c index 33bb5c82..44591225 100644 --- a/src/scripting/python/core.c +++ b/src/scripting/python/core.c @@ -121,6 +121,41 @@ end: return result; } +/* Determine whether or not a user-supplied hooks module exists. */ + +static int +hooks_module_exists(void) +{ + PyObject *imp_module = NULL, *result = NULL; + int found_hooks = 0; + + /* + * Use the find_module() function in Python's imp module to look for + * the hooks module in Python's search path. An ImportError exception + * indicates that no such module was found; any other exception will + * be reported as an error. + */ + imp_module = PyImport_ImportModule("imp"); + if (!imp_module) goto python_error; + + result = PyObject_CallMethod(imp_module, "find_module", "s", "hooks"); + if (result) { + found_hooks = 1; + goto end; + } else if (PyErr_ExceptionMatches(PyExc_ImportError)) { + PyErr_Clear(); + goto end; + } + +python_error: + alert_python_error(); + +end: + Py_XDECREF(imp_module); + Py_XDECREF(result); + return found_hooks; +} + /* Module-level documentation for the Python interpreter's elinks module. */ static char module_doc[] = @@ -169,6 +204,8 @@ init_python(struct module *module) Py_Initialize(); + if (!hooks_module_exists()) return; + elinks_module = Py_InitModule3("elinks", NULL, module_doc); if (!elinks_module) goto python_error; From 7c161bbbf28bd90270c993ea5390494ba7015131 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 17 Dec 2006 16:21:36 +0200 Subject: [PATCH 3/7] Prettify installation of manual pages. Before: [INSTALL] doc/man/man5//home/Kalle/src/elinks/doc/man/man5/elinks.conf.5 -> /home/Kalle/prefix/stow/elinks/share/man/man5 [INSTALL] doc/man/man5//home/Kalle/src/elinks/doc/man/man5/elinkskeys.5 -> /home/Kalle/prefix/stow/elinks/share/man/man5 After: [INSTALL] doc/man/man5/elinks.conf.5 -> /home/Kalle/prefix/stow/elinks/share/man/man5 [INSTALL] doc/man/man5/elinkskeys.5 -> /home/Kalle/prefix/stow/elinks/share/man/man5 --- Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.lib b/Makefile.lib index a81699c5..cbf6d2f3 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -60,7 +60,7 @@ quiet_cmd_ld_objs = " [$(LD_COLOR)LD$(END_COLOR)] $(RELPATH)$@" quiet_cmd_recmake = "[$(INFO_COLOR)MAKE $(3)$(END_COLOR)] $(RELPATH)$(2)" cmd_recmake = $(MAKE) -C $(2) $(3) -quiet_cmd_installdata = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(2) -> $(3)" +quiet_cmd_installdata = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(patsubst $(srcdir)%,%,$(2)) -> $(3)" cmd_installdata = $(INSTALL_DATA) $(2) $(3) # Install a data file from the source (not build) directory From 5331789603d50304330656024538d6ec36b4fb49 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 17 Dec 2006 16:25:12 +0200 Subject: [PATCH 4/7] Remove cmd_installsrcdata. cmd_installdata with $(srcdir) now does the same thing. --- Makefile.lib | 4 ---- doc/Makefile | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile.lib b/Makefile.lib index cbf6d2f3..77089c01 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -63,10 +63,6 @@ quiet_cmd_recmake = "[$(INFO_COLOR)MAKE $(3)$(END_COLOR)] $(RELPATH)$(2)" quiet_cmd_installdata = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(patsubst $(srcdir)%,%,$(2)) -> $(3)" cmd_installdata = $(INSTALL_DATA) $(2) $(3) -# Install a data file from the source (not build) directory -quiet_cmd_installsrcdata = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(2) -> $(3)" - cmd_installsrcdata = $(INSTALL_DATA) $(srcdir)$(2) $(3) - quiet_cmd_installprog = " [$(INSTALL_COLOR)INSTALL$(END_COLOR)] $(RELPATH)$(2) -> $(3)" cmd_installprog = $(INSTALL_PROGRAM) $(2) $(3) diff --git a/doc/Makefile b/doc/Makefile index ea42b7f9..2053e9a4 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -88,7 +88,7 @@ install-doc: all-docs update-man install $(call ncmd,installdata,$(doc),$(PDF_DIR));) @$(foreach doc,$(TXT_DOCS_ASIS), \ $(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(PACKAGE)/txt; \ - $(call ncmd,installsrcdata,$(doc),$(TXT_DIR));) + $(call ncmd,installdata,$(srcdir)$(doc),$(TXT_DIR));) update-man: man @$(if $(MAN_DOCS), \ From 47a8be1b4dab36671f68ce674842244330d90602 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 17 Dec 2006 16:54:50 +0200 Subject: [PATCH 5/7] doc/perl.pod: Tweak the NAME section for pod2html. This change avoids getting No Title in perl.html. --- doc/perl.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/perl.pod b/doc/perl.pod index bdb5de6c..2859d13e 100644 --- a/doc/perl.pod +++ b/doc/perl.pod @@ -1,6 +1,6 @@ =head1 NAME -ELinks Perl Interface +elinks-perl - ELinks Perl Interface =head1 INTRODUCTION From a1fe5cf97560fa29bfc44a796bd03ee148f9d942 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 10 Dec 2006 03:07:00 +0200 Subject: [PATCH 6/7] Bug 826, UTF-8 set_hline: Don't skip the character after double-cell. I do not fully understand this code, but I am sure skipping characters like this is a bug, and correcting it seems to fix bug 826 (too small table for double-cell characters). I don't see any similar bugs in other parts of set_hline. The patch is from bug 826, comment 4, attachment 308. The warning there about unicode_to_cell(UCS_NO_CHAR) still applies but this patch does not make the situation worse. I have logged a separate bug 901 about those calls. --- src/document/html/renderer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index b80e2d63..0108f8ba 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -507,7 +507,6 @@ good_char: x++; part->spaces[x] = 0; part->char_width[x] = 0; - data = utf8_to_unicode(&chars, end); } if (data == UCS_NO_CHAR) { /* this is at the end only */ From 7589d4457abbc61a0913f9ef6a143ebcd1ec90ba Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 18 Dec 2006 18:50:47 +0100 Subject: [PATCH 7/7] Bug 899: Fix size handling in FTP directory listings This fixes parse_ftp_number to use off_t instead of long to store its (intermediate) result and return type. It also introduces an OFFT_MAX type "limit" that is used for validating the size of the parsed number. A test-case for was added in 37c9bf3f7515c22f6d9e6e553de834f60185cac9 to test-ftp-parser and the patch has been confirmed to fix the test-case by adamg and me. This closes bug 899, which is a duplicate of debian bug 403139. --- src/osdep/types.h | 22 ++++++++++++++++++++++ src/protocol/ftp/ftp.c | 2 +- src/protocol/ftp/parse.c | 14 +++++++------- src/protocol/ftp/parse.h | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/osdep/types.h b/src/osdep/types.h index 9d0f2820..2404ac01 100644 --- a/src/osdep/types.h +++ b/src/osdep/types.h @@ -53,6 +53,28 @@ #endif #endif +#if defined(HAVE_LONG_LONG) && !defined(LLONG_MAX) +#ifdef MAXLLONG +#define LLONG_MAX MAXLLONG +#elif SIZEOF_LONG_LONG == 8 +#define LLONG_MAX 9223372036854775807LL +#elif SIZEOF_LONG_LONG == 4 +#define LLONG_MAX LONG_MAX +#endif +#endif + +#ifndef OFFT_MAX +#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T == SIZEOF_LONG_LONG +#define OFFT_MAX LLONG_MAX +#elif SIZEOF_OFF_T == SIZEOF_LONG +#define OFFT_MAX LONG_MAX +#elif SIZEOF_OFF_T == SIZEOF_INT +#define OFFT_MAX INT_MAX +#elif SIZEOF_OFF_T == SIZEOF_SHORT +#define OFFT_MAX SHRT_MAX +#endif +#endif + #ifndef HAVE_UINT16_T #if SIZEOF_CHAR == 2 typedef unsigned char uint16_t; diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c index 87ec4445..01e301bc 100644 --- a/src/protocol/ftp/ftp.c +++ b/src/protocol/ftp/ftp.c @@ -1091,7 +1091,7 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries, add_to_string(&string, " 1 ftp ftp "); if (ftp_info->size != FTP_SIZE_UNKNOWN) { - add_format_to_string(&string, "%12lu ", ftp_info->size); + add_format_to_string(&string, "%12" OFF_T_FORMAT " ", ftp_info->size); } else { add_to_string(&string, " - "); } diff --git a/src/protocol/ftp/parse.c b/src/protocol/ftp/parse.c index b5caeba7..be4326e7 100644 --- a/src/protocol/ftp/parse.c +++ b/src/protocol/ftp/parse.c @@ -41,10 +41,10 @@ #define skip_nonspace_end(src, end) \ do { while ((src) < (end) && *(src) != ' ') (src)++; } while (0) -static long -parse_ftp_number(unsigned char **src, unsigned char *end, long from, long to) +static off_t +parse_ftp_number(unsigned char **src, unsigned char *end, off_t from, off_t to) { - long number = 0; + off_t number = 0; unsigned char *pos = *src; for (; pos < end && isdigit(*pos); pos++) @@ -104,7 +104,7 @@ parse_ftp_eplf_response(struct ftp_file_info *info, unsigned char *src, int len) case FTP_EPLF_SIZE: if (src >= pos) break; - info->size = parse_ftp_number(&src, pos, 0, LONG_MAX); + info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX); break; case FTP_EPLF_MTIME: @@ -278,7 +278,7 @@ parse_ftp_unix_response(struct ftp_file_info *info, unsigned char *src, int len) break; } - info->size = parse_ftp_number(&src, pos, 0, LONG_MAX); + info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX); break; case FTP_UNIX_DAY: @@ -543,7 +543,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len memset(&mtime, 0, sizeof(mtime)); mtime.tm_isdst = -1; - mtime.tm_mon = parse_ftp_number(&src, end, 1, 12); + mtime.tm_mon = (int) parse_ftp_number(&src, end, 1, 12); if (src + 2 >= end || *src != '-') return NULL; @@ -587,7 +587,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len } else if (isdigit(*src)) { info->type = FTP_FILE_PLAINFILE; - info->size = parse_ftp_number(&src, end, 0, LONG_MAX); + info->size = parse_ftp_number(&src, end, 0, OFFT_MAX); info->permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; } else { diff --git a/src/protocol/ftp/parse.h b/src/protocol/ftp/parse.h index e7773987..18cfacd8 100644 --- a/src/protocol/ftp/parse.h +++ b/src/protocol/ftp/parse.h @@ -19,7 +19,7 @@ struct ftp_file_info { enum ftp_file_type type; /* File type */ struct string name; /* File name */ struct string symlink; /* Link to which file points */ - long size; /* File size. -1 if unknown. */ + off_t size; /* File size. -1 if unknown. */ time_t mtime; /* Modification time */ unsigned int local_time_zone:1; /* What format the mtime is in */ mode_t permissions; /* File permissions */