RE: [PATCH 3/4] Sim Access Profile Server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
Hi Johan,

>> +	val = (uint16_t *) &param->val;
>> +	maxmsgsize = ntohs(*val);
>
>Is this unaligned access safe?

In theory this is safe :) param-> val  should be always aligned to 4 bytes according to sap spec

struct sap_parameter {
	uint8_t id;
	uint8_t reserved;
	uint16_t len;
	uint8_t val[0];
	/*
	 * Padding bytes 0-3 bytes
	 */
} __attribute__ ((packed));

However, I tried
	maxmsgsize = ntohs(bt_get_unaligned((uint16_t *) &param->val));
and got gcc error: dereferencing type-punned pointer will break strict-aliasing rules.

Strange as it's already used in bluetoothd and it compiles without such errors. Do I missed something ?


Thanks for comments and  have a look on fixed patch.

/Waldek

Attachment: 0003-Sim-Access-Profile-Server.patch
Description: 0003-Sim-Access-Profile-Server.patch


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux