Ok, here's an ifdef version (+ added error handling for our case, if
the tmpfile has failed).


Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/check/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- Makefile    29 Sep 2014 19:58:04 -0000      1.12
+++ Makefile    21 Nov 2014 00:26:44 -0000
@@ -3,6 +3,7 @@
 COMMENT =      unit test framework for C programs
 
 DISTNAME =     check-0.9.14
+REVISION =     0
 SHARED_LIBS +=  check                3.0      # unknown
 
 CATEGORIES =   devel
Index: patches/patch-src_check_msg_c
===================================================================
RCS file: patches/patch-src_check_msg_c
diff -N patches/patch-src_check_msg_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_check_msg_c       21 Nov 2014 10:05:52 -0000
@@ -0,0 +1,21 @@
+--- src/check_msg.c.orig       Fri Nov 21 11:31:49 2014
++++ src/check_msg.c    Fri Nov 21 12:04:56 2014
+@@ -234,6 +234,7 @@
+     file = tmpfile();
+     if(file == NULL)
+     {
++#ifdef _WIN32
+         char *tmp = getenv("TEMP");
+         char *tmp_file = tempnam(tmp, "check_");
+ 
+@@ -252,6 +253,10 @@
+         file = fopen(uniq_tmp_file, "w+b");
+         *name = uniq_tmp_file;
+         free(tmp_file);
++#else
++      fprintf(stderr, "Error creating temporary file\n");
++      exit(EXIT_FAILURE);
++#endif
+     }
+     return file;
+ }



On Fri, Nov 21, 2014 at 11:42:33AM +0400, Vadim Zhukov wrote:
> 21 нояб. 2014 г. 3:42 пользователь "Kaspars Bankovskis" <
> kasp...@bankovskis.net> написал:
> >
> > Hi,
> >
> > Currently, when linking your source against libcheck, you get an
> > annoying warning about unsafe usage of tempnam(3).  The following
> > patch fixes that, by commenting out a block of code which, according
> > to comments above it, is supposed to solve issues with Windows, and
> > shouldn't be relevant in OpenBSD case.
> >
> >
> > Index: Makefile
> > ===================================================================
> > RCS file: /cvs/ports/devel/check/Makefile,v
> > retrieving revision 1.12
> > diff -u -p -u -r1.12 Makefile
> > --- Makefile    29 Sep 2014 19:58:04 -0000      1.12
> > +++ Makefile    21 Nov 2014 00:26:44 -0000
> > @@ -3,6 +3,7 @@
> >  COMMENT =      unit test framework for C programs
> >
> >  DISTNAME =     check-0.9.14
> > +REVISION =     0
> >  SHARED_LIBS +=  check                3.0      # unknown
> >
> >  CATEGORIES =   devel
> > Index: patches/patch-src_check_msg_c
> > ===================================================================
> > RCS file: patches/patch-src_check_msg_c
> > diff -N patches/patch-src_check_msg_c
> > --- /dev/null   1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-src_check_msg_c       20 Nov 2014 23:50:20 -0000
> > @@ -0,0 +1,30 @@
> > +--- src/check_msg.c.orig       Fri Nov 21 01:47:21 2014
> > ++++ src/check_msg.c    Fri Nov 21 01:50:16 2014
> > +@@ -232,10 +232,12 @@
> > +     /* and finally, the "b" from "w+b" is ignored on OS X, not sure
> about WIN32 */
> > +
> > +     file = tmpfile();
> > ++/*
> > +     if(file == NULL)
> > +     {
> > +         char *tmp = getenv("TEMP");
> > +         char *tmp_file = tempnam(tmp, "check_");
> > ++*/
> > +
> > +         /*
> > +          * Note, tempnam is not enough to get a unique name. Between
> > +@@ -247,12 +249,14 @@
> > +          * we append the pid to the file. The pid should be unique on
> the
> > +          * system.
> > +          */
> > ++/*
> > +         char *uniq_tmp_file = ck_strdup_printf("%s.%d", tmp_file,
> getpid());
> > +
> > +         file = fopen(uniq_tmp_file, "w+b");
> > +         *name = uniq_tmp_file;
> > +         free(tmp_file);
> > +     }
> > ++*/
> > +     return file;
> > + }
> > +
> 
> Could you, please, use something that upstream will accept instead? Like
> "#ifdef _WIN32".
> 
> --
> Vadim Zhukov

Reply via email to