修改原版代码中strlcpy最大8个字节的限制, "enp175s0f0"这种网卡名被截断的BUG.

This commit is contained in:
lijia
2019-07-12 14:50:30 +08:00
parent f36a4fca25
commit 408d23b286
3 changed files with 47 additions and 43 deletions

13
configure vendored
View File

@@ -2965,8 +2965,9 @@ _ACEOF
USER_CFLAGS=$CFLAGS
#CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99"
CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1"
#CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1 -DMARSIO=1"
#CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1"
CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1 -DMARSIO=1"
LIBS="-lmarsio $LIBS"
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@@ -16579,7 +16580,7 @@ if ${ac_cv_lib_nsl_gethostbyname+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
LIBS="-lnsl $LIBS -lpthread"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -16614,7 +16615,7 @@ if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then :
#define HAVE_LIBNSL 1
_ACEOF
LIBS="-lnsl $LIBS"
LIBS="-lnsl $LIBS -lpthread"
fi
@@ -16624,7 +16625,7 @@ if ${ac_cv_lib_rt_nanosleep+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lrt $LIBS"
LIBS="-lrt $LIBS -lpthread"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -16659,7 +16660,7 @@ if test "x$ac_cv_lib_rt_nanosleep" = xyes; then :
#define HAVE_LIBRT 1
_ACEOF
LIBS="-lrt $LIBS"
LIBS="-lrt $LIBS -lpthread"
fi

View File

@@ -73,7 +73,8 @@ get_interface(interface_list_t *list, const char *alias)
} while (ptr != NULL);
} else {
name = (char *)safe_malloc(strlen(alias) + 1);
strlcpy(name, alias, sizeof(name));
memset(name, 0, strlen(alias) + 1);
strncpy(name, alias, strlen(alias) + 1);
return(name);
}

View File

@@ -1097,7 +1097,7 @@ int stream_burst_marsio_init(void)
tcpburst_marsio4_vdev = marsio_open_device(tcpburst_marsio4_instance, marsio_send_device, 0/* rx_stream */, 1 /* tx_stream */);
if(NULL == tcpburst_marsio4_vdev) {
fprintf(stderr,"%s\n","marsio_open_device() error!\n");
fprintf(stderr,"%s\n","marsio_open_device %s error!\n", marsio_send_device);
exit(1);
}
@@ -1799,6 +1799,7 @@ replay_file(int file_idx)
#endif
if(1 == send_pkt_driver_mode){
if (pcap != NULL) {
dlt = sendpacket_get_dlt(options.intf1);
if ((dlt > 0) && (dlt != pcap_datalink(pcap)))
@@ -1806,7 +1807,7 @@ replay_file(int file_idx)
path, pcap_datalink_val_to_name(pcap_datalink(pcap)),
options.intf1->device, pcap_datalink_val_to_name(dlt));
}
}
send_packets(pcap, file_idx);
if (pcap != NULL)
pcap_close(pcap);
@@ -2026,6 +2027,7 @@ post_args(void)
if (HAVE_OPT(PKTLEN))
warn("--pktlen may cause problems. Use with caution.");
if(1 == send_pkt_driver_mode){
if ((intname = get_interface(intlist, OPT_ARG(INTF1))) == NULL)
errx(-1, "Invalid interface name/alias: %s", OPT_ARG(INTF1));
@@ -2060,7 +2062,7 @@ post_args(void)
&options.comment);
safe_free(temp);
}
}
if (! HAVE_OPT(QUIET))
notice("sending out %s %s", options.intf1_name,
options.intf2_name == NULL ? "" : options.intf2_name);