aboutsummaryrefslogtreecommitdiff
path: root/ports/binn/0001_fix_uwp.patch
blob: c4f0b6658733a7fc0f5d51d1295a2951ebf5aed3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
diff --git a/src/binn.c b/src/binn.c
index ef32f35..d12d473 100644
--- a/src/binn.c
+++ b/src/binn.c
@@ -142,8 +142,8 @@ BINN_PRIVATE void copy_be64(u64 *pdest, u64 *psource) {
 /***************************************************************************/
 
 #ifndef WIN32
-#define stricmp strcasecmp
-#define strnicmp strncasecmp
+#define _stricmp strcasecmp
+#define _strnicmp strncasecmp
 #endif
 
 BINN_PRIVATE BOOL IsValidBinnHeader(void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize);
@@ -614,7 +614,7 @@ BINN_PRIVATE unsigned char * SearchForKey(unsigned char *p, int header_size, int
     if (p > plimit) break;
     // Compare if the strings are equal.
     if (len > 0) {
-      if (strnicmp((char*)p, key, len) == 0) {   // note that there is no null terminator here
+      if (_strnicmp((char*)p, key, len) == 0) {   // note that there is no null terminator here
         if (keylen == len) {
           p += len;
           return p;
@@ -1582,6 +1582,7 @@ BINN_PRIVATE BOOL binn_read_pair(int expected_type, void *ptr, int pos, int *pid
   base = p;
   plimit = p + size - 1;
   p += header_size;
+  key = 0;
 
   for (i = 0; i < count; i++) {
     switch (type) {
@@ -3147,15 +3148,15 @@ BINN_PRIVATE BOOL is_bool_str(char *str, BOOL *pbool) {
 
   if (str == NULL || pbool == NULL) return FALSE;
 
-  if (stricmp(str, "true") == 0) goto loc_true;
-  if (stricmp(str, "yes") == 0) goto loc_true;
-  if (stricmp(str, "on") == 0) goto loc_true;
-  //if (stricmp(str, "1") == 0) goto loc_true;
+  if (_stricmp(str, "true") == 0) goto loc_true;
+  if (_stricmp(str, "yes") == 0) goto loc_true;
+  if (_stricmp(str, "on") == 0) goto loc_true;
+  //if (_stricmp(str, "1") == 0) goto loc_true;
 
-  if (stricmp(str, "false") == 0) goto loc_false;
-  if (stricmp(str, "no") == 0) goto loc_false;
-  if (stricmp(str, "off") == 0) goto loc_false;
-  //if (stricmp(str, "0") == 0) goto loc_false;
+  if (_stricmp(str, "false") == 0) goto loc_false;
+  if (_stricmp(str, "no") == 0) goto loc_false;
+  if (_stricmp(str, "off") == 0) goto loc_false;
+  //if (_stricmp(str, "0") == 0) goto loc_false;
 
   if (is_integer(str)) {
     vint = atoi64(str);
@@ -3333,7 +3334,7 @@ char * APIENTRY binn_get_str(binn *value) {
 
   if (type_family(value->type) == BINN_FAMILY_INT) {
     if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) return NULL;
-    sprintf(buf, "%" INT64_FORMAT, vint);
+    sprintf_s(buf, "%" INT64_FORMAT, vint);
     goto loc_convert_value;
   }
 
@@ -3341,15 +3342,15 @@ char * APIENTRY binn_get_str(binn *value) {
   case BINN_FLOAT:
     value->vdouble = value->vfloat;
   case BINN_DOUBLE:
-    sprintf(buf, "%g", value->vdouble);
+    sprintf_s(buf, sizeof buf, "%g", value->vdouble);
     goto loc_convert_value;
   case BINN_STRING:
     return (char*) value->ptr;
   case BINN_BOOL:
     if (value->vbool)
-      strcpy(buf, "true");
+      strcpy_s(buf, sizeof buf, "true");
     else
-      strcpy(buf, "false");
+      strcpy_s(buf, sizeof buf, "false");
     goto loc_convert_value;
   }
 
@@ -3358,7 +3359,7 @@ char * APIENTRY binn_get_str(binn *value) {
 loc_convert_value:
 
   //value->vint64 = 0;
-  value->ptr = strdup(buf);
+  value->ptr = _strdup(buf);
   if (value->ptr == NULL) return NULL;
   value->freefn = free;
   value->type = BINN_STRING;