strncpy -> g_strlcpy
authorAnders Broman <anders.broman@ericsson.com>
Thu, 8 May 2008 05:16:33 +0000 (05:16 -0000)
committerAnders Broman <anders.broman@ericsson.com>
Thu, 8 May 2008 05:16:33 +0000 (05:16 -0000)
svn path=/trunk/; revision=25254

wiretap/cosine.c
wiretap/iseries.c
wiretap/netscreen.c
wiretap/network_instruments.c
wiretap/visual.c
wiretap/vms.c

index e43dc007d33aa89713a95fb25e9567dc0a36c353..1cf77f6c4e37a853f0902ec51cc96d1fb198046b 100644 (file)
@@ -218,8 +218,7 @@ static gint64 cosine_seek_next_packet(wtap *wth, int *err, char *hdr)
                if (file_gets(buf, sizeof(buf), wth->fh) != NULL) {
                        if (strstr(buf, COSINE_REC_MAGIC_STR1) ||
                            strstr(buf, COSINE_REC_MAGIC_STR2)) {
-                               strncpy(hdr, buf, COSINE_LINE_LENGTH-1);
-                               hdr[COSINE_LINE_LENGTH-1] = '\0';
+                               g_strlcpy(hdr, buf, COSINE_LINE_LENGTH);
                                return cur_off;
                        }
                } else {
@@ -449,8 +448,8 @@ parse_cosine_rec_hdr(wtap *wth, const char *line,
        } else if (strncmp(direction, "l2-rx", 5) == 0) {
                pseudo_header->cosine.direction = COSINE_DIR_RX;
        }
-       strncpy(pseudo_header->cosine.if_name, if_name,
-               COSINE_MAX_IF_NAME_LEN - 1);
+       g_strlcpy(pseudo_header->cosine.if_name, if_name,
+               COSINE_MAX_IF_NAME_LEN);
        pseudo_header->cosine.pro = pro;
        pseudo_header->cosine.off = off;
        pseudo_header->cosine.pri = pri;
index b9441884eba360cf17912eebac5fe1b77ca18995..8c7b970b643978ee66b13cbec52286ae2c1121a2 100644 (file)
@@ -509,9 +509,9 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
          iseries_UNICODE_to_ASCII ((guint8 *)data, ISERIES_LINE_LENGTH);
        }
       /* look for packet header */
-      for (i=0; i<8; i++) {      
-       if (strncmp(data+i,"*",1) == 0)
-         strncpy(data+i," ",1);
+      for (i=0; i<8; i++) {
+                 if (strncmp(data+i,"*",1) == 0)
+                         g_strlcpy(data+i," ",(ISERIES_LINE_LENGTH * 2));
       }
       num_items_scanned =
        sscanf (data,
index 9a2bdee50eca6e961cdf783c7d1fd8d161d10143..b8b05d63c9c179731fe188ebb7f57627777b729f 100644 (file)
@@ -127,8 +127,7 @@ static gint64 netscreen_seek_next_packet(wtap *wth, int *err, char *hdr)
                if (file_gets(buf, sizeof(buf), wth->fh) != NULL) {
                        if (strstr(buf, NETSCREEN_REC_MAGIC_STR1) ||
                            strstr(buf, NETSCREEN_REC_MAGIC_STR2)) {
-                               strncpy(hdr, buf, NETSCREEN_LINE_LENGTH-1);
-                               hdr[NETSCREEN_LINE_LENGTH-1] = '\0';
+                               g_strlcpy(hdr, buf, NETSCREEN_LINE_LENGTH);
                                return cur_off;
                        }
                } else {
index 96867377325a9dfe01b04fd230e9ada4aa633df9..edddba315edb7de908d0635258adf5efac239b37 100644 (file)
@@ -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));
-       strncpy(file_header.observer_version, network_instruments_magic, 32);
+       g_strlcpy(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 e4b449f6e93a61b47c9d811375185a2c91523344..7504ffa1cf5dafed91faf9fdaab6b4fef9edc064 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);
-    strncpy(vfile_hdr.description, "Wireshark file", 64);
+    g_strlcpy(vfile_hdr.description, "Wireshark file", 64);
 
     /* Translate the encapsulation type */
     switch (wdh->encap)
index 38fbb9e124efa761b0ee5c283cf4224d17850fea..f834122897540a64d4a69ac3d2e0bfc5404fc526 100644 (file)
@@ -174,9 +174,8 @@ static long vms_seek_next_packet(wtap *wth, int *err)
       if (strstr(buf, VMS_REC_MAGIC_STR1) ||
          strstr(buf, VMS_REC_MAGIC_STR2) ||
          strstr(buf, VMS_REC_MAGIC_STR2)) {
-       strncpy(hdr, buf, VMS_LINE_LENGTH-1);
-       hdr[VMS_LINE_LENGTH-1] = '\0';
-       return cur_off;
+                 g_strlcpy(hdr, buf,VMS_LINE_LENGTH);
+                 return cur_off;
       }
     } else {
       if (file_eof(wth->fh)) {