From patchwork Mon Sep 23 09:52:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1165974 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46cKNw6wckz9s4Y for ; Mon, 23 Sep 2019 19:52:14 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E663C3C1D02 for ; Mon, 23 Sep 2019 11:52:07 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id E205F3C1C7C for ; Mon, 23 Sep 2019 11:52:05 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id C5F4F1001563 for ; Mon, 23 Sep 2019 11:51:56 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0E7B6AF65 for ; Mon, 23 Sep 2019 09:52:04 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Mon, 23 Sep 2019 11:52:03 +0200 Message-Id: <20190923095203.30362-1-chrubis@suse.cz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [COMMITTED] [PATCH] syscalls/getxattr01: Fix rare failures X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The test was observed to fail on s390x, the cause is obviously that we use strcmp() for something that is not guaranteed to be null terminated. That is because we store the string without the terminating null into the extended attribute and the allocated buffer we read the attribute to is not initialized either. Fix the test by checking the returned size first then using memcmp() instead of strcmp(). This change is just pre-release band-aid with minimal changes, I've opened issue #583 so that we don't forget to rewrite the test later on. Signed-off-by: Cyril Hrubis --- testcases/kernel/syscalls/getxattr/getxattr01.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/getxattr/getxattr01.c b/testcases/kernel/syscalls/getxattr/getxattr01.c index be410a536..54ca65390 100644 --- a/testcases/kernel/syscalls/getxattr/getxattr01.c +++ b/testcases/kernel/syscalls/getxattr/getxattr01.c @@ -121,7 +121,14 @@ int main(int argc, char *argv[]) } } - if (strcmp(tc[i - 1].value, XATTR_TEST_VALUE)) + if (TEST_RETURN != XATTR_TEST_VALUE_SIZE) { + tst_resm(TFAIL, + "getxattr() returned wrong size %ld expected %d", + TEST_RETURN, XATTR_TEST_VALUE_SIZE); + continue; + } + + if (memcmp(tc[i - 1].value, XATTR_TEST_VALUE, XATTR_TEST_VALUE_SIZE)) tst_resm(TFAIL, "Wrong value, expect \"%s\" got \"%s\"", XATTR_TEST_VALUE, tc[i - 1].value); else