Re: [PATCH - JACK plugin 2/2] jack: Support to connect multiple JACK ports with same ALSA channel

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

 



On Thu, 24 Jan 2019 15:42:55 +0100,
<twischer@xxxxxxxxxxxxxx> wrote:
> 
> @@ -53,6 +61,32 @@ typedef struct {
>  	bool xrun_detected;
>  } snd_pcm_jack_t;
>  
> +
> +/* adds one element to the head of the list */
> +static int snd_pcm_jack_port_list_add(snd_pcm_jack_t *jack,
> +				      const unsigned int channel,
> +				      const char * const name)
> +{
> +	const size_t name_size = strlen(name) + 1;
> +	const size_t elem_size = sizeof(snd_pcm_jack_port_list_t) + name_size;
> +	snd_pcm_jack_port_list_t *elem = NULL;
> +
> +	if (name == NULL)
> +		return -EINVAL;

name is already dereferenced in strlen(), so it's too late here.
i.e. name_size has to be evaluated after this NULL check, if any.
Or just drop this NULL check.  It's an internal function and the name
is never NULL, practically seen.

> +	elem = calloc(1, elem_size);
> +	if (elem == NULL)
> +		return -ENOMEM;
> +
> +	strncpy(elem->name, name, name_size);
> +	elem->name[name_size-1] = 0x00;

name_size is the exact size of string + 1, so this is equivalent with
strcpy().


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux