Commit 6bfeb4fe authored by Robert Lubos's avatar Robert Lubos Committed by Fabio Baltieri
Browse files

net: lwm2m: senml_cbor: Verify data len before calling memcpy



Check if there actually is data to copy before calling memcpy() to
prevent potentially calling memcpy() with NULL value pointer.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 779d8521
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -644,8 +644,9 @@ static int get_string(struct lwm2m_input_context *in, uint8_t *buf, size_t bufle
	}

	len = MIN(buflen-1, fd->current->record_union.union_vs.len);

	if (len > 0) {
		memcpy(buf, fd->current->record_union.union_vs.value, len);
	}
	buf[len] = '\0';

	fd->current = NULL;