diff --git a/src/network/net_netswitch.c b/src/network/net_netswitch.c index e95c9aeaf..1cd0a81a7 100644 --- a/src/network/net_netswitch.c +++ b/src/network/net_netswitch.c @@ -401,6 +401,7 @@ net_netswitch_init(const netcard_t *card, const uint8_t *mac_addr, void *priv, c memcpy(ns_args.mac_addr, net_netswitch->mac_addr, 6); /* The remote switch hostname */ strncpy(ns_args.nrs_hostname, netcard->nrs_hostname, sizeof(ns_args.nrs_hostname) - 1); + ns_args.nrs_hostname[127] = 0x00; net_switch_log("%s Net Switch: Starting up virtual switch with group %d, flags %d\n", net_netswitch->switch_type, ns_args.group, ns_args.flags); diff --git a/src/network/netswitch.c b/src/network/netswitch.c index e7b913d0d..1ec2c5e6f 100644 --- a/src/network/netswitch.c +++ b/src/network/netswitch.c @@ -242,6 +242,7 @@ ns_open(struct ns_open_args *open_args) { /* Remote switch hostname */ strncpy(conn->nrs_hostname, open_args->nrs_hostname, sizeof(conn->nrs_hostname) - 1); + conn->nrs_hostname[127] = 0x00; /* Switch type */ if(conn->switch_type == SWITCH_TYPE_REMOTE) { diff --git a/src/network/pb_encode.c b/src/network/pb_encode.c index 7f5620125..a4e30b471 100644 --- a/src/network/pb_encode.c +++ b/src/network/pb_encode.c @@ -53,7 +53,8 @@ static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, si { pb_byte_t *dest = (pb_byte_t*)stream->state; stream->state = dest + count; - + + if ((dest != NULL) && (buf != NULL)) memcpy(dest, buf, count * sizeof(pb_byte_t)); return true;