1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #5534 from aeneby/sc_netif_send_empty_payload

shell: set NULL pointer for data pakets with zero-length payload
This commit is contained in:
Martine Lenders 2016-06-09 11:04:44 +02:00
commit 789b2c0917

View File

@ -1041,7 +1041,7 @@ int _netif_send(int argc, char **argv)
{
kernel_pid_t dev;
uint8_t addr[MAX_ADDR_LEN];
size_t addr_len;
size_t addr_len, data_len;
gnrc_pktsnip_t *pkt, *hdr;
gnrc_netif_hdr_t *nethdr;
uint8_t flags = 0x00;
@ -1073,10 +1073,16 @@ int _netif_send(int argc, char **argv)
}
/* put packet together */
pkt = gnrc_pktbuf_add(NULL, argv[3], strlen(argv[3]), GNRC_NETTYPE_UNDEF);
if (pkt == NULL) {
puts("error: packet buffer full");
return 1;
data_len = strlen(argv[3]);
if (data_len == 0) {
pkt = NULL;
}
else {
pkt = gnrc_pktbuf_add(NULL, argv[3], data_len, GNRC_NETTYPE_UNDEF);
if (pkt == NULL) {
puts("error: packet buffer full");
return 1;
}
}
hdr = gnrc_netif_hdr_build(NULL, 0, addr, addr_len);
if (hdr == NULL) {