Ticket #7186: sane-snprintf.patch.txt

File sane-snprintf.patch.txt, 2.0 KB (added by Nathan Baum, 2 years ago)
Line 
1Sun Feb  4 19:43:31 UTC 2007  Nathan Baum <nathan_baum@btinternet.com>
2  * sane-snprintf
3diff -rN -c old-vanilla/hdrs/externs.h new-vanilla/hdrs/externs.h
4*** old-vanilla/hdrs/externs.h  2007-02-04 19:45:22.000000000 +0000
5--- new-vanilla/hdrs/externs.h  2007-02-04 19:45:22.000000000 +0000
6***************
7*** 417,426 ****
8  #endif
9      char *mush_strdup(const char *s, const char *check) __attribute_malloc__;
10  #ifdef WIN32
11! #ifndef HAS_VSNPRINTF
12! #define HAS_VSNPRINTF
13! #define vsnprintf _vsnprintf
14! #endif
15  #endif
16 
17  #ifdef WIN32
18--- 417,432 ----
19  #endif
20      char *mush_strdup(const char *s, const char *check) __attribute_malloc__;
21  #ifdef WIN32
22! int sane_snprintf (char *str, size_t size, const char *format, ...)
23! {
24!   va_list args;
25!   va_start(args, format);
26!   vsnprintf_s(str, size, _TRUNCATE, format, args);
27!   va_end(args);
28! }
29!
30! #define snprintf sane_snprintf
31! #define vsnprintf(str,size,fmt,args) vsnprintf_s(str, size, _TRUNCATE, fmt, args)
32  #endif
33 
34  #ifdef WIN32
35diff -rN -c old-vanilla/hdrs/mysocket.h new-vanilla/hdrs/mysocket.h
36*** old-vanilla/hdrs/mysocket.h 2007-02-04 19:45:22.000000000 +0000
37--- new-vanilla/hdrs/mysocket.h 2007-02-04 19:45:22.000000000 +0000
38***************
39*** 24,30 ****
40  #define ETIMEDOUT WSAETIMEDOUT
41  #define EAFNOSUPPORT WSAEAFNOSUPPORT
42  #define ENOSPC          28
43! #define snprintf _snprintf
44  #define MAXHOSTNAMELEN 32
45  #pragma comment( lib, "wsock32.lib")
46  #pragma comment( lib, "winmm.lib")
47--- 24,41 ----
48  #define ETIMEDOUT WSAETIMEDOUT
49  #define EAFNOSUPPORT WSAEAFNOSUPPORT
50  #define ENOSPC          28
51!
52! int sane_snprintf (char *str, size_t size, const char *format, ...)
53! {
54!   va_list args;
55!   va_start(args, format);
56!   vsnprintf_s(str, size, _TRUNCATE, format, args);
57!   va_end(args);
58! }
59!
60! #define snprintf sane_snprintf
61! #define vsnprintf(str,size,fmt,args) vsnprintf_s(str, size, _TRUNCATE, fmt, args)
62!
63  #define MAXHOSTNAMELEN 32
64  #pragma comment( lib, "wsock32.lib")
65  #pragma comment( lib, "winmm.lib")