util/cutils: Skip "." when looking for next directory component

When looking for the next directory component, a "." component is now skipped.

This fixes the path(s) used for firmware lookup for the prefix == bindir case
which is standard for QEMU on Windows and where the internally
used bindir value ends with "/.".

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Message-Id: <20210208205752.2488774-1-sw@weilnetz.de>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Stefan Weil 2021-02-08 21:57:52 +01:00 committed by Paolo Bonzini
parent b0019c995e
commit 342e3a4f20
1 changed files with 2 additions and 1 deletions

View File

@ -916,7 +916,8 @@ static inline bool starts_with_prefix(const char *dir)
static inline const char *next_component(const char *dir, int *p_len)
{
int len;
while (*dir && G_IS_DIR_SEPARATOR(*dir)) {
while ((*dir && G_IS_DIR_SEPARATOR(*dir)) ||
(*dir == '.' && (G_IS_DIR_SEPARATOR(dir[1]) || dir[1] == '\0'))) {
dir++;
}
len = 0;