On 12/07/11 16:20, Gregory Edigarov wrote:
> Hello.
>
> this patch corrects segfaults in mail/libetpan port.
> found while trying to debug claws-mail coredumps.
>
> ============================================================
> diff -ur libetpan-1.0-orig/build-windows/libetpan_version.h
> libetpan-1.0/build-windows/libetpan_version.h ---
> libetpan-1.0-orig/build-windows/libetpan_version.h Sun Sep 6
> 03:34:44 2009 +++ libetpan-1.0/build-windows/libetpan_version.h
> Wed Nov 9 12:15:30 2011 @@ -34,11 +34,11 @@ #define LIBETPAN_VERSION_H
>
> #ifndef LIBETPAN_VERSION_MAJOR
> -#define LIBETPAN_VERSION_MAJOR 0
> +#define LIBETPAN_VERSION_MAJOR 1
> #endif
>
> #ifndef LIBETPAN_VERSION_MINOR
> -#define LIBETPAN_VERSION_MINOR 58
> +#define LIBETPAN_VERSION_MINOR 0
> #endif
>
> #ifndef LIBETPAN_REENTRANT
> diff -ur libetpan-1.0-orig/src/data-types/mailstream_helper.c
> libetpan-1.0/src/data-types/mailstream_helper.c ---
> libetpan-1.0-orig/src/data-types/mailstream_helper.c Thu Feb 21
> 00:15:50 2008 +++
> libetpan-1.0/src/data-types/mailstream_helper.c Thu Nov 10
> 17:40:11 2011 @@ -44,7 +44,8 @@ static void
> remove_trailing_eol(MMAPString * mmapstr) {
> - if (mmapstr->str[mmapstr->len - 1] == '\n') {
> + if(mmapstr && mmapstr->str && mmapstr->len > 0 ){
> + if (mmapstr->str[mmapstr->len - 1] == '\n') {
> mmapstr->len --;
> mmapstr->str[mmapstr->len] = '\0';
> }
> @@ -53,6 +54,7 @@
> mmapstr->str[mmapstr->len] = '\0';
> }
> }
> +}
>
> char * mailstream_read_line(mailstream * stream, MMAPString * line)
> {
> @@ -113,12 +115,17 @@
>
> char * mailstream_read_line_remove_eol(mailstream * stream, MMAPString
> * line) {
> - if (!mailstream_read_line(stream, line))
> + if (stream && line){
> + if (!mailstream_read_line(stream, line))
> return NULL;
>
> remove_trailing_eol(line);
>
> return line->str;
> + }
> +else {
> + return NULL;
> +}
> }
>
> int mailstream_is_end_multiline(const char * line)
> diff -ur libetpan-1.0-orig/src/low-level/feed/parser.c
> libetpan-1.0/src/low-level/feed/parser.c ---
> libetpan-1.0-orig/src/low-level/feed/parser.c Mon Sep 7
> 01:20:26 2009 +++ libetpan-1.0/src/low-level/feed/parser.c Wed
> Nov 9 12:44:48 2011 @@ -41,9 +41,7 @@ #include <stdio.h>
> #include <errno.h>
>
> -#ifdef HAVE_ICONV
> #include <iconv.h>
> -#endif
>
> #include "newsfeed.h"
>
> @@ -230,7 +228,7 @@
> return LEP_ICONV_OK;
> }
> #else
> - return LEP_ICONV_FAIL;
> + return LEP_ICONV_FAILED;
> #endif
> }
>
> diff -ur libetpan-1.0-orig/src/low-level/nntp/newsnntp.c
> libetpan-1.0/src/low-level/nntp/newsnntp.c ---
> libetpan-1.0-orig/src/low-level/nntp/newsnntp.c Mon Apr 5
> 17:21:36 2010 +++ libetpan-1.0/src/low-level/nntp/newsnntp.c Thu
> Nov 10 10:38:13 2011 @@ -1338,7 +1338,7 @@ r = send_command(f, command);
> if (r == -1)
> return NEWSNNTP_ERROR_STREAM;
> -
> + if(f)
> response = read_line(f);
> if (response == NULL)
> return NEWSNNTP_ERROR_STREAM;
> @@ -1816,7 +1816,8 @@
>
> static char * read_line(newsnntp * f)
> {
> - return mailstream_read_line_remove_eol(f->nntp_stream,
> f->nntp_stream_buffer);
> + if (f && f->nntp_stream && f->nntp_stream_buffer)
> + return mailstream_read_line_remove_eol(f->nntp_stream,
> f->nntp_stream_buffer); }
>
> static char * read_multiline(newsnntp * f, size_t size,
>
>
>
Hi,
Not quite the way it's done... The patch has been word wrapped,
so it doesn't apply.
LIBETPAN_VERSION_MAJOR/MINOR - shouldn't need to be touched. These
should be supplied by the Makefile. HAVE_ICONV should need to change
this supplied by the configure. Changing LEP_ICONV_FAIL to
LEP_ICONV_FAILED, not convinced you haven't missed applying patches
in the Ports tree. Some of the indents are wrong, that
could be the word wrap.
The port Makefile should have a reversion bump. Maintainer removed/replaced.
Patches are normally supplied as a CVS diff of the ports tree.
Looks at if you built outside the ports tree, and making unnecessary
corrections to build.
Attached is a diff to give an idea how updates to ports need to be supplied.
This should be attached inline so there is no word wrap.
Nigel
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/mail/libetpan/Makefile,v
retrieving revision 1.11
diff -u -p -r1.11 Makefile
--- Makefile 6 Jul 2011 18:57:09 -0000 1.11
+++ Makefile 7 Dec 2011 17:07:42 -0000
@@ -3,7 +3,7 @@
COMMENT= mail purpose library
DISTNAME= libetpan-1.0
-REVISION= 0
+REVISION= 1
CATEGORIES= mail devel
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=libetpan/}
@@ -11,7 +11,7 @@ SHARED_LIBS= etpan 14.0
HOMEPAGE= http://libetpan.sourceforge.net/
-MAINTAINER= Ulrich Kahl <[email protected]>
+MAINTAINER= Nigel Taylor <[email protected]>
# BSD
PERMIT_PACKAGE_CDROM= Yes
Index: patches/patch-src_data-types_mailstream_helper_c
===================================================================
RCS file: patches/patch-src_data-types_mailstream_helper_c
diff -N patches/patch-src_data-types_mailstream_helper_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_data-types_mailstream_helper_c 7 Dec 2011 17:38:31
-0000
@@ -0,0 +1,40 @@
+$OpenBSD$
+--- src/data-types/mailstream_helper.c.orig Wed Feb 20 22:15:50 2008
++++ src/data-types/mailstream_helper.c Wed Dec 7 17:37:20 2011
+@@ -44,7 +44,8 @@
+
+ static void remove_trailing_eol(MMAPString * mmapstr)
+ {
+- if (mmapstr->str[mmapstr->len - 1] == '\n') {
++ if(mmapstr && mmapstr->str && mmapstr->len > 0 ){
++ if (mmapstr->str[mmapstr->len - 1] == '\n') {
+ mmapstr->len --;
+ mmapstr->str[mmapstr->len] = '\0';
+ }
+@@ -53,6 +54,7 @@ static void remove_trailing_eol(MMAPString * mmapstr)
+ mmapstr->str[mmapstr->len] = '\0';
+ }
+ }
++}
+
+ char * mailstream_read_line(mailstream * stream, MMAPString * line)
+ {
+@@ -113,12 +115,17 @@ char * mailstream_read_line_append(mailstream * stream
+
+ char * mailstream_read_line_remove_eol(mailstream * stream, MMAPString * line)
+ {
+- if (!mailstream_read_line(stream, line))
++ if (stream && line){
++ if (!mailstream_read_line(stream, line))
+ return NULL;
+
+ remove_trailing_eol(line);
+
+ return line->str;
++ }
++else {
++ return NULL;
++}
+ }
+
+ int mailstream_is_end_multiline(const char * line)
Index: patches/patch-src_low-level_nntp_newsnntp_c
===================================================================
RCS file: patches/patch-src_low-level_nntp_newsnntp_c
diff -N patches/patch-src_low-level_nntp_newsnntp_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_low-level_nntp_newsnntp_c 7 Dec 2011 17:38:44 -0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+--- src/low-level/nntp/newsnntp.c.orig Mon Apr 5 15:21:36 2010
++++ src/low-level/nntp/newsnntp.c Wed Dec 7 17:37:20 2011
+@@ -1338,7 +1338,7 @@ int newsnntp_date(newsnntp * f, struct tm * tm)
+ r = send_command(f, command);
+ if (r == -1)
+ return NEWSNNTP_ERROR_STREAM;
+-
++ if(f)
+ response = read_line(f);
+ if (response == NULL)
+ return NEWSNNTP_ERROR_STREAM;
+@@ -1816,7 +1816,8 @@ static int parse_response(newsnntp * f, char * respons
+
+ static char * read_line(newsnntp * f)
+ {
+- return mailstream_read_line_remove_eol(f->nntp_stream,
f->nntp_stream_buffer);
++ if (f && f->nntp_stream && f->nntp_stream_buffer)
++ return mailstream_read_line_remove_eol(f->nntp_stream,
f->nntp_stream_buffer);
+ }
+
+ static char * read_multiline(newsnntp * f, size_t size,