More rewrite of prohibited APIs (sprintf, strcpy, strcat).
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 3 Feb 2008 15:38:20 +0000 (15:38 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 3 Feb 2008 15:38:20 +0000 (15:38 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24258 f5534014-38df-0310-8fa8-9805f1628bb7

30 files changed:
editcap.c
epan/dissectors/packet-cops.c
epan/filesystem.c
epan/prefs.c
print.c
strerror.c
tap-afpstat.c
tap-bootpstat.c
tap-camelcounter.c
tap-camelsrt.c
tap-dcerpcstat.c
tap-h225counter.c
tap-h225rassrt.c
tap-httpstat.c
tap-iostat.c
tap-mgcpstat.c
tap-protohierstat.c
tap-radiusstat.c
tap-rpcstat.c
tap-sctpchunkstat.c
tap-smbstat.c
tap-wspstat.c
tempfile.c
text2pcap.c
tshark.c
util.c
wiretap/catapult_dct2000.c
wiretap/network_instruments.c
wiretap/visual.c
wiretap/wtap.c

index 14fcdb84a28d511cf4212fdabd9053935a7f5fb6..53a184656d473e33c7c4f2962ff12ec1cc8152e1 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -394,6 +394,7 @@ int main(int argc, char *argv[])
   int split_packet_count = 0;
   int written_count = 0;
   char *filename;
+  size_t filenamelen;
   gboolean check_ts;
 #ifdef HAVE_PLUGINS
   char* init_progfile_dir_error;
@@ -618,11 +619,12 @@ int main(int argc, char *argv[])
       out_frame_type = wtap_file_encap(wth);
 
     if (split_packet_count > 0) {
-      filename = (char *) g_malloc(strlen(argv[optind+1]) + 20);
+      filenamelen = strlen(argv[optind+1]) + 20;
+      filename = (char *) g_malloc(filenamelen);
       if (!filename) {
         exit(5);
       }
-      sprintf(filename, "%s-%05d", argv[optind+1], 0);
+      snprintf(filename, filenamelen, "%s-%05d", argv[optind+1], 0);
     } else {
       filename = argv[optind+1];
     }
@@ -651,7 +653,7 @@ int main(int argc, char *argv[])
           exit(1);
         }
 
-        sprintf(filename, "%s-%05d",argv[optind+1], count / split_packet_count);
+        snprintf(filename, filenamelen, "%s-%05d",argv[optind+1], count / split_packet_count);
 
         if (verbose) {
           fprintf(stderr, "Continuing writing in file %s\n", filename);
index 181fa50beac9aa5e31f332f82bbc1a33aada50b1..3d73e32283bab4780e2d9333104308f1f7517e11 100644 (file)
@@ -2634,9 +2634,8 @@ cops_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 op
             val_to_str(code16,table_cops_dqos_transaction_id, "Unknown (0x%04x)"),code16);
 
      /* Write the right data into the 'info field' on the Gui */
-     g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
-     strncat(info,val_to_str(code16,table_cops_dqos_transaction_id, "Unknown"), sizeof(info)-strlen(info));
-     info[sizeof(info)-1] = '\0';
+     g_snprintf(info,sizeof(info),"COPS %-20s - %s",val_to_str(op_code,cops_op_code_vals, "Unknown"),
+               val_to_str(code16,table_cops_dqos_transaction_id, "Unknown"));
 
      if (check_col(pinfo->cinfo, COL_INFO)) {
           col_clear(pinfo->cinfo, COL_INFO);
@@ -3031,8 +3030,8 @@ cops_mm_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8
             val_to_str(code16,table_cops_mm_transaction_id, "Unknown (0x%04x)"),code16);
 
      /* Write the right data into the 'info field' on the Gui */
-     g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown"));
-     strncat(info,val_to_str(code16,table_cops_mm_transaction_id, "Unknown"), sizeof(info)-strlen(info));
+     g_snprintf(info,sizeof(info),"COPS %-20s - %s",val_to_str(op_code,cops_op_code_vals, "Unknown"),
+               val_to_str(code16,table_cops_mm_transaction_id, "Unknown"));
 
      if (check_col(pinfo->cinfo, COL_INFO)) {
           col_clear(pinfo->cinfo, COL_INFO);
index 7ad214e9a2d73832f6f33c866529ee6bad10d987..9194226aef6c9eb940530857ef7e45fd6cbc5ede 100644 (file)
@@ -386,10 +386,7 @@ init_progfile_dir(const char *arg0
                        return g_strdup_printf("getcwd failed: %s\n",
                            strerror(errno));
                }
-               path = g_malloc(strlen(curdir) + 1 + strlen(arg0) + 1);
-               strcpy(path, curdir);
-               strcat(path, "/");
-               strcat(path, arg0);
+               path = g_strdup_printf("%s/%s", curdir, arg0);
                g_free(curdir);
                prog_pathname = path;
        } else {
@@ -411,8 +408,8 @@ init_progfile_dir(const char *arg0
                                    + strlen(arg0) + 1);
                                memcpy(path, path_start, path_component_len);
                                path[path_component_len] = '\0';
-                               strcat(path, "/");
-                               strcat(path, arg0);
+                               strncat(path, "/", 2);
+                               strncat(path, arg0, strlen(arg0) + 1);
                                if (access(path, X_OK) == 0) {
                                        /*
                                         * Found it!
@@ -1140,9 +1137,7 @@ get_persdatafile_dir(void)
          /* the "My Captures" sub-directory is created (if it doesn't exist)
             by u3util.exe when the U3 Wireshark is first run */
 
-         szPath = g_malloc(strlen(u3devicedocumentpath) + strlen(U3_MY_CAPTURES) + 1);
-         strcpy(szPath, u3devicedocumentpath);
-         strcat(szPath, U3_MY_CAPTURES);
+         szPath = g_strdup_printf("%s%s", 3devicedocumentpath, U3_MY_CAPTURES);
 
          persdatafile_dir = szPath;
          return szPath;
@@ -1192,10 +1187,7 @@ get_home_dir(void)
                         * This is cached, so we don't need to worry about
                         * allocating multiple ones of them.
                         */
-                       homestring =
-                           g_malloc(strlen(homedrive) + strlen(homepath) + 1);
-                       strcpy(homestring, homedrive);
-                       strcat(homestring, homepath);
+                       homestring = g_strdup_printf("%s%s", homedrive, homepath);
 
                        /*
                         * Trim off any trailing slash or backslash.
index c5591d52b314dea083d02bf03369e7e69132b57d..babcaae1a04dcc895de8372b7370255234312388 100644 (file)
@@ -961,7 +961,7 @@ put_string_list(GList *sl)
         pref_str[cur_len] = '\n'; cur_len++;
         pref_str[cur_len] = '\t'; cur_len++;
       }
-      sprintf(&pref_str[cur_len], "\"%s\", ", quoted_str);
+      g_snprintf(&pref_str[cur_len], MAX_FMT_PREF_LEN - cur_len, "\"%s\", ", quoted_str);
       cur_pos += fmt_len;
       cur_len += fmt_len;
     }
diff --git a/print.c b/print.c
index 1272dfb5fb46a39154159ca2850f934e05a39db9..fc5df6c766a1055098b662a9cdbdad7580edfd70 100644 (file)
--- a/print.c
+++ b/print.c
@@ -718,9 +718,7 @@ print_hex_data(print_stream_t *stream, epan_dissect_t *edt)
                if (multiple_sources) {
                        name = src->name;
                        print_line(stream, 0, "");
-                       line = g_malloc(strlen(name) + 2);      /* <name>:\0 */
-                       strcpy(line, name);
-                       strcat(line, ":");
+                       line = g_strdup_printf("%s:", name);
                        print_line(stream, 0, line);
                        g_free(line);
                }
index 93cc02b9a31f05939d83b05a02c275c0a294e417..34dcad88bbe4a49c02be5495ed2607d7dd564e51 100644 (file)
@@ -35,7 +35,7 @@ strerror(int errnum)
        static char errbuf[5+1+11+1];   /* "Error %d" */
 
        if (errnum < 0 || errnum >= sys_nerr) {
-               sprintf(errbuf, "Error %d", errnum);
+               g_snprintf(errbuf, 18, "Error %d", errnum);
                return errbuf;
        } else
                return sys_errlist[errnum];
index 43bffbc5b9e3e6f6b028ea74293ef78ecb01f158..16dff8118d66abaa503ed69dff96263fe7ed0f46 100644 (file)
@@ -128,8 +128,7 @@ afpstat_init(const char *optarg, void* userdata _U_)
 
        ss=g_malloc(sizeof(afpstat_t));
        if(filter){
-               ss->filter=g_malloc(strlen(filter)+1);
-               strcpy(ss->filter, filter);
+               ss->filter=g_strdup(filter);
        } else {
                ss->filter=NULL;
        }
index 83d304091a86004c3f0f6529496dc6adada71c9b..1f23e441013dd59a25e5763dd8b9f300fdd61131 100644 (file)
@@ -152,8 +152,7 @@ dhcpstat_init(const char *optarg, void* userdata _U_)
        sp = g_malloc( sizeof(dhcpstat_t) );
        sp->hash = g_hash_table_new( g_str_hash, g_str_equal);
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
index fa489c1ace8b0693ff88866f2d15298d447188f9..0368465bcd78f0253b05985ee586a17e49b5f379 100644 (file)
@@ -104,8 +104,7 @@ static void camelcounter_init(const char *optarg, void* userdata _U_)
 
   p_camelcounter = g_malloc(sizeof(struct camelcounter_t));
   if(filter){
-    p_camelcounter->filter=g_malloc(strlen(filter)+1);
-    strcpy(p_camelcounter->filter,filter);
+    p_camelcounter->filter=g_strdup(filter);
   } else {
     p_camelcounter->filter=NULL;
   }
index 19bfbabc448324aea89e3c537bb86c05261ce759..a16635197ec3c992c6e71e6d50b5c6f42b6c12c9 100644 (file)
@@ -222,8 +222,7 @@ static void camelsrt_init(const char *optarg, void* userdata _U_)
 
   p_camelsrt = g_malloc(sizeof(struct camelsrt_t));
   if(filter){
-    p_camelsrt->filter=g_malloc(strlen(filter)+1);
-    strcpy(p_camelsrt->filter,filter);
+    p_camelsrt->filter=g_strdup(filter);
   } else {
     p_camelsrt->filter=NULL;
   }
index 1c4342975e9a02656472f7b7b8b47768deee312b..7bee236b7c4fba4e094ff13361d50cd71ac04111 100644 (file)
@@ -249,8 +249,7 @@ dcerpcstat_init(const char *optarg, void* userdata _U_)
        rs->ver=ver;
 
        if(filter){
-               rs->filter=g_malloc(strlen(filter)+1);
-               strcpy(rs->filter, filter);
+               rs->filter=g_strdup(filter);
        } else {
                rs->filter=NULL;
        }
index 5e6388b62d03adbcf0c010625c07fe60f4a53eeb..bafc80ba327345dc881ce719808fe55a9f4b6cfd 100644 (file)
@@ -363,8 +363,7 @@ h225counter_init(const char *optarg, void* userdata _U_)
        }
 
        hs = g_malloc(sizeof(h225counter_t));
-       hs->filter=g_malloc(strlen(filter)+1);
-       strcpy(hs->filter, filter);
+       hs->filter=g_strdup(filter);
 
        h225counter_reset(hs);
 
index 97ad22883f59088d1e2c7e436547e1be2c9f595e..385ccc4cf018775e601d383012d033123ec84c2d 100644 (file)
@@ -226,8 +226,7 @@ h225rassrt_init(const char *optarg, void* userdata _U_)
        }
 
        hs = g_malloc(sizeof(h225rassrt_t));
-       hs->filter=g_malloc(strlen(filter)+1);
-       strcpy(hs->filter, filter);
+       hs->filter=g_strdup(filter);
 
        h225rassrt_reset(hs);
 
index 073a35d92514c04c3534208af982649cb9bca2b7..7a611a95872c3b661404a0f6bea3f72e0632e262 100644 (file)
@@ -295,8 +295,7 @@ gtk_httpstat_init(const char *optarg,void* userdata _U_)
        
        sp = g_malloc( sizeof(httpstat_t) );
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
index 5833a46bf550f265a5f202752c9f15d77f1975e8..225af8254d46a5db506f785cc735880d01227750 100644 (file)
@@ -663,8 +663,7 @@ iostat_init(const char *optarg, void* userdata _U_)
                        if(pos==str){
                                register_io_tap(io, i, NULL);
                        } else if(pos==NULL) {
-                               tmp=g_malloc(strlen(str)+1);
-                               strcpy(tmp,str);
+                               tmp=g_strdup(str);
                                register_io_tap(io, i, tmp);
                        } else {
                                tmp=g_malloc((pos-str)+1);
index 5d5d96236f3941bd5c11b6c5991d80de280807a5..967f9d9260bd71ac8b9b9b6e732f22561d5caee2 100644 (file)
@@ -195,8 +195,7 @@ mgcpstat_init(const char *optarg, void* userdata _U_)
        }
 
        ms=g_malloc(sizeof(mgcpstat_t));
-       ms->filter=g_malloc(strlen(filter)+1);
-       strcpy(ms->filter, filter);
+       ms->filter=g_strdup(filter);
 
        for(i=0;i<NUM_TIMESTATS;i++) {
                ms->rtd[i].num=0;
index 415c2f0d71f5736a415fc5c86dfc98dad03e4332..7f897b930aec45b560d24da17a79ad887850a34d 100644 (file)
@@ -200,8 +200,7 @@ protohierstat_init(const char *optarg, void* userdata _U_)
        rs=new_phs_t(NULL);
 
        if(filter){
-               rs->filter=g_malloc(strlen(filter)+1);
-               strcpy(rs->filter, filter);
+               rs->filter=g_strdup(filter);
        } else {
                rs->filter=NULL;
        }
index 56f59792025346a725a96398fc8091aac3849e46..1730c04e427308309c3f8a4cf26dd8e26572cbfd 100644 (file)
@@ -184,19 +184,18 @@ radiusstat_init(const char *optarg, void* userdata _U_)
        }
 
        rs=g_malloc(sizeof(radiusstat_t));
-       rs->filter=g_malloc(strlen(filter)+1);
-       strcpy(rs->filter, filter);
+       rs->filter=g_strdup(filter);
 
        for(i=0;i<NUM_TIMESTATS;i++) {
                rs->rtd[i].num=0;
                rs->rtd[i].min_num=0;
                rs->rtd[i].max_num=0;
                rs->rtd[i].min.secs=0;
-        rs->rtd[i].min.nsecs=0;
-        rs->rtd[i].max.secs=0;
-        rs->rtd[i].max.nsecs=0;
-        rs->rtd[i].tot.secs=0;
-        rs->rtd[i].tot.nsecs=0;
+               rs->rtd[i].min.nsecs=0;
+               rs->rtd[i].max.secs=0;
+               rs->rtd[i].max.nsecs=0;
+               rs->rtd[i].tot.secs=0;
+               rs->rtd[i].tot.nsecs=0;
        }
 
        rs->open_req_num=0;
index b544abf50d3d8019dfa17a061bf4ba93d3056f3b..617ad77fa3b54470d72c99d648f3bd36686881d1 100644 (file)
@@ -293,8 +293,7 @@ rpcstat_init(const char *optarg, void* userdata _U_)
        rs->program=program;
        rs->version=version;
        if(filter){
-               rs->filter=g_malloc(strlen(filter)+1);
-               strcpy(rs->filter, filter);
+               rs->filter=g_strdup(filter);
        } else {
                rs->filter=NULL;
        }
index de060d53fd30ca388e198a8a9975032390a8c1f1..630d4f4c91fe1b134952f5e64b453fec457974d2 100644 (file)
@@ -233,10 +233,9 @@ sctpstat_init(const char *optarg, void* userdata _U_)
        }
 
        hs = g_malloc(sizeof(sctpstat_t));
-       hs->filter=g_malloc(strlen(filter)+1);
+       hs->filter=g_strdup(filter);
        hs->ep_list = NULL;
        hs->number_of_packets = 0;
-       strcpy(hs->filter, filter);
 
        sctpstat_reset(hs);
 
index aa0a2828be0bb77cec95fb379c732fc1c60808e6..5ddfaf65df92de11c06847a72a5109abafd8690b 100644 (file)
@@ -215,8 +215,7 @@ smbstat_init(const char *optarg,void* userdata _U_)
 
        ss=g_malloc(sizeof(smbstat_t));
        if(filter){
-               ss->filter=g_malloc(strlen(filter)+1);
-               strcpy(ss->filter, filter);
+               ss->filter=g_strdup(filter);
        } else {
                ss->filter=NULL;
        }
index 8080560b9feda921c86c04284b549349723d28d0..782ac82d34bf523b32679c08663a27e1e15b6804 100644 (file)
@@ -247,8 +247,7 @@ wspstat_init(const char *optarg, void* userdata _U_)
        sp->num_pdus = 16;
        sp->pdu_stats=g_malloc( (sp->num_pdus+1) * sizeof( wsp_pdu_t) );
        if(filter){
-               sp->filter=g_malloc(strlen(filter)+1);
-               strcpy(sp->filter,filter);
+               sp->filter=g_strdup(filter);
        } else {
                sp->filter=NULL;
        }
index 61495281ce822baebfbef1cb7aaca6c83806e91a..af922b6d416b30ecfa573b76e2d8e575165b00ea 100644 (file)
@@ -57,9 +57,7 @@ setup_tmpdir(const char *dir)
                return dir;
        }
        else {
-               newdir = g_malloc(len + 2);
-               strcpy(newdir, dir);
-               strcat(newdir, G_DIR_SEPARATOR_S);
+               newdir = g_strdup_printf("%s%s", dir, G_DIR_SEPARATOR_S);
                return newdir;
        }
 }
@@ -72,17 +70,14 @@ try_tempfile(char *namebuf, int namebuflen, const char *dir, const char *pfx)
        int old_umask;
        int tmp_fd;
 
+       g_snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
        if (namebuflen < namelen) {
-               /* Stick in a truncated name, so that if this error is
+               /* Stick with the truncated name, so that if this error is
                   reported with the file name, you at least get
                   something. */
-               g_snprintf(namebuf, namebuflen, "%s%s%s", dir, pfx, suffix);
                errno = ENAMETOOLONG;
                return -1;
        }
-       strcpy(namebuf, dir);
-       strcat(namebuf, pfx);
-       strcat(namebuf, suffix);
 
        /* The Single UNIX Specification doesn't say that "mkstemp()"
           creates the temporary file with mode rw-------, so we
index e8d1252f204ed4c1272aee5a1b9175e87b96feb4..c0d557f3460fe5933d6eeab751b1a6fdc883e712 100644 (file)
@@ -704,12 +704,12 @@ append_to_preamble(char *str)
     if (toklen != 0) {
         if (packet_preamble_len + toklen > PACKET_PREAMBLE_MAX_LEN)
             return;    /* no room to add the token to the preamble */
-        strcpy(&packet_preamble[packet_preamble_len], str);
+        strncpy(&packet_preamble[packet_preamble_len], str, PACKET_PREAMBLE_MAX_LEN - packet_preamble_len);
         packet_preamble_len += toklen;
        if (debug >= 2) {
                char *c;
                char xs[PACKET_PREAMBLE_MAX_LEN];
-               strcpy(xs, packet_preamble);
+               strncpy(xs, packet_preamble, PACKET_PREAMBLE_MAX_LEN);
                while ((c = strchr(xs, '\r')) != NULL) *c=' ';
                fprintf (stderr, "[[append_to_preamble: \"%s\"]]", xs);
        }
index 2d7deeb7d5c67c480480f634538950175bee08e6..0d9be652446d4c3865f7df67386f334a18bd8f96 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -449,12 +449,11 @@ add_decode_as(const gchar *cl_param)
   ftenum_t                      dissector_table_selector_type;
   struct protocol_name_search   user_protocol_name;
 
-/* The following code will allocate and copy the command-line options in a string pointed by decoded_param */
+  /* The following code will allocate and copy the command-line options in a string pointed by decoded_param */
 
   g_assert(cl_param);
-  decoded_param = g_malloc( sizeof(gchar) * (strlen(cl_param) + 1) ); /* Allocate enough space to have a working copy of the command-line parameter */
+  decoded_param = g_strdup(cl_param);
   g_assert(decoded_param);
-  strcpy(decoded_param, cl_param);
 
 
   /* The lines below will parse this string (modifying it) to extract all
diff --git a/util.c b/util.c
index 5a9c7b81c29e796509107dda32a815eec57178c8..2bf225bc12fca1e1706134cbbb99a7d50adcf0b7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -75,14 +75,14 @@ get_args_as_string(int argc, char **argv, int optind)
        /*
         * Now construct the string.
         */
-       strcpy(argstring, "");
+       argstring[0] = '\0';
        i = optind;
        for (;;) {
-               strcat(argstring, argv[i]);
+               strncat(argstring, argv[i], len - strlen(argstring));
                i++;
                if (i == argc)
                        break;
-               strcat(argstring, " ");
+               strncat(argstring, " ", len - strlen(argstring));
        }
        return argstring;
 }
index 16e3550781b5b78366b287cb544ab7eac56af5d4..39c0eb8c0c9035f9b847bfb15e651aa36b820811 100644 (file)
@@ -331,7 +331,7 @@ gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info _U_,
             char timestamp_string[32];
             gint64 *pkey = NULL;
 
-            sprintf(timestamp_string, "%d.%04d", seconds, useconds/100);
+            g_snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100);
 
             /* All packets go to Catapult DCT2000 stub dissector */
             wth->phdr.pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000;
@@ -470,7 +470,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
         int n;
         int stub_offset = 0;
         char timestamp_string[32];
-        sprintf(timestamp_string, "%d.%04d", seconds, useconds/100);
+        g_snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100);
 
         /* Make sure all packets go to catapult dct2000 dissector */
         wth->phdr.pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000;
index c36611ec3a7d349f1aca3594faa05c94a0be116c..96867377325a9dfe01b04fd230e9ada4aa633df9 100644 (file)
@@ -490,7 +490,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int
        time(&system_time);
        current_time = localtime(&system_time);
        memset(&comment, 0x00, sizeof(comment));
-       sprintf(comment, "This capture was saved from Wireshark on %s", asctime(current_time));
+       g_snprintf(comment, 64, "This capture was saved from Wireshark on %s", asctime(current_time));
 
        /* create the file header */
        if (fseek(wdh->fh, 0, SEEK_SET) == -1) {
@@ -498,7 +498,7 @@ gboolean network_instruments_dump_open(wtap_dumper *wdh, gboolean cant_seek, int
                return FALSE;
        }
        memset(&file_header, 0x00, sizeof(capture_file_header));
-       strcpy(file_header.observer_version, network_instruments_magic);
+       strncpy(file_header.observer_version, network_instruments_magic, 32);
        file_header.offset_to_first_packet = sizeof(capture_file_header) + sizeof(tlv_header) + strlen(comment);
        file_header.offset_to_first_packet = GUINT16_TO_LE(file_header.offset_to_first_packet);
        file_header.number_of_information_elements = 1;
index b2bfd19b0ad5fc773842eb07bb1220c4e135abdd..e4b449f6e93a61b47c9d811375185a2c91523344 100644 (file)
@@ -886,7 +886,7 @@ static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
     vfile_hdr.max_length = htoles(65535);
     vfile_hdr.file_flags = htoles(1);  /* indexes are present */
     vfile_hdr.file_version = htoles(1);
-    strcpy(vfile_hdr.description, "Wireshark file");
+    strncpy(vfile_hdr.description, "Wireshark file", 64);
 
     /* Translate the encapsulation type */
     switch (wdh->encap)
index 2ddb55bbfc16ff7b38640f05f85a5c67289e4e25..4544b3327207d7314386efead5f6072786969716 100644 (file)
@@ -495,14 +495,14 @@ const char
 #ifdef HAVE_LIBZ
                if (err >= WTAP_ERR_ZLIB_MIN && err <= WTAP_ERR_ZLIB_MAX) {
                        /* Assume it's a zlib error. */
-                       sprintf(errbuf, "Uncompression error: %s",
+                       g_snprintf(errbuf, 128, "Uncompression error: %s",
                            zError(err - WTAP_ERR_ZLIB));
                        return errbuf;
                }
 #endif
                wtap_errlist_index = -1 - err;
                if (wtap_errlist_index >= WTAP_ERRLIST_SIZE) {
-                       sprintf(errbuf, "Error %d", err);
+                       g_snprintf(errbuf, 128, "Error %d", err);
                        return errbuf;
                }
                if (wtap_errlist[wtap_errlist_index] == NULL)