]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | diff --git a/src/binn.c b/src/binn.c |
2 | index ef32f35..d12d473 100644 | |
3 | --- a/src/binn.c | |
4 | +++ b/src/binn.c | |
5 | @@ -142,8 +142,14 @@ BINN_PRIVATE void copy_be64(u64 *pdest, u64 *psource) { | |
6 | /***************************************************************************/ | |
7 | ||
8 | #ifndef WIN32 | |
9 | #define stricmp strcasecmp | |
10 | #define strnicmp strncasecmp | |
11 | +#define sprintf_s(b, n, ...) sprintf(b, __VA_ARGS__) | |
12 | +#define strcpy_s(b, n, s) strcpy(b, s) | |
13 | +#else | |
14 | +#define stricmp _stricmp | |
15 | +#define strnicmp _strnicmp | |
16 | +#define strdup _strdup | |
17 | #endif | |
18 | ||
19 | BINN_PRIVATE BOOL IsValidBinnHeader(void *pbuf, int *ptype, int *pcount, int *psize, int *pheadersize); | |
20 | @@ -1582,6 +1588,7 @@ BINN_PRIVATE BOOL binn_read_pair(int expected_type, void *ptr, int pos, int *pid | |
21 | base = p; | |
22 | plimit = p + size - 1; | |
23 | p += header_size; | |
24 | + key = 0; | |
25 | ||
26 | for (i = 0; i < count; i++) { | |
27 | switch (type) { | |
28 | @@ -3333,7 +3340,7 @@ char * APIENTRY binn_get_str(binn *value) { | |
29 | ||
30 | if (type_family(value->type) == BINN_FAMILY_INT) { | |
31 | if (copy_int_value(value->ptr, &vint, value->type, BINN_INT64) == FALSE) return NULL; | |
32 | - sprintf(buf, "%" INT64_FORMAT, vint); | |
33 | + sprintf_s(buf, sizeof buf, "%" INT64_FORMAT, vint); | |
34 | goto loc_convert_value; | |
35 | } | |
36 | ||
37 | @@ -3341,14 +3348,14 @@ char * APIENTRY binn_get_str(binn *value) { | |
38 | case BINN_FLOAT: | |
39 | value->vdouble = value->vfloat; | |
40 | case BINN_DOUBLE: | |
41 | - sprintf(buf, "%g", value->vdouble); | |
42 | + sprintf_s(buf, sizeof buf, "%g", value->vdouble); | |
43 | goto loc_convert_value; | |
44 | case BINN_STRING: | |
45 | return (char*) value->ptr; | |
46 | case BINN_BOOL: | |
47 | if (value->vbool) | |
48 | - strcpy(buf, "true"); | |
49 | + strcpy_s(buf, sizeof buf, "true"); | |
50 | else | |
51 | - strcpy(buf, "false"); | |
52 | + strcpy_s(buf, sizeof buf, "false"); | |
53 | goto loc_convert_value; | |
54 | } |