diff options
author | Gerald Combs <gerald@wireshark.org> | 2005-09-08 15:01:16 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2005-09-08 15:01:16 +0000 |
commit | e0331bbb1c23aad02e6b0264e959cac4d180b84c (patch) | |
tree | 700ad4c405ea679ff40b6940238ecb5f993cbbb3 /asn1/camel | |
parent | d9c63f0fdd435373bd531305c3c04ff354bba8f5 (diff) |
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
Diffstat (limited to 'asn1/camel')
-rw-r--r-- | asn1/camel/camel.cnf | 15 | ||||
-rw-r--r-- | asn1/camel/packet-camel-template.c | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/asn1/camel/camel.cnf b/asn1/camel/camel.cnf index 3264f847b1..c06569ca4e 100644 --- a/asn1/camel/camel.cnf +++ b/asn1/camel/camel.cnf @@ -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 c[ 2*7 + 5] = ""; /*temporary container*/ - time[ 2*7 + 5 +1 ] = '\0'; + char time[CAMEL_DATE_AND_TIME_LEN]; + char c[CAMEL_DATE_AND_TIME_LEN]; /*temporary container*/ + /* 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]; @@ -195,6 +196,8 @@ tvbuff_t *parameter_tvb; time[16] = c[1]; time[17] = c[2]; time[18] = c[3]; + + time[CAMEL_DATE_AND_TIME_LEN - 1] = '\0'; /*start = 0, length = 7*/ @@ -204,8 +207,8 @@ tvbuff_t *parameter_tvb; 0, 7, time); - free (time); - return 7; /* 7 octetes eaten*/ + + return 7; /* 7 octets eaten*/ #.END diff --git a/asn1/camel/packet-camel-template.c b/asn1/camel/packet-camel-template.c index a3a760e499..f3136b9ccb 100644 --- a/asn1/camel/packet-camel-template.c +++ b/asn1/camel/packet-camel-template.c @@ -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; |