strncpy -> g_strlcpy

svn path=/trunk/; revision=25254
This commit is contained in:
Anders Broman 2008-05-08 05:16:33 +00:00
parent 6ae1343094
commit 6d91aae2e1
6 changed files with 11 additions and 14 deletions

View 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;

View 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,

View 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 {

View 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;

View 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)

View 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)) {