fix null-termination of strings

master
Andre Puschmann 7 years ago
parent e7502d5c6c
commit c8f9a7785a

@ -51,7 +51,7 @@ srslte_cell_t cell = {
SRSLTE_PHICH_R_1_6 // PHICH resources
};
char mimo_type_str [32] = "single";
char mimo_type_str[32] = "single";
srslte_mimo_type_t mimo_type = SRSLTE_MIMO_TYPE_SINGLE_ANTENNA;
uint32_t cfi = 1;
uint32_t mcs[SRSLTE_MAX_CODEWORDS] = {0, 0};
@ -111,7 +111,8 @@ void parse_args(int argc, char **argv) {
cfi = atoi(argv[optind]);
break;
case 'x':
strncpy(mimo_type_str, argv[optind], 32);
strncpy(mimo_type_str, argv[optind], sizeof(mimo_type_str));
mimo_type_str[sizeof(mimo_type_str)-1] = 0;
break;
case 'p':
pmi = (uint32_t) atoi(argv[optind]);

@ -716,6 +716,7 @@ int enb::parse_sib9(std::string filename, LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_9_STRUC
data->hnb_name_present = true;
if (name_enabled) {
strncpy((char*) data->hnb_name, hnb_name.c_str(), 48);
data->hnb_name[47] = 0;
data->hnb_name_size = strnlen(hnb_name.c_str(), 48);
} else if (hex_enabled) {
data->hnb_name_size = HexToBytes(hex_value, data->hnb_name, 48);

@ -202,6 +202,7 @@ srslte::error_t gw::init_if(char *err_str)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ);
ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1] = 0;
if(0 > ioctl(tun_fd, TUNSETIFF, &ifr))
{
err_str = strerror(errno);

Loading…
Cancel
Save