Fix potential buffer overflows.

svn path=/trunk/; revision=2298
This commit is contained in:
Laurent Deniel 2000-08-19 18:20:59 +00:00
parent 69dce2464b
commit 8bc95e98e4
3 changed files with 14 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
* $Id: capture.c,v 1.119 2000/08/14 08:36:39 guy Exp $
* $Id: capture.c,v 1.120 2000/08/19 18:20:56 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -947,7 +947,7 @@ capture(void)
pcap_t *pch;
int pcap_encap;
int snaplen;
gchar err_str[PCAP_ERRBUF_SIZE], label_str[32];
gchar err_str[PCAP_ERRBUF_SIZE], label_str[64];
loop_data ld;
bpf_u_int32 netnum, netmask;
time_t upd_time, cur_time;
@ -1131,11 +1131,13 @@ capture(void)
default:
if (err < 0) {
sprintf(errmsg, "The file to which the capture would be"
snprintf(errmsg, sizeof(errmsg),
"The file to which the capture would be"
" saved (\"%s\") could not be opened: Error %d.",
cfile.save_file, err);
} else {
sprintf(errmsg, "The file to which the capture would be"
snprintf(errmsg, sizeof(errmsg),
"The file to which the capture would be"
" saved (\"%s\") could not be opened: %s.",
cfile.save_file, strerror(err));
}

7
file.c
View File

@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
* $Id: file.c,v 1.206 2000/08/15 21:03:16 deniel Exp $
* $Id: file.c,v 1.207 2000/08/19 18:20:58 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -412,8 +412,9 @@ read_cap_file(capture_file *cf, int *err)
break;
default:
sprintf(errmsg_errno, "An error occurred while reading the"
" capture file: %s.", wtap_strerror(*err));
snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while reading the"
" capture file: %s.", wtap_strerror(*err));
errmsg = errmsg_errno;
break;
}

View File

@ -1,6 +1,6 @@
/* tethereal.c
*
* $Id: tethereal.c,v 1.41 2000/08/14 08:36:41 guy Exp $
* $Id: tethereal.c,v 1.42 2000/08/19 18:20:59 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -1038,8 +1038,9 @@ file_open_error_message(int err, gboolean for_writing)
break;
default:
sprintf(errmsg_errno, "The file \"%%s\" could not be opened: %s.",
wtap_strerror(err));
snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be opened: %s.",
wtap_strerror(err));
errmsg = errmsg_errno;
break;
}