ir247_ias_fix_max.diff
PATCH 1/1 ir247_ias_fix_max.diff
ir247_ias_fix_max.diff :
----------------------
o [CRITICA] Check overflow in string duplicate code in IAS/IAP
- It was only done (more or less) if DEBUG was enabled
o [CORRECT] Fix deadlock on legal large OCT_SEQ IAP replies
o [CORRECT] Increase max IAS attribute size for IrDA compliance
include/linux/irda.h renamed from include/linux/irda.d8.h +11 -6
@@ -92,10 +92,15 @@ enum {#define IRTTP_MAX_SDU_SIZE IRLMP_MAX_SDU_SIZE/* Compatibility */ -#define IAS_MAX_STRING 256 -#define IAS_MAX_OCTET_STRING 1024 -#define IAS_MAX_CLASSNAME 64 -#define IAS_MAX_ATTRIBNAME 256 +#define IAS_MAX_STRING 256/* See IrLMP 1.1, 4.3.3.2 */ +#define IAS_MAX_OCTET_STRING 1024/* See IrLMP 1.1, 4.3.3.2 */ +#define IAS_MAX_CLASSNAME 60/* See IrLMP 1.1, 4.3.1 */ +#define IAS_MAX_ATTRIBNAME 60/* See IrLMP 1.1, 4.3.3.1 */ +#define IAS_MAX_ATTRIBNUMBER 256/* See IrLMP 1.1, 4.3.3.1 */ +/* For user space backward compatibility - may be fixed in kernel 2.5.X +* Note : need 60+1 ('\0'), make it 64 for alignement - Jean II */ +#define IAS_EXPORT_CLASSNAME 64 +#define IAS_EXPORT_ATTRIBNAME 256/* Attribute type needed for struct irda_ias_set */ #define IAS_MISSING 0
@@ -126,8 +131,8 @@ struct irda_device_list { };struct irda_ias_set { -char irda_class_name[IAS_MAX_CLASSNAME ]; -char irda_attrib_name[IAS_MAX_ATTRIBNAME ]; +char irda_class_name[IAS_EXPORT_CLASSNAME ]; +char irda_attrib_name[IAS_EXPORT_ATTRIBNAME ];unsigned int irda_attrib_type;union {unsigned int irda_attrib_int;
include/net/irda/irias_object.h renamed from include/net/irda/irias_object.d8.h +1 -1
@@ -78,7 +78,7 @@ struct ias_attrib {struct ias_value *value;/* Attribute value */ }; -char *strdup (char *str); +char *strndup (char *str,int max);struct ias_object *irias_new_object (char *name,int id);void irias_insert_object (struct ias_object *obj);
net/irda/irias_object.c renamed from net/irda/irias_object.d8.c +34 -16
122 lines not on this page · raw message
net/irda/iriap.c renamed from net/irda/iriap.d8.c +12 -12
@@ -379,7 +379,7 @@ int iriap_getvaluebyclass_request(struct char *name, char *attr) { struct sk_buff *skb; -int name_len, attr_len; +int name_len, attr_len, skb_len;__u8 *frame; ASSERT(self != NULL, return -1;);
@@ -400,13 +400,14 @@ int iriap_getvaluebyclass_request(struct/* Give ourselves 10 secs to finish this operation */ iriap_start_watchdog_timer (self,10 *HZ ); - skb =dev_alloc_skb (64 ); + name_len =strlen (name);/* Up to IAS_MAX_CLASSNAME = 60 */ + attr_len =strlen (attr);/* Up to IAS_MAX_ATTRIBNAME = 60 */ + + skb_len = self->max_header_size+2 +name_len+1 +attr_len+4 ; + skb =dev_alloc_skb (skb_len);if (!skb)return -ENOMEM ; - name_len =strlen (name); - attr_len =strlen (attr); -/* Reserve space for MUX and LAP header */ skb_reserve (skb, self->max_header_size);skb_put (skb,3 +name_len+attr_len);
@@ -500,20 +501,19 @@ void iriap_getvaluebyclass_confirm(struc } value_len = fp[n++];IRDA_DEBUG (4 , __FUNCTION__"(), strlen=%d\n" , value_len); - ASSERT(value_len < 64, return;);/* Make sure the string is null-terminated */ fp[n+value_len] =0x00 ; -IRDA_DEBUG (4 ,"Got string %s\n" , fp+n); + +/* Will truncate to IAS_MAX_STRING bytes */ value =irias_new_string_value (fp+n);break ;case IAS_OCT_SEQ : value_len =be16_to_cpu (get_unaligned ((__u16 *)(fp+n))); n +=2 ; - ASSERT(value_len <= 55, return;); - +/* Will truncate to IAS_MAX_OCTET_STRING bytes */ value =irias_new_octseq_value (fp+n, value_len);break ;default :
@@ -635,8 +635,8 @@ void iriap_getvaluebyclass_indication(ststruct ias_attrib *attrib;int name_len;int attr_len; -char name[64 ]; -char attr[64 ]; +char name[IAS_MAX_CLASSNAME +1 ];/* 60 bytes */ +char attr[IAS_MAX_ATTRIBNAME +1 ];/* 60 bytes */ __u8 *fp;int n;
@@ -1013,7 +1013,7 @@ int irias_proc_read(char *buf, char **st attrib->value->t.string);break ;case IAS_OCT_SEQ : - len +=sprintf (buf+len,"octet sequence\n" ); + len +=sprintf (buf+len,"octet sequence (%d bytes)\n" , attrib->value->len);break ;case IAS_MISSING : len +=sprintf (buf+len,"missing\n" );