View Issue Details

IDProjectCategoryView StatusLast Update
0001288SOGoSOPEpublic2011-05-09 20:54
Reporterbuzzdee Assigned Toludovic  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.7 
Fixed in Version1.3.8 
Summary0001288: OpenBSD does have strndup(3)
Description

NGMimeRFC822DateHeaderFieldParser.m has an own strndup() function, which gets used, in case its not compiled with -DHAVE_STRNDUP. Unfortunately, the GNUmakefile.preamble is deciding wrong with regard to OpenBSD.

Additional Information

Attached patch makes it compile with the strndup from the system.

TagsNo tags attached.

Activities

2011-05-05 22:35

 

patch-sope-mime_NGMime_GNUmakefile_preamble (422 bytes)   
$OpenBSD$

OpenBSD has strndup(3)

--- sope-mime/NGMime/GNUmakefile.preamble.orig	Thu May  5 19:10:39 2011
+++ sope-mime/NGMime/GNUmakefile.preamble	Thu May  5 19:10:49 2011
@@ -10,7 +10,7 @@ ADDITIONAL_CPPFLAGS += \
         -DHAVE_STRNDUP
 endif
 
-ifneq ($(findstring openbsd, $(GNUSTEP_TARGET_OS)), openbsd)
+ifeq ($(findstring openbsd, $(GNUSTEP_TARGET_OS)), openbsd)
 	ADDITIONAL_CPPFLAGS += -DHAVE_STRNDUP
 endif
 
buzzdee

buzzdee

2011-05-09 16:00

reporter   ~0002450

After I sent the patch to review for inclusion in the openbsd ports tree, I was pointed that my patch is nonsense.
-- snip -- -- --
ifeq ($(patsubstr GNU/%,glibc,$(shell uname -o)),glibc)
ADDITIONAL_CPPFLAGS += \
-DHAVE_STRNDUP
endif

ifneq ($(findstring openbsd, $(GNUSTEP_TARGET_OS)), openbsd)
ADDITIONAL_CPPFLAGS += -DHAVE_STRNDUP
endif
-- snip -- -- --

So, as distributed:

If we're using glibc, add -DHAVE_STRNDUP.
If we're not OpenBSD, add -DHAVE_STRNDUP.

-> all OS except OpenBSD have -DHAVE_STRNDUP set. So this whole
macro is only used on OpenBSD and we're removing it.

Since all OS besides OpenBSD has strndup, I completely removed this cruft from the GNUmakefile.preamble, and also removed the hand rolled strndup in the NGMimeRFC822DateHeaderFieldParser.m. see attached patch.

2011-05-09 16:01

 

do-not-use-hand-rolled-strndup-at-all.txt (1,384 bytes)   
$OpenBSD$

OpenBSD has strndup(3)

--- sope-mime/NGMime/GNUmakefile.preamble.orig	Tue Nov  2 15:12:14 2010
+++ sope-mime/NGMime/GNUmakefile.preamble	Mon May  9 13:04:27 2011
@@ -5,15 +5,6 @@ ADDITIONAL_CPPFLAGS += \
 	-DLIBRARY_MINOR_VERSION=${MINOR_VERSION} \
 	-DLIBRARY_SUBMINOR_VERSION=${SUBMINOR_VERSION} \
 
-ifeq ($(patsubstr GNU/%,glibc,$(shell uname -o)),glibc)
-ADDITIONAL_CPPFLAGS += \
-        -DHAVE_STRNDUP
-endif
-
-ifneq ($(findstring openbsd, $(GNUSTEP_TARGET_OS)), openbsd)
-	ADDITIONAL_CPPFLAGS += -DHAVE_STRNDUP
-endif
-
 NGMime_INCLUDE_DIRS += \
 	-I.. -I../..			\
 	-I../../sope-core/NGStreams/	\
$OpenBSD$

fix kind of random crasher in the webmail interface see bug #1022

--- sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m.orig	Sat Dec 18 12:43:50 2010
+++ sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m	Mon May  9 13:04:55 2011
@@ -19,10 +19,6 @@
   02111-1307, USA.
 */
 
-#ifdef HAVE_STRNDUP
-#define _GNU_SOURCE 1
-#endif
-
 #include <string.h>
 
 #include "NGMimeHeaderFieldParser.h"
@@ -30,18 +26,6 @@
 #include "NGMimeUtilities.h"
 #include "common.h"
 
-#ifndef HAVE_STRNDUP
-char *strndup(const char *str, size_t len)
-{
-  char *dup = (char *)malloc(len+1);
-  if (dup) {
-    strncpy(dup,str,len);
-    dup[len]= '\0';
-  }
-  return dup;
-}
-#endif
-
 @implementation NGMimeRFC822DateHeaderFieldParser
 
 static NSTimeZone *gmt = nil;
ludovic

ludovic

2011-05-09 20:54

administrator   ~0002452

http://mtn.inverse.ca/revision/info/66f477f73a8ce773bdb62cd6184905f4336f420e

Issue History

Date Modified Username Field Change
2011-05-05 22:35 buzzdee New Issue
2011-05-05 22:35 buzzdee File Added: patch-sope-mime_NGMime_GNUmakefile_preamble
2011-05-09 16:00 buzzdee Note Added: 0002450
2011-05-09 16:01 buzzdee File Added: do-not-use-hand-rolled-strndup-at-all.txt
2011-05-09 20:54 ludovic Note Added: 0002452
2011-05-09 20:54 ludovic Status new => resolved
2011-05-09 20:54 ludovic Fixed in Version => 1.3.8
2011-05-09 20:54 ludovic Resolution open => fixed
2011-05-09 20:54 ludovic Assigned To => ludovic