libexpat: Solaris and error: 'NAN' was not declared in this scope

Hi Everyone,

I’m updating OpenSSH on Solaris 11.4 i86. libexpat is a dependency. libexpat 2.4.5 is having a little trouble:

$ make check -k
...
/bin/g++ -DHAVE_CONFIG_H -I. -I..   -DXML_ENABLE_VISIBILITY=1 -I./../lib -I/opt/ssh/incl
ude -DNDEBUG -Wall   -fexceptions -fno-strict-aliasing -g2 -O2 -m64 -march=native -fPIC
-pthread -MT runtestspp.o -MD -MP -MF .deps/runtestspp.Tpo -c -o runtestspp.o runtestspp
.cpp
In file included from runtestspp.cpp:36:0:
runtests.c: In function 'void test_billion_laughs_attack_protection_api()':
runtests.c:11712:32: error: 'NAN' was not declared in this scope
          parserWithoutParent, NAN)
                               ^
runtests.c:11734:32: error: 'INFINITY' was not declared in this scope
          parserWithoutParent, INFINITY)
                               ^
*** Error code 1

This patch appears to clear the issue. The self tests build and run without problems:

$ cat expat.patch 
--- tests/runtests.c
+++ tests/runtests.c 
@@ -60,6 +60,16 @@
 #  include <stdbool.h>
 #endif
 
+#if defined(__sun__)
+#  include <sunmath.h>
+#  if ! defined(INFINITY)
+#    define INFINITY (__builtin_huge_val())
+#  endif
+#  if ! defined(NAN)
+#    define NAN (__builtin_nan(""))
+#  endif
+#endif
+
 #include "expat.h"
 #include "chardata.h"
 #include "structdata.h"
@@ -6636,7 +6646,8 @@
   XML_Char **elemstr = (XML_Char **)userData;
   if (xcstrcmp(elemstr[0], name) != 0) {
     char buffer[1024];
-    sprintf(buffer, "unexpected end string: '%" XML_FMT_STR "'", name);
+    snprintf(buffer, sizeof(buffer), "unexpected end string: '%" XML_FMT_STR "'", name);
+    buffer[sizeof(buffer)-1] = '\0';  /* ensure NULL termination */
     fail(buffer);
   }
   triplet_end_flag = XML_TRUE;

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@noloader I have dropped use of isinf now. How about this version: 0001-tests-Resolve-use-of-macros-NAN-and-INFINITY-for-GNU.patch.txt