]> git.ozlabs.org Git - petitboot/commitdiff
test/parser: Make parser_scandir() ignore files with path len less than dir
authorJavier Martinez Canillas <javierm@redhat.com>
Tue, 12 Jun 2018 10:18:32 +0000 (12:18 +0200)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 18 Jun 2018 00:56:27 +0000 (10:56 +1000)
Both the test files and directories added into the test harness are stored
into the same file list. So the parser_scandir() stub compares the absolute
file path of the files and the directory to scan, to know if a file belongs
to the directory.

Files whose absolute file path length isn't bigger than the directory to
scan should just be ignored, since it means they can't be from that dir.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
test/parser/utils.c

index 394efb3b209b4f0dfa885cc1c7cfe3a09db56592..c6d1a170a9b3596daab2c59fbbc49aa7a034530a 100644 (file)
@@ -325,6 +325,9 @@ int parser_scandir(struct discover_context *ctx, const char *dirname,
                if (f->dev != ctx->device)
                        continue;
 
+               if (strlen(f->name) <= strlen(dirname))
+                       continue;
+
                filename = strrchr(f->name, '/');
                if (!filename)
                        continue;