diff --git a/src/iperf_api.c b/src/iperf_api.c index 0a973bc66..89a204cff 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -2778,6 +2778,7 @@ JSON_read(int fd, int max_size) char *str; cJSON *json = NULL; int rc; + char msg_buf[WARN_STR_LEN * 2]; /* * Read a four-byte integer, which is the length of the JSON to follow. @@ -2805,19 +2806,27 @@ JSON_read(int fd, int max_size) json = cJSON_Parse(str); } else { - warning("JSON size of data read does not correspond to offered length"); + snprintf(msg_buf, sizeof(msg_buf), "JSON size of data read does not correspond to offered length - expected %d bytes but received %d; errno=%d", hsize, rc, errno); + warning(msg_buf); } } + else { + snprintf(msg_buf, sizeof(msg_buf), "JSON data read failed; errno=%d", errno); + warning(msg_buf); + } free(str); } } } else { - warning("JSON data length overflow"); + snprintf(msg_buf, sizeof(msg_buf), "JSON data length overflow - %d bytes JSON size is not allowed", hsize); + warning(msg_buf); } } else { warning("Failed to read JSON data size"); + snprintf(msg_buf, sizeof(msg_buf), "Failed to read JSON data size - read returned %d; errno=%d", rc, errno); + warning(msg_buf); } return json; }