]> git.alsa-project.org Git - alsa-lib.git/commit
ucm: fix st_mode check for symbolic links
authorStephan Gerhold <stephan@gerhold.net>
Fri, 8 Jul 2022 12:50:54 +0000 (14:50 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 8 Jul 2022 15:31:58 +0000 (17:31 +0200)
commitcfd3da47fa0f094d541ff596c1a0c24e6dc9d3e2
treed267a1f073838f58bc77dfd8f201895fca40fb6e
parent351a237b2df497e78ac2d4666040e02118e924e8
ucm: fix st_mode check for symbolic links

The file type in the st_mode field is not encoded as unique bits but as
an enumerator. Checking if some bits of S_IFLNK are set does not work
correctly because it happens to evaluate to true for regular files as
well.

The POSIX man page suggests using the following approach to check
the file type:

    if ((sb.st_mode & S_IFMT) == S_IFLNK)

Alternatively, there is a S_ISLNK() macro to check this more easily.

Make use of the latter so that readlink() is only called on actual
symbolic links and not regular files. This makes audio work again
with slightly older alsa-ucm-conf versions or alternative top-level
ucm.conf configurations that do not make use of symlinks.

Fixes: d6adde0e ("ucm: top-level path - set directory from symlink")
Fixes: https://github.com/alsa-project/alsa-lib/pull/249
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/parser.c