diff options
-rw-r--r-- | tap-iostat.c | 4 | ||||
-rw-r--r-- | tap-protocolinfo.c | 4 | ||||
-rw-r--r-- | util.c | 5 |
3 files changed, 7 insertions, 6 deletions
diff --git a/tap-iostat.c b/tap-iostat.c index 225af8254d..456b5cdf5b 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -37,6 +37,7 @@ #include "epan/packet_info.h" #include <epan/tap.h> #include <epan/stat_cmd_args.h> +#include <epan/strutil.h> #include "register.h" @@ -667,8 +668,7 @@ iostat_init(const char *optarg, void* userdata _U_) register_io_tap(io, i, tmp); } else { tmp=g_malloc((pos-str)+1); - strncpy(tmp,str,(pos-str)); - tmp[pos-str]=0; + g_strlcpy(tmp,str,(pos-str)+1); register_io_tap(io, i, tmp); } str=pos+1; diff --git a/tap-protocolinfo.c b/tap-protocolinfo.c index dfaea88099..4f9c4b934a 100644 --- a/tap-protocolinfo.c +++ b/tap-protocolinfo.c @@ -40,6 +40,7 @@ #include "epan/proto.h" #include <epan/tap.h> #include <epan/stat_cmd_args.h> +#include <epan/strutil.h> #include "register.h" typedef struct _pci_t { @@ -117,8 +118,7 @@ protocolinfo_init(const char *optarg, void* userdata _U_) rs->hf_index=hfi->id; if((field-filter)>1){ rs->filter=g_malloc(field-filter); - strncpy(rs->filter,filter,(field-filter)-1); - rs->filter[(field-filter)-1]=0; + g_strlcpy(rs->filter,filter,(field-filter)); } else { rs->filter=NULL; } @@ -40,6 +40,7 @@ #include <epan/address.h> #include <epan/addr_resolv.h> #include <epan/ws_strsplit.h> +#include <epan/strutil.h> #include "util.h" @@ -78,11 +79,11 @@ get_args_as_string(int argc, char **argv, int optind) argstring[0] = '\0'; i = optind; for (;;) { - strncat(argstring, argv[i], len - strlen(argstring)); + g_strlcat(argstring, argv[i], len); i++; if (i == argc) break; - strncat(argstring, " ", len - strlen(argstring)); + g_strlcat(argstring, " ", len); } return argstring; } |