From patchwork Wed Jun 6 13:59:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 925857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4119Kd3pJkzB3sg for ; Thu, 7 Jun 2018 00:00:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4119Kb6pDfzF1xV for ; Thu, 7 Jun 2018 00:00:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=74.125.82.66; helo=mail-wm0-f66.google.com; envelope-from=javierm@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4119KL2MydzF1xV for ; Wed, 6 Jun 2018 23:59:49 +1000 (AEST) Received: by mail-wm0-f66.google.com with SMTP id n5-v6so12184293wmc.5 for ; Wed, 06 Jun 2018 06:59:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/XIYaFgzlacDQ37gLlztX7Z+l9VknPE58ppez60Lw7U=; b=oaJ9B9XkU2Ii0H6oEhCzUjz3U9X3FuGEOcvIO7dvrJgq49ly0zPmTb8EO9rGMdU4dc ZitazD+HQvc48uWVMJSbFkgJ6J4h23RBnu6G3B0uZyHrq4XPUnBFxh/JGqmFim8HB/Cl A8qUF22D3JNmhB6WnrzlSQkmMDQj5K+ASgn5//OiCE+5Hq27MrQPyYhcPfoSEhEwws/9 vNEOcBbVQwzvNNZ0oqZaHbGzDA4GBcc7TyWVq/o3y1pGAOB+W+DZicB9Jdv/7SRdh+n7 aU1e+GIvi6uTNtbpGQgFmB3snYnCXjBGMb5J00hBGCsBp1az2VSAwDi5uqzhvHF66KA7 /ntQ== X-Gm-Message-State: APt69E1LbQbd9Kel2fiUu/yOzCBOz82jMWwZkg/Qs2L4ltmAK05PoV7s vImCz/NPC6jKKIzK+pVtJIJsYw7p9Co= X-Google-Smtp-Source: ADUXVKIPtW35FrqH3JEBSBmZGk/MYPBwq0+u8zUS3SIe+H66DQ1D4ZCFrIoU1avNiOC1lvKCoe8cjQ== X-Received: by 2002:a1c:b954:: with SMTP id j81-v6mr1789947wmf.89.1528293586251; Wed, 06 Jun 2018 06:59:46 -0700 (PDT) Received: from minerva.home ([90.77.100.34]) by smtp.gmail.com with ESMTPSA id a184-v6sm4953961wmf.30.2018.06.06.06.59.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jun 2018 06:59:45 -0700 (PDT) From: Javier Martinez Canillas To: petitboot@lists.ozlabs.org Subject: [PATCH 1/3] test/parser: Make parser_scandir() ignore files with path len less than dir Date: Wed, 6 Jun 2018 15:59:34 +0200 Message-Id: <20180606135936.2461-2-javierm@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180606135936.2461-1-javierm@redhat.com> References: <20180606135936.2461-1-javierm@redhat.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Javier Martinez Canillas , Peter Jones , Jan Hlavac , Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- test/parser/utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parser/utils.c b/test/parser/utils.c index 394efb3b209..c6d1a170a9b 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -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;