diff options
author | Anders Broman <anders.broman@ericsson.com> | 2008-05-08 05:16:33 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2008-05-08 05:16:33 +0000 |
commit | 6d91aae2e1b011b85b7efc02cb385225bf0d0efa (patch) | |
tree | eb5566e364265e2626b7c14b7b6db0b0fb1be441 /wiretap | |
parent | 6ae13430946abfb589ea350265aa9ae8a0ec471a (diff) | |
download | wireshark-6d91aae2e1b011b85b7efc02cb385225bf0d0efa.tar.gz |
strncpy -> g_strlcpy
svn path=/trunk/; revision=25254
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/cosine.c | 7 | ||||
-rw-r--r-- | wiretap/iseries.c | 6 | ||||
-rw-r--r-- | wiretap/netscreen.c | 3 | ||||
-rw-r--r-- | wiretap/network_instruments.c | 2 | ||||
-rw-r--r-- | wiretap/visual.c | 2 | ||||
-rw-r--r-- | wiretap/vms.c | 5 |
6 files changed, 11 insertions, 14 deletions
diff --git a/wiretap/cosine.c b/wiretap/cosine.c index e43dc007d3..1cf77f6c4e 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -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; diff --git a/wiretap/iseries.c b/wiretap/iseries.c index b9441884eb..8c7b970b64 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -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, diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index 9a2bdee50e..b8b05d63c9 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -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 { diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 9686737732..edddba315e 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -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; diff --git a/wiretap/visual.c b/wiretap/visual.c index e4b449f6e9..7504ffa1cf 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -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) diff --git a/wiretap/vms.c b/wiretap/vms.c index 38fbb9e124..f834122897 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -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)) { |