forked from osmocom/wireshark
Make the "col_data" field in a "column_info" structure a pointer to an
array of "const char *" rather than to an array of "char *", and make the second argument of "col_set_str()" a "const char *" - there's no guarantee that "col_data" points to something you're allowed to modify. svn path=/trunk/; revision=12875
This commit is contained in:
parent
28bdc16f36
commit
467e33d1b1
|
@ -191,7 +191,7 @@ col_clear(column_info *cinfo, gint el)
|
|||
/* Use this if "str" points to something that will stay around (and thus
|
||||
needn't be copied). */
|
||||
void
|
||||
col_set_str(column_info *cinfo, gint el, gchar* str)
|
||||
col_set_str(column_info *cinfo, gint el, const gchar* str)
|
||||
{
|
||||
int i;
|
||||
int fence;
|
||||
|
@ -338,11 +338,11 @@ col_append_sep_fstr(column_info *cinfo, gint el, const gchar *separator,
|
|||
void
|
||||
col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int i;
|
||||
char orig_buf[COL_BUF_MAX_LEN];
|
||||
char *orig;
|
||||
size_t max_len;
|
||||
va_list ap;
|
||||
int i;
|
||||
char orig_buf[COL_BUF_MAX_LEN];
|
||||
const char *orig;
|
||||
size_t max_len;
|
||||
|
||||
g_assert(cinfo->col_first[el] >= 0);
|
||||
if (el == COL_INFO)
|
||||
|
@ -354,12 +354,12 @@ col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...)
|
|||
for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) {
|
||||
if (cinfo->fmt_matx[i][el]) {
|
||||
if (cinfo->col_data[i] != cinfo->col_buf[i]) {
|
||||
/* This was set with "col_set_str()"; which is effectively const */
|
||||
/* This was set with "col_set_str()"; which is effectively const */
|
||||
orig = cinfo->col_data[i];
|
||||
} else {
|
||||
strncpy(orig_buf, cinfo->col_buf[i], max_len);
|
||||
orig_buf[max_len - 1] = '\0';
|
||||
orig = orig_buf;
|
||||
strncpy(orig, cinfo->col_buf[i], max_len);
|
||||
orig[max_len - 1] = '\0';
|
||||
}
|
||||
vsnprintf(cinfo->col_buf[i], max_len, format, ap);
|
||||
cinfo->col_buf[i][max_len - 1] = '\0';
|
||||
|
|
|
@ -31,18 +31,18 @@
|
|||
#define COL_MAX_INFO_LEN 4096
|
||||
|
||||
typedef struct _column_info {
|
||||
gint num_cols; /* Number of columns */
|
||||
gint *col_fmt; /* Format of column */
|
||||
gboolean **fmt_matx; /* Specifies which formats apply to a column */
|
||||
gint *col_first; /* First column number with a given format */
|
||||
gint *col_last; /* Last column number with a given format */
|
||||
gchar **col_title; /* Column titles */
|
||||
gchar **col_data; /* Column data */
|
||||
gchar **col_buf; /* Buffer into which to copy data for column */
|
||||
int *col_fence; /* Stuff in column buffer before this index is immutable */
|
||||
gchar **col_expr; /* Filter expression */
|
||||
gchar **col_expr_val; /* Value for filter expression */
|
||||
gboolean writable; /* Are we stil writing to the columns? */
|
||||
gint num_cols; /* Number of columns */
|
||||
gint *col_fmt; /* Format of column */
|
||||
gboolean **fmt_matx; /* Specifies which formats apply to a column */
|
||||
gint *col_first; /* First column number with a given format */
|
||||
gint *col_last; /* Last column number with a given format */
|
||||
gchar **col_title; /* Column titles */
|
||||
const gchar **col_data; /* Column data */
|
||||
gchar **col_buf; /* Buffer into which to copy data for column */
|
||||
int *col_fence; /* Stuff in column buffer before this index is immutable */
|
||||
gchar **col_expr; /* Filter expression */
|
||||
gchar **col_expr_val; /* Value for filter expression */
|
||||
gboolean writable; /* Are we stil writing to the columns? */
|
||||
} column_info;
|
||||
|
||||
/*
|
||||
|
|
|
@ -95,7 +95,7 @@ void new_window_cb(GtkWidget *w _U_)
|
|||
{
|
||||
#define NewWinTitleLen 1000
|
||||
char Title[NewWinTitleLen] = "";
|
||||
char *TextPtr;
|
||||
const char *TextPtr;
|
||||
gint tv_size = 95, bv_size = 75;
|
||||
GtkWidget *main_w, *main_vbox, *pane,
|
||||
*tree_view, *tv_scrollw,
|
||||
|
|
6
print.c
6
print.c
|
@ -76,7 +76,7 @@ static gboolean print_hex_data_buffer(print_stream_t *stream, const guchar *cp,
|
|||
guint length, char_enc encoding);
|
||||
static void ps_clean_string(unsigned char *out, const unsigned char *in,
|
||||
int outbuf_size);
|
||||
static void print_escaped_xml(FILE *fh, char *unescaped_string);
|
||||
static void print_escaped_xml(FILE *fh, const char *unescaped_string);
|
||||
|
||||
static void print_pdml_geninfo(proto_tree *tree, FILE *fh);
|
||||
|
||||
|
@ -561,9 +561,9 @@ get_field_data(GSList *src_list, field_info *fi)
|
|||
/* Print a string, escaping out certain characters that need to
|
||||
* escaped out for XML. */
|
||||
static void
|
||||
print_escaped_xml(FILE *fh, char *unescaped_string)
|
||||
print_escaped_xml(FILE *fh, const char *unescaped_string)
|
||||
{
|
||||
unsigned char *p;
|
||||
const unsigned char *p;
|
||||
|
||||
for (p = unescaped_string; *p != '\0'; p++) {
|
||||
switch (*p) {
|
||||
|
|
Loading…
Reference in New Issue