diff --git a/iio-private.h b/iio-private.h index 6d0fb2dd5..cce44a82b 100644 --- a/iio-private.h +++ b/iio-private.h @@ -29,8 +29,10 @@ #ifdef _MSC_BUILD #define inline __inline #define iio_snprintf sprintf_s +#define iio_sscanf sscanf_s #else #define iio_snprintf snprintf +#define iio_sscanf sscanf #endif #ifdef _WIN32 diff --git a/iiod-client.c b/iiod-client.c index aabafe472..0469a115a 100644 --- a/iiod-client.c +++ b/iiod-client.c @@ -588,7 +588,7 @@ static int iiod_client_read_mask(struct iiod_client *client, IIO_DEBUG("Reading mask\n"); for (i = words, ptr = buf; i > 0; i--) { - sscanf(ptr, "%08" PRIx32, &mask[i - 1]); + iio_sscanf(ptr, "%08" PRIx32, &mask[i - 1]); IIO_DEBUG("mask[%lu] = 0x%08" PRIx32 "\n", (unsigned long)(i - 1), mask[i - 1]); diff --git a/local.c b/local.c index 54cef6f32..3faed8af8 100644 --- a/local.c +++ b/local.c @@ -1230,12 +1230,22 @@ static int handle_protected_scan_element_attr(struct iio_channel *chn, char endian, sign; if (strchr(buf, 'X')) { - sscanf(buf, "%ce:%c%u/%uX%u>>%u", &endian, &sign, + iio_sscanf(buf, "%ce:%c%u/%uX%u>>%u", +#ifdef _MSC_BUILD + &e, sizeof(e), &s, sizeof(s), +#else + &endian, &sign, +#endif &chn->format.bits, &chn->format.length, &chn->format.repeat, &chn->format.shift); } else { chn->format.repeat = 1; - sscanf(buf, "%ce:%c%u/%u>>%u", &endian, &sign, + iio_sscanf(buf, "%ce:%c%u/%u>>%u", +#ifdef _MSC_BUILD + &e, sizeof(e), &s, sizeof(s), +#else + &endian, &sign, +#endif &chn->format.bits, &chn->format.length, &chn->format.shift); } diff --git a/network.c b/network.c index 18770c928..cea71a80e 100644 --- a/network.c +++ b/network.c @@ -780,7 +780,7 @@ static ssize_t network_read_mask(struct iio_network_io_context *io_ctx, if (ret < 0) return ret; - sscanf(buf, "%08x", &mask[i - 1]); + iio_sscanf(buf, "%08x", &mask[i - 1]); IIO_DEBUG("mask[%lu] = 0x%x\n", (unsigned long)(i - 1), mask[i - 1]); } diff --git a/xml.c b/xml.c index 5640dc36b..607d7812f 100644 --- a/xml.c +++ b/xml.c @@ -143,14 +143,24 @@ static void setup_scan_element(struct iio_channel *chn, xmlNode *n) } else if (!strcmp(name, "format")) { char e, s; if (strchr(content, 'X')) { - sscanf(content, "%ce:%c%u/%uX%u>>%u", &e, &s, + iio_sscanf(content, "%ce:%c%u/%uX%u>>%u", +#ifdef _MSC_BUILD + &e, sizeof(e), &s, sizeof(s), +#else + &e, &s, +#endif &chn->format.bits, &chn->format.length, &chn->format.repeat, &chn->format.shift); } else { chn->format.repeat = 1; - sscanf(content, "%ce:%c%u/%u>>%u", &e, &s, + iio_sscanf(content, "%ce:%c%u/%u>>%u", +#ifdef _MSC_BUILD + &e, sizeof(e), &s, sizeof(s), +#else + &e, &s, +#endif &chn->format.bits, &chn->format.length, &chn->format.shift);