Rewrote to use g_strlcpy and g_strlcat.
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 2 Mar 2008 21:12:24 +0000 (21:12 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 2 Mar 2008 21:12:24 +0000 (21:12 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24531 f5534014-38df-0310-8fa8-9805f1628bb7

tap-iostat.c
tap-protocolinfo.c
util.c

index 225af8254d46a5db506f785cc735880d01227750..456b5cdf5b119e92f341655645bed9c181c90164 100644 (file)
@@ -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;
index dfaea88099fbdef8dc676a142601d63d7077cf09..4f9c4b934a0da526b9477934366f4785bcb2387a 100644 (file)
@@ -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;
        }
diff --git a/util.c b/util.c
index 2bf225bc12fca1e1706134cbbb99a7d50adcf0b7..a9d7f5be5ac9becfa19ec8075b1ed769a42e474b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -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;
 }