From nobody Mon Nov 25 05:08: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=1717549258; cv=none; d=zohomail.com; s=zohoarc; b=VYLRAVI0IsSM3wcQ3MhWAmfu6MHk8TlPjKYnwUkPLdYRyGuSGtJ1jfWaaZKrus7Kz9fLDcsHyVHZBt72Sq54/o4pYCrKeTQFA90JCXscTKywDvw60oWmArZsKvTT1R/7bhf10V4D1tQPi94O66Od4iSMWN5hw1gerh/g3mR2lgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717549258; 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=nnj77JjBpVsXflYKIgrGhPwS8pVPD/uZ2hGHpqlFRga+E4Ow7aJ+Ecp0Rr9Cm+spbxD4JLmN6dT+uDN3CMCacq7jWewWlr0VgjLK4d9dq6jniQha3TD3XcHBEDt7adhdilq93BCN1mCOHuTAvw3VBI+ZJTIwNSqPqKphwmNd6Gk= 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 1717549258944433.0704256993189; Tue, 4 Jun 2024 18:00:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEf0i-0008HU-NP; Tue, 04 Jun 2024 21:00:16 -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 1sEf0c-0008Fg-G8; Tue, 04 Jun 2024 21:00:11 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEf0a-0004S2-GW; Tue, 04 Jun 2024 21:00:10 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-702548b056aso3192013b3a.1; Tue, 04 Jun 2024 18:00:07 -0700 (PDT) Received: from amjad-pc.. ([192.228.203.229]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-703ee633e04sm3731b3a.19.2024.06.04.18.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 18:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717549205; x=1718154005; 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=U8Sfc4H/nWUEoiohJSFe8hReVVXvDm2QyXvvOE8plYZi5n1vW7E0+BAdNe/OaffxJi O1gw+TvLaSXlHv8v7YoU1lt3Vp3i7prtV4LHAG9VryRdTTYhLxX0JQnjZe8NSHjQWNGs Wyl6RwEu1gZsj7MGiDDEQKygdd+IoVaerhFD7/mSNJyWhPg27S8TKDLIpNxfu8mZhGze XkuXfHKSMOlsogGtvcwDVCfOheTPcu3KK8u3hL9b9JavxfgSAjEfuedD+BfGLKbD7yoQ a7/NEvS0AA3dvTDmTEnEGktV0oyVDWn4Tn1dl0bh0mIfjs2eOhffe6Hbau/vLWcGyoEU 5EnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717549205; x=1718154005; 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=r343QXjxJ+XY6vMd/TS/fcGM8RuJ1IHf2NxVtfpgqibv0fM0N7tT2J+74WljETY6Q7 xeHpGUXV8Jzge1miK2Z2o2CXKcVf0MM7YRiAuvgvwYUJn6txENHaOgr+5V7QuULAfnTW nXTR50qF8Xj7M53HL0OVc9SOV6iQB2/4aW3rTQYdKUnYIHzPWHHohYW7Ck8UwyoMvUHR kRHad6455CEUfjEDgSuDfenv/W8G/FnNapwsFwhEDkQtyEumgXoYue1XRuGXZ1j6I/4m Uyowz8/p3qBqw7zijB4RNa+cM64RYTiM9LW2LO7I7oVUcbSquUy+2+BS6d4v+iBTLnO/ HHqA== X-Forwarded-Encrypted: i=1; AJvYcCV02sFVNzDSd0R/m17V1bE0eXlwikFLSMGfnEZaKLLrEQD4SSSDfHBMrd/1NUKJybOhpv8ucj3sE7FwpSOlyvpX7rZKawU= X-Gm-Message-State: AOJu0Yzimy9pJEegQd+nSwLDR/AX1WF9tDY+BqMa+zfoiR2how6ZnFzh a1/x8JvDGQFzK+1v3QRVtw+ACULB0HQAQM973wtHdFsuq2CCjtdGgkShRVjCXzo= X-Google-Smtp-Source: AGHT+IFjnpe+mQKhY2xjd4tN2As3LWc9ByDooIYvnVHLpt/TOeKePaIT6d8caIiojoR7ls4BE2a+4Q== X-Received: by 2002:a05:6a20:7487:b0:1b2:a899:e57e with SMTP id adf61e73a8af0-1b2b71542b8mr1416771637.59.1717549205196; Tue, 04 Jun 2024 18:00:05 -0700 (PDT) From: Amjad Alsharafi To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , "open list:vvfat" , Amjad Alsharafi Subject: [PATCH v4 1/4] vvfat: Fix bug in writing to middle of file Date: Wed, 5 Jun 2024 08:58:37 +0800 Message-ID: <4100134ef391cc33487ded6568bdf1a2abd1e8e7.1717549035.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::42b; envelope-from=amjadsharafi10@gmail.com; helo=mail-pf1-x42b.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: 1717549260446100003 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