Re: [PATCH BlueZ v2 02/12] storage: Store address type in "aliases" file

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

 



Hi Paulo,

On Tue, Jul 03, 2012, Paulo Alcantara wrote:
>  int delete_entry(bdaddr_t *src, const char *storage, const char *key)
>  {
> -	char filename[PATH_MAX + 1];
> +	char filename[PATH_MAX + 1], old_key[18];
> +	int err;
> +
> +	memset(old_key, 0, sizeof(old_key));
> +	memcpy(old_key, key, sizeof(old_key) - 1);
>  
>  	create_filename(filename, PATH_MAX, src, storage);
>  
> -	return textfile_del(filename, key);
> +	/* key: address#type */
> +	err = textfile_del(filename, key);
> +	if (err < 0)
> +		/* old_key: address only */
> +		err = textfile_del(filename, old_key);
> +
> +	return err;
>  }

This looks dangerous to me. Even though the only users of delete_entry()
use addresses as the key values there's nothing about the naming of this
function that suggests that it's only usable for key values with a very
specific format compared to what the rest of storage.c is designed to
support (arbitrary key values).

Either the function name and/or the "key" parameter name needs to be
changed to make this restricted use clear or then the error handling of
old keys should be pushed to the caller side (device.c).

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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