Menu

#1311 macro SOAP_SNPRINTF from stdsoap2.h may be mangled

v1.0 (example)
closed-rejected
None
5
2023-07-11
2023-07-10
schnuette
No

stdsoap2.h shipped with the latest gsoap release includes the following macro definitions:

# ifdef HAVE_SNPRINTF
#  if _MSC_VER >= 1400
#   define SOAP_SNPRINTF(buf, len, num) void)_snprintf_s((buf), (len), _TRUNCATE
#   define SOAP_SNPRINTF_SAFE(buf, len) void)_snprintf_s((buf), (len), _TRUNCATE
#  else
#   define SOAP_SNPRINTF(buf, len, num) void)snprintf((buf), (len)
#   define SOAP_SNPRINTF_SAFE(buf, len) void)snprintf((buf), (len)
#  endif
# else
#  define SOAP_SNPRINTF(buf, len, num) (len) <= (num)) ? (void)((buf)[0] = '\0') : (void)sprintf((buf)
#  define SOAP_SNPRINTF_SAFE(buf, len) void)sprintf((buf)
# endif

Looks mangled, leads to compiler warnings.
Please check.

Discussion

  • Robert van Engelen

    No issues whatsover. Note that all uses have parenthesis in the code base: Like this:

    (SOAP_SNPRINTF(tmp, sizeof(tmp), 20), "&#x%lX;", c);
    

    So perfectly fine. This is to allow the result to be ignored with (void).

     
  • Robert van Engelen

    • status: open --> closed-rejected
    • assigned_to: Robert van Engelen
     

Log in to post a comment.