[alsa-devel] [PATCH] alsa-lib: pcm: segmentation fault snd_pcm_open

Takashi Iwai tiwai at suse.de
Fri Dec 8 15:36:11 CET 2017


On Fri, 08 Dec 2017 15:19:55 +0100,
Markus Seeber wrote:
> 
> Previously, calling snd_pcm_open with a null pointer argument for
> "name" caused a segmentation fault in snd_config_search_definition.
> The segmentation fault resulted from invoking undefined behavior by
> calling strchr with a null pointer argument.
> 
> The issue can be reproduced by passing a null pointer for "name" to
> snd_pcm_open.
> 
> To prevent this instance of strchr to be invoked with a null pointer
> argument, snd_config_search_definition now returns EINVAL if argument
> "name" is a null pointer.
> 
> Signed-off-by: Markus Seeber <markus.seeber at spectralbird.de>

The NULL check of name argument is done in the caller side via
assert() in snd_pcm_open().   So this check is redundant.

It's another question whether we should make the check mandatory
instead of assert(), though.  Basically it's a bug of the application
that calls with name=NULL, and assert() was considered to catch that.


thanks,

Takashi


More information about the Alsa-devel mailing list