packet-fcswils.c: Fix incorrect use of g_snprintf return

packet-wccp.c: Fix incorrect use of g_snprintf return
packet-cops.c: Fix incorrect use of g_snprintf return value
packet-wtp.c: Fix incorrect use of g_snprintf return value


svn path=/trunk/; revision=17046
This commit is contained in:
Jörg Mayer 2006-01-17 10:56:06 +00:00
parent be27196e0a
commit f905ad1862
4 changed files with 43 additions and 21 deletions

View File

@ -1343,6 +1343,7 @@ static int decode_cops_pr_asn1_data(tvbuff_t *tvb,packet_info *pinfo, guint32 of
gchar *vb_display_string;
gchar *vb_display_string2;
size_t returned_length, str_index = 0;
#ifdef HAVE_NET_SNMP
struct variable_list variable;
@ -1350,7 +1351,6 @@ static int decode_cops_pr_asn1_data(tvbuff_t *tvb,packet_info *pinfo, guint32 of
#endif /* HAVE_NET_SNMP */
unsigned int i;
gchar *buf;
gint8 class;
gboolean pc, ind = 0;
gint32 ber_tag;
@ -1476,10 +1476,13 @@ static int decode_cops_pr_asn1_data(tvbuff_t *tvb,packet_info *pinfo, guint32 of
* to the end of the string.
*/
vb_display_string = ep_alloc(4*vb_length);
buf = vb_display_string;
buf += g_snprintf(buf, 4*vb_length, "%03u", vb_octet_string[0]);
returned_length = g_snprintf(vb_display_string, 4*vb_length, "%03u",
vb_octet_string[0]);
str_index += MIN(returned_length, 4*vb_length);
for (i = 1; i < vb_length; i++) {
buf += g_snprintf(buf, 4*vb_length-(buf-vb_display_string), ".%03u", vb_octet_string[i]);
returned_length = g_snprintf(&vb_display_string[str_index],
4*vb_length-str_index, ".%03u", vb_octet_string[i]);
str_index += MIN(returned_length, 4*vb_length-str_index);
}
proto_tree_add_text(tree, tvb, vb_value_start, length,
"Value: %s: %s", vb_type_name, vb_display_string);

View File

@ -770,21 +770,26 @@ dissect_swils_elp (tvbuff_t *tvb, proto_tree *elp_tree, guint8 isreq _U_)
flags="";
if (elp.cls1_svcparm[0] & 0x80) {
#define MAX_FLAGS_LEN 40
int stroff;
size_t stroff, returned_length;
flags=ep_alloc(MAX_FLAGS_LEN);
stroff = 0;
flags[stroff]=0;
stroff+=g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, "Class 1 Valid");
returned_length = g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff,
"Class 1 Valid");
stroff += MIN(returned_length, MAX_FLAGS_LEN-stroff);
if (elp.cls1_svcparm[0] & 0x40) {
stroff+=g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | IMX");
returned_length = g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | IMX");
stroff += MIN(returned_length, MAX_FLAGS_LEN-stroff);
}
if (elp.cls1_svcparm[0] & 0x20) {
stroff+=g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | IPS");
returned_length = g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | IPS");
stroff += MIN(returned_length, MAX_FLAGS_LEN-stroff);
}
if (elp.cls1_svcparm[0] & 0x10) {
stroff+=g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | LKS");
returned_length = g_snprintf (flags+stroff, MAX_FLAGS_LEN-stroff, " | LKS");
stroff += MIN(returned_length, MAX_FLAGS_LEN-stroff);
}
}
else {

View File

@ -1193,6 +1193,7 @@ dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
int i;
char *flags_string;
char *p;
size_t returned_length, str_index = 0;
char *buf;
if (capability_val_len != 4) {
@ -1206,13 +1207,16 @@ dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
#define FLAGS_STRING_LEN (128+1)
flags_string=ep_alloc(FLAGS_STRING_LEN);
flags_string[0] = 0;
p = flags_string;
for (i = 0; flags[i].short_name != NULL; i++) {
if (capability_val & flags[i].value) {
if (p != flags_string) {
p+=g_snprintf(p, FLAGS_STRING_LEN-(p-flags_string), ",");
if (str_index != 0) {
returned_length = g_snprintf(&flags_string[str_index],
FLAGS_STRING_LEN-str_index, ",");
str_index += MIN(returned_length, FLAGS_STRING_LEN-str_index);
}
p+=g_snprintf(p, FLAGS_STRING_LEN-(p-flags_string), "%s", flags[i].short_name);
returned_length = g_snprintf(&flags_string[str_index],
FLAGS_STRING_LEN-str_index, "%s", flags[i].short_name);
str_index += MIN(returned_length, FLAGS_STRING_LEN-str_index);
}
}
tm = proto_tree_add_text(element_tree, tvb, curr_offset+4, 4,
@ -1225,12 +1229,14 @@ dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
for (i = 0; flags[i].long_name != NULL; i++) {
p = decode_bitfield_value(buf, capability_val,
flags[i].value, 32);
p+=g_snprintf(p, BUF_SIZE-(p-buf), "%s: %s",
flags[i].long_name,
str_index = MIN(p-buf, BUF_SIZE);
returned_length = g_snprintf(&flags_string[str_index], BUF_SIZE-str_index,
"%s: %s", flags[i].long_name,
(capability_val & flags[i].value)?
"Supported":
"Not supported"
);
str_index += MIN(returned_length, BUF_SIZE-str_index);
proto_tree_add_text(method_tree, tvb, curr_offset+4, 4,
"%s", buf);
}

View File

@ -307,8 +307,9 @@ wtp_handle_tpi(proto_tree *tree, tvbuff_t *tvb)
static void
dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
char *szInfo, *buf;
char *szInfo;
int offCur = 0; /* current offset from start of WTP data */
size_t returned_length, str_index = 0;
unsigned char b0;
@ -398,8 +399,9 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
#endif
/* Develop the string to put in the Info column */
buf = szInfo + g_snprintf(szInfo, SZINFO_SIZE, "WTP %s",
returned_length = g_snprintf(szInfo, SZINFO_SIZE, "WTP %s",
val_to_str(pdut, vals_wtp_pdu_type, "Unknown PDU type 0x%x"));
str_index += MIN(returned_length, SZINFO_SIZE-str_index);
switch (pdut) {
case INVOKE:
@ -407,7 +409,9 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
TID = tvb_get_ntohs(tvb, offCur + 1);
psn = 0;
clsTransaction = transaction_class(tvb_get_guint8(tvb, offCur + 3));
buf += g_snprintf(buf, SZINFO_SIZE-(buf-szInfo), " Class %d", clsTransaction);
returned_length = g_snprintf(&szInfo[str_index], SZINFO_SIZE-str_index,
" Class %d", clsTransaction);
str_index += MIN(returned_length, SZINFO_SIZE-str_index);
cbHeader = 4;
break;
@ -416,8 +420,11 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
fTTR = transmission_trailer(b0);
TID = tvb_get_ntohs(tvb, offCur + 1);
psn = tvb_get_guint8(tvb, offCur + 3);
if (psn != 0)
buf += g_snprintf(buf, SZINFO_SIZE-(buf-szInfo), " (%u)", psn);
if (psn != 0) {
returned_length = g_snprintf(&szInfo[str_index], SZINFO_SIZE-str_index,
" (%u)", psn);
str_index += MIN(returned_length, SZINFO_SIZE-str_index);
}
cbHeader = 4;
break;
@ -446,7 +453,8 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
break;
};
if (fRID) {
buf += g_snprintf(buf, SZINFO_SIZE-(buf-szInfo), " R" );
returned_length = g_snprintf(&szInfo[str_index], SZINFO_SIZE-str_index, " R" );
str_index += MIN(returned_length, SZINFO_SIZE-str_index);
};
/* In the interest of speed, if "tree" is NULL, don't do any work not
necessary to generate protocol tree items. */