Fix more problems found by Steve Grubb, along with other changes:
Camel: Fix an off-by-one error. Don't alloc and free where it's not needed. Remove an unused variable. PPP and K12: Fix memory leaks. svn path=/trunk/; revision=15725
This commit is contained in:
parent
d9c63f0fdd
commit
e0331bbb1c
|
@ -131,10 +131,9 @@ tvbuff_t *parameter_tvb;
|
|||
|
||||
guint8 digit_pair;
|
||||
guint8 i = 0, curr_offset;
|
||||
char *time = (char *)(calloc (2*7 + 5 + 1, sizeof(char)));
|
||||
char time[CAMEL_DATE_AND_TIME_LEN];
|
||||
char c[CAMEL_DATE_AND_TIME_LEN]; /*temporary container*/
|
||||
|
||||
char c[ 2*7 + 5] = ""; /*temporary container*/
|
||||
time[ 2*7 + 5 +1 ] = '\0';
|
||||
/* 2 digits per octet, 7 octets total + 5 delimiters */
|
||||
|
||||
for (curr_offset = 0; curr_offset < 7 ; curr_offset++)
|
||||
|
@ -164,6 +163,8 @@ tvbuff_t *parameter_tvb;
|
|||
}
|
||||
|
||||
/* Pretty print date */
|
||||
/* XXX - Should we use sprintf here instead of assembling the string by
|
||||
* hand? */
|
||||
|
||||
time[0] = c[9];
|
||||
time[1] = c[8];
|
||||
|
@ -196,6 +197,8 @@ tvbuff_t *parameter_tvb;
|
|||
time[17] = c[2];
|
||||
time[18] = c[3];
|
||||
|
||||
time[CAMEL_DATE_AND_TIME_LEN - 1] = '\0';
|
||||
|
||||
/*start = 0, length = 7*/
|
||||
|
||||
proto_tree_add_string(tree,
|
||||
|
@ -204,8 +207,8 @@ tvbuff_t *parameter_tvb;
|
|||
0,
|
||||
7,
|
||||
time);
|
||||
free (time);
|
||||
return 7; /* 7 octetes eaten*/
|
||||
|
||||
return 7; /* 7 octets eaten*/
|
||||
|
||||
#.END
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ static const true_false_string camel_extension_value = {
|
|||
};
|
||||
#define EUROPEAN_DATE 1
|
||||
#define AMERICAN_DATE 2
|
||||
#define CAMEL_DATE_AND_TIME_LEN 20 /* 2*5 + 4 + 5 + 1 (HH:MM:SS;mm/dd/yyyy) */
|
||||
|
||||
static enum_val_t date_options[] = {
|
||||
{ "european", "DD/MM/YYYY", EUROPEAN_DATE },
|
||||
|
@ -505,7 +506,7 @@ static guint8 camel_pdu_size = 0;
|
|||
static int
|
||||
dissect_camel_camelPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
|
||||
|
||||
char *version_ptr, *version_str;
|
||||
char *version_ptr;
|
||||
|
||||
opcode = 0;
|
||||
application_context_version = 0;
|
||||
|
|
|
@ -651,6 +651,7 @@ static const true_false_string camel_extension_value = {
|
|||
};
|
||||
#define EUROPEAN_DATE 1
|
||||
#define AMERICAN_DATE 2
|
||||
#define CAMEL_DATE_AND_TIME_LEN 20 /* 2*5 + 4 + 5 + 1 (HH:MM:SS;mm/dd/yyyy) */
|
||||
|
||||
static enum_val_t date_options[] = {
|
||||
{ "european", "DD/MM/YYYY", EUROPEAN_DATE },
|
||||
|
@ -3232,10 +3233,9 @@ dissect_camel_DateAndTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
|
|||
|
||||
guint8 digit_pair;
|
||||
guint8 i = 0, curr_offset;
|
||||
char *time = (char *)(calloc (2*7 + 5 + 1, sizeof(char)));
|
||||
char time[CAMEL_DATE_AND_TIME_LEN];
|
||||
char c[CAMEL_DATE_AND_TIME_LEN]; /*temporary container*/
|
||||
|
||||
char c[ 2*7 + 5] = ""; /*temporary container*/
|
||||
time[ 2*7 + 5 +1 ] = '\0';
|
||||
/* 2 digits per octet, 7 octets total + 5 delimiters */
|
||||
|
||||
for (curr_offset = 0; curr_offset < 7 ; curr_offset++)
|
||||
|
@ -3265,6 +3265,8 @@ dissect_camel_DateAndTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
|
|||
}
|
||||
|
||||
/* Pretty print date */
|
||||
/* XXX - Should we use sprintf here instead of assembling the string by
|
||||
* hand? */
|
||||
|
||||
time[0] = c[9];
|
||||
time[1] = c[8];
|
||||
|
@ -3297,6 +3299,8 @@ dissect_camel_DateAndTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
|
|||
time[17] = c[2];
|
||||
time[18] = c[3];
|
||||
|
||||
time[CAMEL_DATE_AND_TIME_LEN - 1] = '\0';
|
||||
|
||||
/*start = 0, length = 7*/
|
||||
|
||||
proto_tree_add_string(tree,
|
||||
|
@ -3305,8 +3309,8 @@ dissect_camel_DateAndTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset,
|
|||
0,
|
||||
7,
|
||||
time);
|
||||
free (time);
|
||||
return 7; /* 7 octetes eaten*/
|
||||
|
||||
return 7; /* 7 octets eaten*/
|
||||
|
||||
|
||||
return offset;
|
||||
|
@ -6830,7 +6834,7 @@ static guint8 camel_pdu_size = 0;
|
|||
static int
|
||||
dissect_camel_camelPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) {
|
||||
|
||||
char *version_ptr, *version_str;
|
||||
char *version_ptr;
|
||||
|
||||
opcode = 0;
|
||||
application_context_version = 0;
|
||||
|
|
|
@ -3254,8 +3254,10 @@ remove_escape_chars(tvbuff_t *tvb, int offset, int length)
|
|||
scanned_len++;
|
||||
i++;
|
||||
}
|
||||
if (i == 0)
|
||||
if (i == 0) {
|
||||
g_free(buff);
|
||||
return NULL;
|
||||
}
|
||||
next_tvb = tvb_new_real_data(buff,i,i);
|
||||
|
||||
/* Arrange that the allocated packet data copy be freed when the
|
||||
|
|
|
@ -375,6 +375,7 @@ int k12_open(wtap *wth, int *err, gchar **err_info _U_) {
|
|||
|
||||
if (extra_len == 0 || name_len == 0 || stack_len == 0
|
||||
|| 0x20 + extra_len + name_len + stack_len > rec_len ) {
|
||||
g_free(rec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue