forked from osmocom/wireshark
Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.pespin/osmux-wip
parent
c5a19582e4
commit
fe5248717f
82
capinfos.c
82
capinfos.c
|
@ -335,53 +335,53 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
switch (tsprecision) {
|
||||
|
||||
case WTAP_TSPREC_SEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64,
|
||||
(gint64)timer->secs);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_DSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%01d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%01d",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 100000000);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_CSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%02d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%02d",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 10000000);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_MSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%03d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%03d",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 1000000);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_USEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%06d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%06d",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 1000);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_NSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%09d",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%09d",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"Unknown precision %d",
|
||||
tsprecision);
|
||||
break;
|
||||
|
@ -390,13 +390,13 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
} else {
|
||||
ti_tm = localtime(&timer->secs);
|
||||
if (ti_tm == NULL) {
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf, "Not representable");
|
||||
snprintf(time_string_buf, sizeof time_string_buf, "Not representable");
|
||||
return time_string_buf;
|
||||
}
|
||||
switch (tsprecision) {
|
||||
|
||||
case WTAP_TSPREC_SEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -407,7 +407,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_DSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d%s%01d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -420,7 +420,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_CSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d%s%02d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -433,7 +433,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_MSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d%s%03d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -446,7 +446,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_USEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d%s%06d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -459,7 +459,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_NSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%04d-%02d-%02d %02d:%02d:%02d%s%09d",
|
||||
ti_tm->tm_year + 1900,
|
||||
ti_tm->tm_mon + 1,
|
||||
|
@ -472,7 +472,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"Unknown precision %d",
|
||||
tsprecision);
|
||||
break;
|
||||
|
@ -481,7 +481,7 @@ absolute_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info)
|
|||
}
|
||||
}
|
||||
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf, "n/a");
|
||||
snprintf(time_string_buf, sizeof time_string_buf, "n/a");
|
||||
return time_string_buf;
|
||||
}
|
||||
|
||||
|
@ -505,16 +505,16 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
switch (tsprecision) {
|
||||
|
||||
case WTAP_TSPREC_SEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%s",
|
||||
(gint64)timer->secs,
|
||||
second,
|
||||
timer->secs == 1 ? "" : plural);
|
||||
break;
|
||||
|
||||
case WTAP_TSPREC_DSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%01d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%01d%s%s",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 100000000,
|
||||
|
@ -523,8 +523,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_CSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%02d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%02d%s%s",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 10000000,
|
||||
|
@ -533,8 +533,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_MSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%03d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%03d%s%s",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 1000000,
|
||||
|
@ -543,8 +543,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_USEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%06d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%06d%s%s",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs / 1000,
|
||||
|
@ -553,8 +553,8 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
break;
|
||||
|
||||
case WTAP_TSPREC_NSEC:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"G_GINT64_MODIFIER"d%s%09d%s%s",
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"%"PRId64"%s%09d%s%s",
|
||||
(gint64)timer->secs,
|
||||
decimal_point,
|
||||
timer->nsecs,
|
||||
|
@ -563,7 +563,7 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf,
|
||||
snprintf(time_string_buf, sizeof time_string_buf,
|
||||
"Unknown precision %d",
|
||||
tsprecision);
|
||||
break;
|
||||
|
@ -571,7 +571,7 @@ relative_time_string(nstime_t *timer, int tsprecision, capture_info *cf_info, gb
|
|||
return time_string_buf;
|
||||
}
|
||||
|
||||
g_snprintf(time_string_buf, sizeof time_string_buf, "n/a");
|
||||
snprintf(time_string_buf, sizeof time_string_buf, "n/a");
|
||||
return time_string_buf;
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
|
|||
if (cap_file_size) {
|
||||
printf ("File size: ");
|
||||
if (machine_readable) {
|
||||
printf ("%" G_GINT64_MODIFIER "d bytes\n", cf_info->filesize);
|
||||
printf ("%" PRId64 " bytes\n", cf_info->filesize);
|
||||
} else {
|
||||
size_string = format_size(cf_info->filesize, FORMAT_SIZE_UNIT_BYTES, 0);
|
||||
printf ("%s\n", size_string);
|
||||
|
@ -692,7 +692,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
|
|||
if (cap_data_size) {
|
||||
printf ("Data size: ");
|
||||
if (machine_readable) {
|
||||
printf ("%" G_GINT64_MODIFIER "u bytes\n", cf_info->packet_bytes);
|
||||
printf ("%" PRIu64 " bytes\n", cf_info->packet_bytes);
|
||||
} else {
|
||||
size_string = format_size(cf_info->packet_bytes, FORMAT_SIZE_UNIT_BYTES, 0);
|
||||
printf ("%s\n", size_string);
|
||||
|
@ -951,14 +951,14 @@ print_stats_table(const gchar *filename, capture_info *cf_info)
|
|||
if (cap_file_size) {
|
||||
putsep();
|
||||
putquote();
|
||||
printf("%" G_GINT64_MODIFIER "d", cf_info->filesize);
|
||||
printf("%" PRId64, cf_info->filesize);
|
||||
putquote();
|
||||
}
|
||||
|
||||
if (cap_data_size) {
|
||||
putsep();
|
||||
putquote();
|
||||
printf("%" G_GINT64_MODIFIER "u", cf_info->packet_bytes);
|
||||
printf("%" PRIu64, cf_info->packet_bytes);
|
||||
putquote();
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < (int) length; i++) {
|
||||
g_snprintf(str+(i*2), 3, "%02x", hash[i]);
|
||||
snprintf(str+(i*2), 3, "%02x", hash[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ if_info_get(const char *name)
|
|||
descr_size = sizeof (descr_prefix) + 10;
|
||||
description = g_malloc(descr_size);
|
||||
if (description != NULL) {
|
||||
g_snprintf(description, descr_size,
|
||||
snprintf(description, descr_size,
|
||||
"%s%ld", descr_prefix, busnum);
|
||||
}
|
||||
}
|
||||
|
@ -889,14 +889,14 @@ set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
|
|||
if (pcap_set_datalink(pcap_h, datalink) == 0)
|
||||
return TRUE; /* no error */
|
||||
set_datalink_err_str = pcap_geterr(pcap_h);
|
||||
g_snprintf(errmsg, (gulong) errmsg_len, "Unable to set data link type on interface '%s' (%s).",
|
||||
snprintf(errmsg, (gulong) errmsg_len, "Unable to set data link type on interface '%s' (%s).",
|
||||
name, set_datalink_err_str);
|
||||
/*
|
||||
* If the error isn't "XXX is not one of the DLTs supported by this device",
|
||||
* tell the user to tell the Wireshark developers about it.
|
||||
*/
|
||||
if (strstr(set_datalink_err_str, "is not one of the DLTs supported by this device") == NULL)
|
||||
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
|
||||
snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
|
||||
"%s", please_report_bug());
|
||||
else
|
||||
secondary_errmsg[0] = '\0';
|
||||
|
@ -1366,10 +1366,10 @@ open_capture_device_pcap_create(
|
|||
*/
|
||||
*open_status = CAP_DEVICE_OPEN_WARNING_GENERIC;
|
||||
if (status == PCAP_WARNING) {
|
||||
g_snprintf(*open_status_str, sizeof *open_status_str,
|
||||
snprintf(*open_status_str, sizeof *open_status_str,
|
||||
"Warning: %s", pcap_geterr(pcap_h));
|
||||
} else {
|
||||
g_snprintf(*open_status_str, sizeof *open_status_str,
|
||||
snprintf(*open_status_str, sizeof *open_status_str,
|
||||
"Warning: %s", pcap_statustostr(status));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -263,7 +263,7 @@ convert_errbuf_to_utf8(char *errbuf)
|
|||
}
|
||||
errbuf[PCAP_ERRBUF_SIZE - 1] = '\0';
|
||||
utf8_err = local_code_page_str_to_utf8(errbuf);
|
||||
g_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s", utf8_err);
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s", utf8_err);
|
||||
g_free(utf8_err);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ pcap_open_live(const char *a, int b, int c, int d, char *errbuf)
|
|||
{
|
||||
pcap_t *p;
|
||||
if (!has_wpcap) {
|
||||
g_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"unable to load Npcap or WinPcap (wpcap.dll); can't open %s to capture",
|
||||
a);
|
||||
return NULL;
|
||||
|
@ -409,7 +409,7 @@ pcap_open(const char *a, int b, int c, int d, struct pcap_rmtauth *e, char *errb
|
|||
{
|
||||
pcap_t *ret;
|
||||
if (!has_wpcap) {
|
||||
g_snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"unable to load Npcap or WinPcap (wpcap.dll); can't open %s to capture",
|
||||
a);
|
||||
return NULL;
|
||||
|
@ -563,7 +563,7 @@ pcap_statustostr(int a)
|
|||
}
|
||||
|
||||
/* XXX copy routine from pcap.c ??? */
|
||||
(void)g_snprintf(ebuf, sizeof ebuf, "Don't have pcap_statustostr(), can't translate error: %d", a);
|
||||
(void)snprintf(ebuf, sizeof ebuf, "Don't have pcap_statustostr(), can't translate error: %d", a);
|
||||
return(ebuf);
|
||||
|
||||
}
|
||||
|
|
|
@ -270,56 +270,56 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (capture_opts->has_autostop_filesize) {
|
||||
char sfilesize[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize);
|
||||
snprintf(sfilesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sfilesize);
|
||||
}
|
||||
|
||||
if (capture_opts->has_file_duration) {
|
||||
char sfile_duration[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(sfile_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->file_duration);
|
||||
snprintf(sfile_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->file_duration);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sfile_duration);
|
||||
}
|
||||
|
||||
if (capture_opts->has_file_interval) {
|
||||
char sfile_interval[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(sfile_interval, ARGV_NUMBER_LEN, "interval:%d",capture_opts->file_interval);
|
||||
snprintf(sfile_interval, ARGV_NUMBER_LEN, "interval:%d",capture_opts->file_interval);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sfile_interval);
|
||||
}
|
||||
|
||||
if (capture_opts->has_file_packets) {
|
||||
char sfile_packets[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(sfile_packets, ARGV_NUMBER_LEN, "packets:%d",capture_opts->file_packets);
|
||||
snprintf(sfile_packets, ARGV_NUMBER_LEN, "packets:%d",capture_opts->file_packets);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sfile_packets);
|
||||
}
|
||||
|
||||
if (capture_opts->has_ring_num_files) {
|
||||
char sring_num_files[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(sring_num_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->ring_num_files);
|
||||
snprintf(sring_num_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->ring_num_files);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sring_num_files);
|
||||
}
|
||||
|
||||
if (capture_opts->has_nametimenum) {
|
||||
char nametimenum[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-b");
|
||||
g_snprintf(nametimenum, ARGV_NUMBER_LEN, "nametimenum:2");
|
||||
snprintf(nametimenum, ARGV_NUMBER_LEN, "nametimenum:2");
|
||||
argv = sync_pipe_add_arg(argv, &argc, nametimenum);
|
||||
}
|
||||
|
||||
if (capture_opts->has_autostop_files) {
|
||||
char sautostop_files[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-a");
|
||||
g_snprintf(sautostop_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->autostop_files);
|
||||
snprintf(sautostop_files, ARGV_NUMBER_LEN, "files:%d",capture_opts->autostop_files);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sautostop_files);
|
||||
}
|
||||
} else {
|
||||
if (capture_opts->has_autostop_filesize) {
|
||||
char sautostop_filesize[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-a");
|
||||
g_snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize);
|
||||
snprintf(sautostop_filesize, ARGV_NUMBER_LEN, "filesize:%u",capture_opts->autostop_filesize);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sautostop_filesize);
|
||||
}
|
||||
}
|
||||
|
@ -327,14 +327,14 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (capture_opts->has_autostop_packets) {
|
||||
char scount[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-c");
|
||||
g_snprintf(scount, ARGV_NUMBER_LEN, "%d",capture_opts->autostop_packets);
|
||||
snprintf(scount, ARGV_NUMBER_LEN, "%d",capture_opts->autostop_packets);
|
||||
argv = sync_pipe_add_arg(argv, &argc, scount);
|
||||
}
|
||||
|
||||
if (capture_opts->has_autostop_duration) {
|
||||
char sautostop_duration[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-a");
|
||||
g_snprintf(sautostop_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->autostop_duration);
|
||||
snprintf(sautostop_duration, ARGV_NUMBER_LEN, "duration:%f",capture_opts->autostop_duration);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sautostop_duration);
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (interface_opts->extcap_fifo != NULL)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char *pipe = g_strdup_printf("%s%" G_GUINTPTR_FORMAT, EXTCAP_PIPE_PREFIX, interface_opts->extcap_pipe_h);
|
||||
char *pipe = g_strdup_printf("%s%" PRIuPTR, EXTCAP_PIPE_PREFIX, interface_opts->extcap_pipe_h);
|
||||
argv = sync_pipe_add_arg(argv, &argc, pipe);
|
||||
g_free(pipe);
|
||||
#else
|
||||
|
@ -375,7 +375,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (interface_opts->has_snaplen) {
|
||||
char ssnap[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-s");
|
||||
g_snprintf(ssnap, ARGV_NUMBER_LEN, "%d", interface_opts->snaplen);
|
||||
snprintf(ssnap, ARGV_NUMBER_LEN, "%d", interface_opts->snaplen);
|
||||
argv = sync_pipe_add_arg(argv, &argc, ssnap);
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
argv = sync_pipe_add_arg(argv, &argc, "-B");
|
||||
if(interface_opts->buffer_size == 0x00)
|
||||
interface_opts->buffer_size = DEFAULT_CAPTURE_BUFFER_SIZE;
|
||||
g_snprintf(buffer_size, ARGV_NUMBER_LEN, "%d", interface_opts->buffer_size);
|
||||
snprintf(buffer_size, ARGV_NUMBER_LEN, "%d", interface_opts->buffer_size);
|
||||
argv = sync_pipe_add_arg(argv, &argc, buffer_size);
|
||||
}
|
||||
#endif
|
||||
|
@ -419,7 +419,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (interface_opts->auth_type == CAPTURE_AUTH_PWD) {
|
||||
char sauth[256];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-A");
|
||||
g_snprintf(sauth, sizeof(sauth), "%s:%s",
|
||||
snprintf(sauth, sizeof(sauth), "%s:%s",
|
||||
interface_opts->auth_username,
|
||||
interface_opts->auth_password);
|
||||
argv = sync_pipe_add_arg(argv, &argc, sauth);
|
||||
|
@ -430,7 +430,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
if (interface_opts->sampling_method != CAPTURE_SAMP_NONE) {
|
||||
char ssampling[ARGV_NUMBER_LEN];
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-m");
|
||||
g_snprintf(ssampling, ARGV_NUMBER_LEN, "%s:%d",
|
||||
snprintf(ssampling, ARGV_NUMBER_LEN, "%s:%d",
|
||||
interface_opts->sampling_method == CAPTURE_SAMP_BY_COUNT ? "count" :
|
||||
interface_opts->sampling_method == CAPTURE_SAMP_BY_TIMER ? "timer" :
|
||||
"undef",
|
||||
|
@ -448,7 +448,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
#ifndef DEBUG_CHILD
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-Z");
|
||||
#ifdef _WIN32
|
||||
g_snprintf(control_id, ARGV_NUMBER_LEN, "%d", GetCurrentProcessId());
|
||||
snprintf(control_id, ARGV_NUMBER_LEN, "%d", GetCurrentProcessId());
|
||||
argv = sync_pipe_add_arg(argv, &argc, control_id);
|
||||
#else
|
||||
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
|
||||
|
@ -595,7 +595,7 @@ sync_pipe_start(capture_options *capture_opts, GPtrArray *capture_comments,
|
|||
dup2(sync_pipe[PIPE_WRITE], 2);
|
||||
ws_close(sync_pipe[PIPE_READ]);
|
||||
execv(argv[0], argv);
|
||||
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
||||
snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
||||
argv[0], g_strerror(errno));
|
||||
sync_pipe_errmsg_to_parent(2, errmsg, "");
|
||||
|
||||
|
@ -834,7 +834,7 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd,
|
|||
ws_close(sync_pipe[PIPE_READ]);
|
||||
ws_close(sync_pipe[PIPE_WRITE]);
|
||||
execv(argv[0], argv);
|
||||
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
||||
snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
||||
argv[0], g_strerror(errno));
|
||||
sync_pipe_errmsg_to_parent(2, errmsg, "");
|
||||
|
||||
|
@ -1965,7 +1965,7 @@ sync_pipe_signame(int sig)
|
|||
|
||||
default:
|
||||
/* Returning a static buffer is ok in the context we use it here */
|
||||
g_snprintf(sigmsg_buf, sizeof sigmsg_buf, "Signal %d", sig);
|
||||
snprintf(sigmsg_buf, sizeof sigmsg_buf, "Signal %d", sig);
|
||||
sigmsg = sigmsg_buf;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ iface_mon_event(void)
|
|||
return;
|
||||
}
|
||||
evd = (struct net_event_data *)&kem->event_data[0];
|
||||
g_snprintf(ifr_name, IFNAMSIZ, "%s%u", evd->if_name, evd->if_unit);
|
||||
snprintf(ifr_name, IFNAMSIZ, "%s%u", evd->if_name, evd->if_unit);
|
||||
|
||||
/*
|
||||
* Check type of event.
|
||||
|
|
|
@ -81,11 +81,11 @@ udp_term_stats_tree_packet(stats_tree *st, /* st as it was passed to us */
|
|||
|
||||
/* we then tick a node for this src_addr:src_port
|
||||
if the node doesn't exists it will be created */
|
||||
g_snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_src),udphdr->sport);
|
||||
snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_src),udphdr->sport);
|
||||
tick_stat_node(st, str, st_udp_term, FALSE);
|
||||
|
||||
/* same thing for dst */
|
||||
g_snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_dst),udphdr->dport);
|
||||
snprintf(str, sizeof(str),"%s:%u",address_to_str(&pinfo->net_dst),udphdr->dport);
|
||||
tick_stat_node(st, str, st_udp_term, FALSE);
|
||||
|
||||
return 1;
|
||||
|
|
156
dumpcap.c
156
dumpcap.c
|
@ -642,10 +642,10 @@ get_capture_device_open_failure_messages(cap_device_open_status open_status,
|
|||
char *secondary_errmsg,
|
||||
size_t secondary_errmsg_len)
|
||||
{
|
||||
g_snprintf(errmsg, (gulong) errmsg_len,
|
||||
snprintf(errmsg, (gulong) errmsg_len,
|
||||
"The capture session could not be initiated on capture device \"%s\" (%s).",
|
||||
iface, open_status_str);
|
||||
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, "%s",
|
||||
snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, "%s",
|
||||
get_pcap_failure_secondary_error_message(open_status, open_status_str));
|
||||
}
|
||||
|
||||
|
@ -725,7 +725,7 @@ show_filter_code(capture_options *capture_opts)
|
|||
/* OK, try to compile the capture filter. */
|
||||
if (!compile_capture_filter(interface_opts->name, pcap_h, &fcode,
|
||||
interface_opts->cfilter)) {
|
||||
g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_h));
|
||||
snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_h));
|
||||
pcap_close(pcap_h);
|
||||
report_cfilter_error(capture_opts, j, errmsg);
|
||||
return FALSE;
|
||||
|
@ -1363,7 +1363,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm
|
|||
|
||||
/* Skip the initial "TCP@" in the pipename. */
|
||||
if (ws_socket_ptoa(&sa, pipename + 4, DEF_TCP_PORT) < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated because"
|
||||
"\"%s\" is not a valid socket specification", pipename);
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1371,7 +1371,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm
|
|||
}
|
||||
|
||||
if ((fd = (int)socket(sa.ss_family, SOCK_STREAM, 0)) < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated because"
|
||||
" the socket couldn't be created due to the socket error: \n"
|
||||
#ifdef _WIN32
|
||||
|
@ -1388,7 +1388,7 @@ cap_open_socket(char *pipename, capture_src *pcap_src, char *errmsg, size_t errm
|
|||
else
|
||||
sa_len = sizeof(struct sockaddr_in);
|
||||
if (connect(fd, (struct sockaddr *)&sa, sa_len) < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated because"
|
||||
" the socket couldn't be connected due to the socket error: \n"
|
||||
#ifdef _WIN32
|
||||
|
@ -1447,14 +1447,14 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl)
|
|||
sz = pcap_src->cap_pipe_bytes_to_read - pcap_src->cap_pipe_bytes_read;
|
||||
while (bytes_read < sz) {
|
||||
if (fd == -1) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl, "Invalid file descriptor.");
|
||||
snprintf(errmsg, (gulong)errmsgl, "Invalid file descriptor.");
|
||||
pcap_src->cap_pipe_err = PIPNEXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
sel_ret = cap_pipe_select(fd);
|
||||
if (sel_ret < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Unexpected error from select: %s.", g_strerror(errno));
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
return -1;
|
||||
|
@ -1463,7 +1463,7 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl)
|
|||
sz-bytes_read, pcap_src->from_cap_socket);
|
||||
if (b <= 0) {
|
||||
if (b == 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file reading from pipe or socket.");
|
||||
pcap_src->cap_pipe_err = PIPEOF;
|
||||
} else {
|
||||
|
@ -1473,11 +1473,11 @@ cap_pipe_read_data_bytes(capture_src *pcap_src, char *errmsg, size_t errmsgl)
|
|||
*/
|
||||
DWORD lastError = WSAGetLastError();
|
||||
errno = lastError;
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error reading from pipe or socket: %s.",
|
||||
win32strerror(lastError));
|
||||
#else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error reading from pipe or socket: %s.",
|
||||
g_strerror(errno));
|
||||
#endif
|
||||
|
@ -1566,7 +1566,7 @@ cap_pipe_open_live(char *pipename,
|
|||
if (errno == ENOENT || errno == ENOTDIR)
|
||||
pcap_src->cap_pipe_err = PIPNEXIST;
|
||||
else {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated "
|
||||
"due to error getting information on pipe or socket: %s.", g_strerror(errno));
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1576,7 +1576,7 @@ cap_pipe_open_live(char *pipename,
|
|||
if (S_ISFIFO(pipe_stat.st_mode)) {
|
||||
fd = ws_open(pipename, O_RDONLY | O_NONBLOCK, 0000 /* no creation so don't matter */);
|
||||
if (fd == -1) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated "
|
||||
"due to error on pipe open: %s.", g_strerror(errno));
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1585,7 +1585,7 @@ cap_pipe_open_live(char *pipename,
|
|||
} else if (S_ISSOCK(pipe_stat.st_mode)) {
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated "
|
||||
"due to error on socket create: %s.", g_strerror(errno));
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1617,7 +1617,7 @@ cap_pipe_open_live(char *pipename,
|
|||
*/
|
||||
if (g_strlcpy(sa.sun_path, pipename, sizeof sa.sun_path) > sizeof sa.sun_path) {
|
||||
/* Path name too long */
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session coud not be initiated "
|
||||
"due to error on socket connect: Path name too long.");
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1626,7 +1626,7 @@ cap_pipe_open_live(char *pipename,
|
|||
}
|
||||
b = connect(fd, (struct sockaddr *)&sa, sizeof sa);
|
||||
if (b == -1) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session coud not be initiated "
|
||||
"due to error on socket connect: %s.", g_strerror(errno));
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1641,7 +1641,7 @@ cap_pipe_open_live(char *pipename,
|
|||
*/
|
||||
pcap_src->cap_pipe_err = PIPNEXIST;
|
||||
} else {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated because\n"
|
||||
"\"%s\" is neither an interface nor a socket nor a pipe.", pipename);
|
||||
pcap_src->cap_pipe_err = PIPERR;
|
||||
|
@ -1650,7 +1650,7 @@ cap_pipe_open_live(char *pipename,
|
|||
}
|
||||
|
||||
#else /* _WIN32 */
|
||||
if (sscanf(pipename, EXTCAP_PIPE_PREFIX "%" G_GUINTPTR_FORMAT, &extcap_pipe_handle) == 1)
|
||||
if (sscanf(pipename, EXTCAP_PIPE_PREFIX "%" PRIuPTR, &extcap_pipe_handle) == 1)
|
||||
{
|
||||
/* The client is already connected to extcap pipe.
|
||||
* We have inherited the handle from parent process.
|
||||
|
@ -1674,7 +1674,7 @@ cap_pipe_open_live(char *pipename,
|
|||
g_free(pncopy);
|
||||
|
||||
if (!pos) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session could not be initiated because\n"
|
||||
"\"%s\" is neither an interface nor a pipe.", pipename);
|
||||
pcap_src->cap_pipe_err = PIPNEXIST;
|
||||
|
@ -1691,7 +1691,7 @@ cap_pipe_open_live(char *pipename,
|
|||
break;
|
||||
|
||||
if (GetLastError() != ERROR_PIPE_BUSY) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session on \"%s\" could not be started "
|
||||
"due to error on pipe open: %s.",
|
||||
pipename, win32strerror(GetLastError()));
|
||||
|
@ -1700,7 +1700,7 @@ cap_pipe_open_live(char *pipename,
|
|||
}
|
||||
|
||||
if (!WaitNamedPipe(utf_8to16(pipename), 30 * 1000)) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The capture session on \"%s\" timed out during "
|
||||
"pipe open: %s.",
|
||||
pipename, win32strerror(GetLastError()));
|
||||
|
@ -1747,7 +1747,7 @@ cap_pipe_open_live(char *pipename,
|
|||
while (bytes_read < sizeof magic) {
|
||||
sel_ret = cap_pipe_select(fd);
|
||||
if (sel_ret < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Unexpected error from select: %s.",
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
|
@ -1761,10 +1761,10 @@ cap_pipe_open_live(char *pipename,
|
|||
|
||||
if (b <= 0) {
|
||||
if (b == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file on pipe magic during open.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error on pipe magic during open: %s.",
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
|
@ -1785,10 +1785,10 @@ cap_pipe_open_live(char *pipename,
|
|||
|
||||
if (pcap_src->cap_pipe_bytes_read <= 0) {
|
||||
if (pcap_src->cap_pipe_bytes_read == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file on pipe magic during open.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error on pipe magic during open: %s.",
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
|
@ -1841,9 +1841,9 @@ cap_pipe_open_live(char *pipename,
|
|||
default:
|
||||
/* Not a pcapng file, and either not a pcap type we know about
|
||||
or not a pcap file, either. */
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Data written to the pipe is neither in a supported pcap format nor in pcapng format.");
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
not_our_bug);
|
||||
goto error;
|
||||
}
|
||||
|
@ -1898,7 +1898,7 @@ pcap_pipe_open_live(int fd,
|
|||
while (bytes_read < sizeof(struct pcap_hdr)) {
|
||||
sel_ret = cap_pipe_select(fd);
|
||||
if (sel_ret < 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Unexpected error from select: %s.",
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
|
@ -1908,13 +1908,13 @@ pcap_pipe_open_live(int fd,
|
|||
pcap_src->from_cap_socket);
|
||||
if (b <= 0) {
|
||||
if (b == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file on pipe header during open.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error on pipe header during open: %s.",
|
||||
g_strerror(errno));
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl,
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsgl,
|
||||
"%s", not_our_bug);
|
||||
goto error;
|
||||
}
|
||||
|
@ -1927,13 +1927,13 @@ pcap_pipe_open_live(int fd,
|
|||
pipe_read_sync(pcap_src, hdr, sizeof(struct pcap_hdr));
|
||||
if (pcap_src->cap_pipe_bytes_read <= 0) {
|
||||
if (pcap_src->cap_pipe_bytes_read == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file on pipe header during open.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error on pipe header header during open: %s.",
|
||||
g_strerror(errno));
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
not_our_bug);
|
||||
goto error;
|
||||
}
|
||||
|
@ -1969,10 +1969,10 @@ pcap_pipe_open_live(int fd,
|
|||
}
|
||||
|
||||
if (hdr->version_major < 2) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"The old pcap format version %d.%d is not supported.",
|
||||
hdr->version_major, hdr->version_minor);
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsgl, "%s",
|
||||
not_our_bug);
|
||||
goto error;
|
||||
}
|
||||
|
@ -2016,10 +2016,10 @@ pcapng_read_shb(capture_src *pcap_src,
|
|||
sizeof(pcapng_section_header_block_t));
|
||||
if (pcap_src->cap_pipe_bytes_read <= 0) {
|
||||
if (pcap_src->cap_pipe_bytes_read == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file reading from pipe or socket.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error reading from pipe or socket: %s.",
|
||||
g_strerror(errno));
|
||||
return -1;
|
||||
|
@ -2069,13 +2069,13 @@ pcapng_read_shb(capture_src *pcap_src,
|
|||
#define OUR_ENDIAN "little"
|
||||
#define IFACE_ENDIAN "big"
|
||||
#endif
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Interface %u is " IFACE_ENDIAN " endian but we're " OUR_ENDIAN " endian.",
|
||||
pcap_src->interface_id);
|
||||
return -1;
|
||||
default:
|
||||
/* Not a pcapng type we know about, or not pcapng at all. */
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Unrecognized pcapng format or not pcapng data.");
|
||||
return -1;
|
||||
}
|
||||
|
@ -2229,10 +2229,10 @@ pcapng_pipe_open_live(int fd,
|
|||
sizeof(bh->block_total_length));
|
||||
if (pcap_src->cap_pipe_bytes_read <= 0) {
|
||||
if (pcap_src->cap_pipe_bytes_read == 0)
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"End of file reading from pipe or socket.");
|
||||
else
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Error reading from pipe or socket: %s.",
|
||||
g_strerror(errno));
|
||||
goto error;
|
||||
|
@ -2243,7 +2243,7 @@ pcapng_pipe_open_live(int fd,
|
|||
}
|
||||
#endif
|
||||
if ((bh->block_total_length & 0x03) != 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"block_total_length read from pipe is %u, which is not a multiple of 4.",
|
||||
bh->block_total_length);
|
||||
goto error;
|
||||
|
@ -2400,7 +2400,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er
|
|||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"pcap_pipe_dispatch: invalid state");
|
||||
result = PD_ERR;
|
||||
|
||||
|
@ -2425,7 +2425,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er
|
|||
* STATE_EXPECT_DATA) as that would not fit in the buffer and
|
||||
* instead stop with an error.
|
||||
*/
|
||||
g_snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)",
|
||||
snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)",
|
||||
ld->packets_captured+1, pcap_info->rechdr.hdr.incl_len);
|
||||
break;
|
||||
}
|
||||
|
@ -2492,7 +2492,7 @@ pcap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t er
|
|||
return -1;
|
||||
|
||||
case PD_PIPE_ERR:
|
||||
g_snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s",
|
||||
snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s",
|
||||
#ifdef _WIN32
|
||||
win32strerror(GetLastError()));
|
||||
#else
|
||||
|
@ -2636,7 +2636,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t
|
|||
break;
|
||||
|
||||
default:
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"pcapng_pipe_dispatch: invalid state");
|
||||
result = PD_ERR;
|
||||
|
||||
|
@ -2667,7 +2667,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t
|
|||
}
|
||||
|
||||
if ((bh->block_total_length & 0x03) != 0) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"Total length of pcapng block read from pipe is %u, which is not a multiple of 4.",
|
||||
bh->block_total_length);
|
||||
break;
|
||||
|
@ -2679,7 +2679,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t
|
|||
* STATE_EXPECT_DATA) as that would not fit in the buffer and
|
||||
* instead stop with an error.
|
||||
*/
|
||||
g_snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)",
|
||||
snprintf(errmsg, (gulong)errmsgl, "Frame %u too long (%d bytes)",
|
||||
ld->packets_captured+1, bh->block_total_length);
|
||||
break;
|
||||
}
|
||||
|
@ -2706,7 +2706,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t
|
|||
|
||||
/* The record always has at least the block total length following the header */
|
||||
if (bh->block_total_length < sizeof(pcapng_block_header_t)+sizeof(guint32)) {
|
||||
g_snprintf(errmsg, (gulong)errmsgl,
|
||||
snprintf(errmsg, (gulong)errmsgl,
|
||||
"malformed pcapng block_total_length < minimum");
|
||||
pcap_src->cap_pipe_err = PIPEOF;
|
||||
return -1;
|
||||
|
@ -2740,7 +2740,7 @@ pcapng_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, size_t
|
|||
return -1;
|
||||
|
||||
case PD_PIPE_ERR:
|
||||
g_snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s",
|
||||
snprintf(errmsg, (gulong)errmsgl, "Error reading from pipe: %s",
|
||||
#ifdef _WIN32
|
||||
win32strerror(GetLastError()));
|
||||
#else
|
||||
|
@ -2773,7 +2773,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
|
|||
|
||||
if ((use_threads == FALSE) &&
|
||||
(capture_opts->ifaces->len > 1)) {
|
||||
g_snprintf(errmsg, (gulong) errmsg_len,
|
||||
snprintf(errmsg, (gulong) errmsg_len,
|
||||
"Using threads is required for capturing on multiple interfaces.");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2783,7 +2783,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
|
|||
interface_opts = &g_array_index(capture_opts->ifaces, interface_options, i);
|
||||
pcap_src = g_new0(capture_src, 1);
|
||||
if (pcap_src == NULL) {
|
||||
g_snprintf(errmsg, (gulong) errmsg_len,
|
||||
snprintf(errmsg, (gulong) errmsg_len,
|
||||
"Could not allocate memory.");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3176,7 +3176,7 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err
|
|||
|
||||
if ((capture_opts->use_pcapng == FALSE) &&
|
||||
(capture_opts->ifaces->len > 1)) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"Using PCAPNG is required for capturing on multiple interfaces. Use the -n option.");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3232,12 +3232,12 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err
|
|||
/* We couldn't set up to write to the capture file. */
|
||||
/* XXX - use cf_open_error_message from tshark instead? */
|
||||
if (err < 0) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"The file to which the capture would be"
|
||||
" saved (\"%s\") could not be opened: Error %d.",
|
||||
capture_opts->save_file, err);
|
||||
} else {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"The file to which the capture would be"
|
||||
" saved (\"%s\") could not be opened: %s.",
|
||||
capture_opts->save_file, g_strerror(err));
|
||||
|
@ -3333,7 +3333,7 @@ capture_loop_dispatch(loop_data *ld,
|
|||
sel_ret = cap_pipe_select(pcap_src->cap_pipe_fd);
|
||||
if (sel_ret <= 0) {
|
||||
if (sel_ret < 0 && errno != EINTR) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"Unexpected error from select: %s", g_strerror(errno));
|
||||
report_capture_error(errmsg, please_report_bug());
|
||||
ld->go = FALSE;
|
||||
|
@ -3406,7 +3406,7 @@ capture_loop_dispatch(loop_data *ld,
|
|||
}
|
||||
} else {
|
||||
if (sel_ret < 0 && errno != EINTR) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"Unexpected error from select: %s", g_strerror(errno));
|
||||
report_capture_error(errmsg, please_report_bug());
|
||||
ld->go = FALSE;
|
||||
|
@ -3543,7 +3543,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
|
|||
if (capture_opts->output_to_pipe == TRUE) { /* either "-" or named pipe */
|
||||
if (capture_opts->multi_files_on) {
|
||||
/* ringbuffer is enabled; that doesn't work with standard output or a named pipe */
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"Ring buffer requested, but capture is being written to standard output or to a named pipe.");
|
||||
g_free(capfile_name);
|
||||
return FALSE;
|
||||
|
@ -3579,7 +3579,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
|
|||
}
|
||||
if (capture_opts->print_file_names) {
|
||||
if (!ringbuf_set_print_name(capture_opts->print_name_to, NULL)) {
|
||||
g_snprintf(errmsg, errmsg_len, "Could not write filenames to %s: %s.\n",
|
||||
snprintf(errmsg, errmsg_len, "Could not write filenames to %s: %s.\n",
|
||||
capture_opts->print_name_to,
|
||||
g_strerror(errno));
|
||||
g_free(capfile_name);
|
||||
|
@ -3673,7 +3673,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
|
|||
/* did we fail to open the output file? */
|
||||
if (*save_file_fd == -1) {
|
||||
if (is_tempfile) {
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"The temporary file to which the capture would be saved (\"%s\") "
|
||||
"could not be opened: %s.", capfile_name, err_tempfile->message);
|
||||
g_error_free(err_tempfile);
|
||||
|
@ -3685,7 +3685,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
|
|||
ringbuf_error_cleanup();
|
||||
}
|
||||
|
||||
g_snprintf(errmsg, errmsg_len,
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"The file to which the capture would be saved (\"%s\") "
|
||||
"could not be opened: %s.", capfile_name,
|
||||
g_strerror(errno));
|
||||
|
@ -3945,13 +3945,13 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
case INITFILTER_BAD_FILTER:
|
||||
cfilter_error = TRUE;
|
||||
error_index = i;
|
||||
g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_src->pcap_h));
|
||||
snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_src->pcap_h));
|
||||
goto error;
|
||||
|
||||
case INITFILTER_OTHER_ERROR:
|
||||
g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).",
|
||||
snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).",
|
||||
pcap_geterr(pcap_src->pcap_h));
|
||||
g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug());
|
||||
snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug());
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -4340,7 +4340,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
/* Let the parent process know. */
|
||||
pcap_dropped += stats->ps_drop;
|
||||
} else {
|
||||
g_snprintf(errmsg, sizeof(errmsg),
|
||||
snprintf(errmsg, sizeof(errmsg),
|
||||
"Can't get packet-drop statistics: %s",
|
||||
pcap_geterr(pcap_src->pcap_h));
|
||||
report_capture_error(errmsg, please_report_bug());
|
||||
|
@ -4415,44 +4415,44 @@ capture_loop_get_errmsg(char *errmsg, size_t errmsglen, char *secondary_errmsg,
|
|||
switch (err) {
|
||||
|
||||
case ENOSPC:
|
||||
g_snprintf(errmsg, (gulong)errmsglen,
|
||||
snprintf(errmsg, (gulong)errmsglen,
|
||||
"Not all the packets could be written to the file"
|
||||
" to which the capture was being saved\n"
|
||||
"(\"%s\") because there is no space left on the file system\n"
|
||||
"on which that file resides.",
|
||||
fname);
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s",
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s",
|
||||
find_space);
|
||||
break;
|
||||
|
||||
#ifdef EDQUOT
|
||||
case EDQUOT:
|
||||
g_snprintf(errmsg, (gulong)errmsglen,
|
||||
snprintf(errmsg, (gulong)errmsglen,
|
||||
"Not all the packets could be written to the file"
|
||||
" to which the capture was being saved\n"
|
||||
"(\"%s\") because you are too close to, or over,"
|
||||
" your disk quota\n"
|
||||
"on the file system on which that file resides.",
|
||||
fname);
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s",
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsglen, "%s",
|
||||
find_space);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
if (is_close) {
|
||||
g_snprintf(errmsg, (gulong)errmsglen,
|
||||
snprintf(errmsg, (gulong)errmsglen,
|
||||
"The file to which the capture was being saved\n"
|
||||
"(\"%s\") could not be closed: %s.",
|
||||
fname, g_strerror(err));
|
||||
} else {
|
||||
g_snprintf(errmsg, (gulong)errmsglen,
|
||||
snprintf(errmsg, (gulong)errmsglen,
|
||||
"An error occurred while writing to the file"
|
||||
" to which the capture was being saved\n"
|
||||
"(\"%s\"): %s.",
|
||||
fname, g_strerror(err));
|
||||
}
|
||||
g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen,
|
||||
snprintf(secondary_errmsg, (gulong)secondary_errmsglen,
|
||||
"%s", please_report_bug());
|
||||
break;
|
||||
}
|
||||
|
@ -4671,7 +4671,7 @@ capture_loop_queue_packet_cb(u_char *pcap_src_p, const struct pcap_pkthdr *phdr,
|
|||
}
|
||||
/* I don't want to hold the mutex over the debug output. So the
|
||||
output may be wrong */
|
||||
ws_info("Queue size is now %" G_GINT64_MODIFIER "d bytes (%" G_GINT64_MODIFIER "d packets)",
|
||||
ws_info("Queue size is now %" PRId64 " bytes (%" PRId64 " packets)",
|
||||
pcap_queue_bytes, pcap_queue_packets);
|
||||
}
|
||||
|
||||
|
@ -4728,7 +4728,7 @@ capture_loop_queue_pcapng_cb(capture_src *pcap_src, const pcapng_block_header_t
|
|||
}
|
||||
/* I don't want to hold the mutex over the debug output. So the
|
||||
output may be wrong */
|
||||
ws_info("Queue size is now %" G_GINT64_MODIFIER "d bytes (%" G_GINT64_MODIFIER "d packets)",
|
||||
ws_info("Queue size is now %" PRId64 " bytes (%" PRId64 " packets)",
|
||||
pcap_queue_bytes, pcap_queue_packets);
|
||||
}
|
||||
|
||||
|
@ -5622,7 +5622,7 @@ report_packet_count(unsigned int packet_count)
|
|||
static unsigned int count = 0;
|
||||
|
||||
if (capture_child) {
|
||||
g_snprintf(count_str, sizeof(count_str), "%u", packet_count);
|
||||
snprintf(count_str, sizeof(count_str), "%u", packet_count);
|
||||
ws_debug("Packets: %s", count_str);
|
||||
pipe_write_block(2, SP_PACKET_COUNT, count_str);
|
||||
} else {
|
||||
|
@ -5683,7 +5683,7 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
|
|||
|
||||
if (i < capture_opts->ifaces->len) {
|
||||
if (capture_child) {
|
||||
g_snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg);
|
||||
snprintf(tmp, sizeof(tmp), "%u:%s", i, errmsg);
|
||||
ws_debug("Capture filter error: %s", errmsg);
|
||||
pipe_write_block(2, SP_BAD_FILTER, tmp);
|
||||
} else {
|
||||
|
|