Commit b9ac440d authored by Jukka Rissanen's avatar Jukka Rissanen
Browse files

samples: net: Fix invalid memory access for TCP

Set protocol family value only after the buf is verified
to be non-null.

Change-Id: I0ce7bab3539087d0f522b4bb3024f46a7eb3c15f
Signed-off-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
parent baa4939b
Loading
Loading
Loading
Loading
+3 −1
Changes for samples/net/echo_server/src/echo-server.c: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -429,8 +429,8 @@ static void tcp_received(struct net_context *context,
			 void *user_data)
{
	static char dbg[MAX_DBG_PRINT + 1];
	sa_family_t family = net_nbuf_family(buf);
	struct net_buf *reply_buf;
	sa_family_t family;
	int ret;

	if (!buf) {
@@ -438,6 +438,8 @@ static void tcp_received(struct net_context *context,
		return;
	}

	family = net_nbuf_family(buf);

	snprintk(dbg, MAX_DBG_PRINT, "TCP IPv%c",
		 family == AF_INET6 ? '6' : '4');