From nobody Fri Oct 25 19:31:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1718196329; cv=none; d=zohomail.com; s=zohoarc; b=I6Uvy1pj3YIIERsrBNTXCvaXoFD5waFpOgwTcIzuQPU5A3lnbG59TN+z4YDOfnVZeYX8WTx4OmnMH3fGSQzpRK/ihPO7+EXWZXP+SGUXeohxXOZLFTcTjt9fR+DeBNLWbe41O0FedwESp0oKZhWbP86oQO2ZeVJZCwEbGBbqhJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718196329; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ymVSlpsEC0B/nB1jHObObR3P+gg3N0AOCscuoEKuFXg=; b=Tac7uhIrCtTYVwS3sEGvhV89fzTpRWsDyKhbQSJkOqCZo+236Bjqc6vQnFB/ccB8tBxut56dZKSukBM0t9w7QlL3koy3IqzQV9//DvEerAHeXDn4ggg9f47xHdlE+/HSFbNmYVYhK27UhkQhN79b7iEs+mw8rcpLnSUImvX7az8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718196329421215.94217868480507; Wed, 12 Jun 2024 05:45:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHNLW-0000xA-I0; Wed, 12 Jun 2024 08:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHNL9-0000pd-9Y; Wed, 12 Jun 2024 08:44:35 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sHNL7-0004xh-Gs; Wed, 12 Jun 2024 08:44:34 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-6bce380eb96so1651444a12.0; Wed, 12 Jun 2024 05:44:32 -0700 (PDT) Received: from amjad-pc.. ([202.185.212.207]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7042dff35fdsm6928961b3a.131.2024.06.12.05.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 05:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718196271; x=1718801071; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ymVSlpsEC0B/nB1jHObObR3P+gg3N0AOCscuoEKuFXg=; b=EeklGONPlDr2I0IUlaKdR9RQnFuxqYoJijtNZgyJgBPfu0MBrloo+MXkvSnUU8Np+z YI0Fa6itTMqgwobauBAW4dygGak0XsHSU7ATpjVdN8WYiarXy7M//PJ30GFwdeO6jjC1 CE2JSuOW2Ob++wkbocg4mWJ3DNORsH2hrDE1xv538ixX2Vm1FheOqp8N+PGt/yyjvEVm 1Clt+U2SEpLvuj/fPcVG8FIglMKd0H+gpnVQ0z5xkzCfYLmrQFzzDzwQ0C80a7ht17oX PWIpylSx5but3HF2xeKzlSYyBct4crfjhMHeeI0AN3iXaazANYB6Z7otNY1CxDRZuaKt fffA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718196271; x=1718801071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ymVSlpsEC0B/nB1jHObObR3P+gg3N0AOCscuoEKuFXg=; b=FhtkMkUi15TMSI5lMqEeQ6wBrmpcb5wN233/KjDX6tklBpEI5M1GPa8lL3uumMTCse v27T78raOSmyMN3fOys2JdpbtPiOXDnUgPgzAsKxqvXE/P1w7QDiHKmW5L7k0l1xQOdq QDOOdMgWxQTY11JOnlt2NS3Vp0oNk3u2Bsn3BUPz+cLvybc3wRAcDZRTFsJR7f2axVPh mNVI4NDpZV38lyaq2/fXRYxAK45vsbCRxVMBYc08RInX4Hw9sBl9JF3c69huXCSqHYPF zgfjEFX7hqyMz26AXGcVMNjX4SC1IXDs9IhoIGDuJOy6jKNQ+JyPc/1P91/8eg3at2qx c0vA== X-Forwarded-Encrypted: i=1; AJvYcCXRTEQgdaDmSSULHukShN0bVYiwDCtHgcleautTT42jLguZVbSYiisBABu2VT36eqQ0VplPFKUlFW49GZR5/s69Q0bNhEI= X-Gm-Message-State: AOJu0Yxol6vuSvAJE+T+6gtsDzN0nUu2dc0G2eYbR3R32fhRQU+jbKL5 ZXTsjIipIGdScNoFwQ7UuBBl+BSzLal+aVUj2tG3deZcmUGXu7Qhzczv/Jzsqic= X-Google-Smtp-Source: AGHT+IGZ0m1QnyEpNaz45jWGix4ylxaY3FH7zCtIr/6cZdnWJE2TfDL1I7VpO6GMX0uFEzOTrEKM/Q== X-Received: by 2002:a05:6a21:999a:b0:1b2:b16f:3b26 with SMTP id adf61e73a8af0-1b8a9b1375bmr1891370637.7.1718196270710; Wed, 12 Jun 2024 05:44:30 -0700 (PDT) From: Amjad Alsharafi To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , "open list:vvfat" , Amjad Alsharafi Subject: [PATCH v5 1/5] vvfat: Fix bug in writing to middle of file Date: Wed, 12 Jun 2024 20:43:22 +0800 Message-ID: <4100134ef391cc33487ded6568bdf1a2abd1e8e7.1718195956.git.amjadsharafi10@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=amjadsharafi10@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1718196329642100001 Content-Type: text/plain; charset="utf-8" Before this commit, the behavior when calling `commit_one_file` for example with `offset=3D0x2000` (second cluster), what will happen is that we won't fetch the next cluster from the fat, and instead use the first cluster for the read operation. This is due to off-by-one error here, where `i=3D0x2000 !< offset=3D0x2000`, thus not fetching the next cluster. Signed-off-by: Amjad Alsharafi Reviewed-by: Kevin Wolf Tested-by: Kevin Wolf --- block/vvfat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/vvfat.c b/block/vvfat.c index 9d050ba3ae..19da009a5b 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2525,8 +2525,9 @@ commit_one_file(BDRVVVFATState* s, int dir_index, uin= t32_t offset) return -1; } =20 - for (i =3D s->cluster_size; i < offset; i +=3D s->cluster_size) + for (i =3D 0; i < offset; i +=3D s->cluster_size) { c =3D modified_fat_get(s, c); + } =20 fd =3D qemu_open_old(mapping->path, O_RDWR | O_CREAT | O_BINARY, 0666); if (fd < 0) { --=20 2.45.1