From patchwork Tue Jun 12 10:18:32 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: 928224 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 414m7g32Njz9s0W for ; Tue, 12 Jun 2018 20:18:55 +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 414m7g1mVqzF4GZ for ; Tue, 12 Jun 2018 20:18:55 +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 414m7Q5NyYzF4GY for ; Tue, 12 Jun 2018 20:18:42 +1000 (AEST) Received: by mail-wm0-f66.google.com with SMTP id v131-v6so22171280wma.1 for ; Tue, 12 Jun 2018 03:18:42 -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=BTB6xwhPKjV43aUAB04Hc2frH6Vr+E/fjkVX/7Zs1YDHTUPQUAuqPi9gQbtc6KUEgk im9J6VV/YYHpUgotix7qReOhd9pCti/d22izCwLPraATI/sXpZAtflSQmYD3eG775+PZ TfFy6cgDk+fofmaTwo24VLv+NS0OB7a0lxJk2LCKQHxLKGdYixZy0hH+NlMIrSXxegPv 7/xLNBnQ4EZ+SzTtExd03a8+1V71d5yYlpTw5BZFX2RJ41JqveXUVzTg2AltIJkWcQY/ 5DWEukqDEUt7g26jtJF+mHrnHDT8kJrUtJl/BYBLC+I0TeZP8xSowy/5HKbwEl8qmApk oR4A== X-Gm-Message-State: APt69E3TBbCM8/hv8EhvG8CiKPjALrW3EV5x+8Ys3ixDTHl40P/+asU9 T9TPGlfxVnsmBbhqLd8MZ36MWpRlQH0= X-Google-Smtp-Source: ADUXVKI2orMaif1B3pO3rfeuy7ovC1cSt/t8FAxVbxfHvhObNemz/zYqBpBdRlz+WzhsBNgZxmHLOQ== X-Received: by 2002:a1c:6943:: with SMTP id e64-v6mr1746060wmc.14.1528798719179; Tue, 12 Jun 2018 03:18:39 -0700 (PDT) Received: from minerva.redhat.com ([90.77.100.34]) by smtp.gmail.com with ESMTPSA id m58-v6sm1275862wrf.61.2018.06.12.03.18.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 03:18:38 -0700 (PDT) From: Javier Martinez Canillas To: petitboot@lists.ozlabs.org Subject: [PATCH v3 1/3] test/parser: Make parser_scandir() ignore files with path len less than dir Date: Tue, 12 Jun 2018 12:18:32 +0200 Message-Id: <20180612101835.20872-2-javierm@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612101835.20872-1-javierm@redhat.com> References: <20180612101835.20872-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: Jan Hlavac , Peter Jones , Javier Martinez Canillas , 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;