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,



-- 
With best regards,
        Gregory Edigarov

Reply via email to