Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp994659lqt; Fri, 7 Jun 2024 05:18:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsPknP7uNFjvOl46CAcb9bEWEzHAl/h+q6BsVhEOepAgBoLWuwDC49C1ip9KU+hwNFsbJTQ8CZ08C/FRHfntPvuleMeRblktod7i65sA== X-Google-Smtp-Source: AGHT+IE53e5GfxVnUFIbVYIczs0xHIR6kV17A97JLwG8+lY4C3WX7EM1ptdDA61LVTNbJPlETQ1z X-Received: by 2002:a67:f34d:0:b0:48c:3746:33e2 with SMTP id ada2fe7eead31-48c37463903mr289254137.14.1717762723763; Fri, 07 Jun 2024 05:18:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717762723; cv=pass; d=google.com; s=arc-20160816; b=o+Z1K37F2DhhZb1vFbhnqfQF1qLnCkkCclqVX+SK3EV/WAvO3tazEidCTdsblyjv61 pcPt+Ojh2E4KOH1bmbgxNVku9lnjiq7eO6iP2vEhiNqwhkD6WS2YKCAtHij6RBTw3N2S q41sBVmf6gJ6k7GZVmhoXhbNhA6C4W8BmmYg72VVrVtFGN8r/vQuu0nK+u1O7syKT/fU FQ0eNecJLzrkJmCkvAdZ616VTeBwuW7Hkzu9uE9siXzWDOA7oqoAwqvJLkiLw6zFkv6v HywgRv8WLtowHc6AIL0S8paFu20Mt/lpcwxGG7zc9aGR20Y5L/T4fWjOER5ijXHIOyHX lJEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ym80i2jTMD1HhHw9F6CkuGUlURqOKsq9Wpygi7rED0Q=; fh=xoZo938iZo6Zo9BQRi1y1Y/2pdszedQYQQiMhZQzvOk=; b=iGvnowZy4cZnU4JErAz01GyUvXJJFZVmOYZFzLx/nvTTY8X0OCgp0jPNs586unuzoi xJX7FjNLm4zScV0ygXr/ZdqrDyYckGW/rsk9jkvb8vNoJP/KIyxmFFYOImDRhZqyVADy iaoHgUrQqrLPF+29YtMi6YZpr987//fityP+M/GueH9/ntnrCdxzTOwHx9MF8VBQoDqt bGaJPogMIDZVVjLlzXDzc4Ttm+XfPLI0tOsAr63wrdITGdPezAC5ccX0yrV9IOl+gEsw kMpOxRY/W2CDauognX4YcGoZ13wUX+vrRVrL2KLtEjdEA8IvOG9h3JF4Z771kiCEDFff s7SA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ql6b1Rc+; dkim=pass header.i=@paragon-software.com header.s=mail header.b=udhbf3NC; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-206001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ada2fe7eead31-48c1a1eaeb6si951524137.286.2024.06.07.05.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ql6b1Rc+; dkim=pass header.i=@paragon-software.com header.s=mail header.b=udhbf3NC; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-206001-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8F64E1C222BC for ; Fri, 7 Jun 2024 12:18:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F30A1196446; Fri, 7 Jun 2024 12:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="ql6b1Rc+"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="udhbf3NC" Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEF3D194AD0; Fri, 7 Jun 2024 12:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717762585; cv=none; b=u4D2yzVisLvAmu73/7t8jwjikOg57cBAV/wFr9LKcDq7wDybxXTuqWOLFIdQre0/8rj6a8lOQnLN6NTu+IrdXaIuPzL+d159SDgxozzivVVTfTCrrN1CdeVgWQen86oIe+qJDNNsyR0kUxE0hbyWtaOKL2JXgu92OgU9pzCZdiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717762585; c=relaxed/simple; bh=dE3xbrb288BUcy0ffw0XuM+Wo69zpin7XHmKE6h0t/Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RLcLLzCFt5IY7MdeAZKlEohnAnT5q3gI+7l1fcZTlvmV2OSBIwyBw8h1CSICFTDR0mDEf6WHjkgly8dKhmRH9UkDRU4oKMUCCxRGegniEzQEkZTabW7QyhfGpx1YJ+csMI6qyO7eKR9VOMES8mgTFUuAK9+VbHY1QH7z54ELpo0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=ql6b1Rc+; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=udhbf3NC; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 238322113; Fri, 7 Jun 2024 12:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1717762107; bh=ym80i2jTMD1HhHw9F6CkuGUlURqOKsq9Wpygi7rED0Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ql6b1Rc+StMi1+r0ITd5QoV2mnkysFlrCipV2oajuuunicN2cf3sdyQuNStnoiT0k ewrtZN55TlktwwSnXYH0/dlr93yU/VENgkFlmorIm2wPgndpvyaWlmmKT7jiMkALLv 6qo9gAC1nJIiyI9YLRs2d7wJnQcahRP3FDYTz5RM= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 0695A195; Fri, 7 Jun 2024 12:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1717762581; bh=ym80i2jTMD1HhHw9F6CkuGUlURqOKsq9Wpygi7rED0Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=udhbf3NCsD2gP7uFZbWhAJDK+16Ws0gCfh+H5vIymtSFnBiNhTA/CtNcp7LEsjWiy 5pfNgE7fRDZXHqHcZHjZx/SGVY3GrKlv5RM1VZvZIazH/Y5PRyqNQEzR/JiZeWHr05 hhFIdHuG7VUDcGDtK+LLH3IJRWN3St/8eQtlkWYs= Received: from ntfs3vm.paragon-software.com (192.168.211.95) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 7 Jun 2024 15:16:20 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 13/18] fs/ntfs3: Use macros NTFS_LABEL_MAX_LENGTH instead of hardcoded value Date: Fri, 7 Jun 2024 15:15:43 +0300 Message-ID: <20240607121548.18818-14-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> References: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) To check the length of the volume label, the existing constant NTFS_LABEL_MAX_LENGTH could be used. Signed-off-by: Konstantin Komarov --- fs/ntfs3/fsntfs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 626d3f2c7e2d..0fa636038b4e 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2650,8 +2650,8 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) { int err; struct ATTRIB *attr; + u32 uni_bytes; struct ntfs_inode *ni = sbi->volume.ni; - const u8 max_ulen = 0x80; /* TODO: use attrdef to get maximum length */ /* Allocate PATH_MAX bytes. */ struct cpu_str *uni = __getname(); @@ -2663,7 +2663,8 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) if (err < 0) goto out; - if (uni->len > max_ulen) { + uni_bytes = uni->len * sizeof(u16); + if (uni_bytes > NTFS_LABEL_MAX_LENGTH * sizeof(u16)) { ntfs_warn(sbi->sb, "new label is too long"); err = -EFBIG; goto out; @@ -2674,13 +2675,13 @@ int ntfs_set_label(struct ntfs_sb_info *sbi, u8 *label, int len) /* Ignore any errors. */ ni_remove_attr(ni, ATTR_LABEL, NULL, 0, false, NULL); - err = ni_insert_resident(ni, uni->len * sizeof(u16), ATTR_LABEL, NULL, - 0, &attr, NULL, NULL); + err = ni_insert_resident(ni, uni_bytes, ATTR_LABEL, NULL, 0, &attr, + NULL, NULL); if (err < 0) goto unlock_out; /* write new label in on-disk struct. */ - memcpy(resident_data(attr), uni->name, uni->len * sizeof(u16)); + memcpy(resident_data(attr), uni->name, uni_bytes); /* update cached value of current label. */ if (len >= ARRAY_SIZE(sbi->volume.label)) -- 2.34.1