zephyr/modsocket: socket_write: Send only data fitting in a netbuf.

zephyr-rebase
Paul Sokolovsky 2016-09-18 14:13:38 +03:00
parent 9290942f3a
commit c5b33851d7
1 changed files with 3 additions and 0 deletions

View File

@ -184,6 +184,9 @@ STATIC mp_uint_t socket_write(mp_obj_t self_in, const void *buf, mp_uint_t len,
}
struct net_buf *netbuf = ip_buf_get_tx(self->sock);
if (len > net_buf_tailroom(netbuf)) {
len = net_buf_tailroom(netbuf);
}
uint8_t *ptr = net_buf_add(netbuf, len);
memcpy(ptr, buf, len);
ip_buf_appdatalen(netbuf) = len;