From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F35EC433B4 for ; Mon, 5 Apr 2021 13:16:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3628611BE for ; Mon, 5 Apr 2021 13:16:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3628611BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTP5h-00087d-Ta for qemu-devel@archiver.kernel.org; Mon, 05 Apr 2021 09:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTP3q-0006n9-Vh for qemu-devel@nongnu.org; Mon, 05 Apr 2021 09:14:34 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:41833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTP3p-0005xd-Gb for qemu-devel@nongnu.org; Mon, 05 Apr 2021 09:14:34 -0400 Received: by mail-wr1-x42b.google.com with SMTP id a6so4886146wrw.8 for ; Mon, 05 Apr 2021 06:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fqiLovYvQuOlZXvGJXZzmuyGnZzzgfjs0PbRWtRKh/k=; b=POL4DjmXJ4nEV6PMgwiUxR3n2YiryPPzc5S83LnXmp6anQ4E8muozz20m8XgTWoftj cE77HW2o9jDbOYAr6cTR5X4uP8qBcqDdWT6Qg9XX8aT5aDi/AlVEjpoYDPCutkues+vp I1GF81nLgNPSbgdZ8HO73EjdPbov/QjF0Ly8u1nZo0iX1sJkOWESUKiANVBtd8MPSsya epzC9qaynlYmTpHzkZjE6PvO08NYazwxPJhrFCeMK+wJXOF6p0QzkmTPh6WwATeFzXZz J5qUE2TOO9lHwWePAvrezqJ6aFWX5rSrUrz74PfGHwmvMbxLtmW6uNqPx8dOrpd/AaCi PkLw== 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=fqiLovYvQuOlZXvGJXZzmuyGnZzzgfjs0PbRWtRKh/k=; b=puGCNctDpL/Um4rrufeyhk6uYui3C5gziLKetAmZpxlNzJ08guRMOEBoxD5KEqisOR yDt+HpJUZdFrHMuGiXf79F5+tPOeR+zwrww6C/a4woFJQ687DPhLS8TYelwz/Bh0hp4A IOoSHhqtcLGIu1wSxycTSp7QHydBbR/Zk1oEYVuH914Igv649yfQVT5Z1meIHF+ybA/1 UW3m/emM4rXhlkWdCPQch8pltsrvBCzKicJXcBYpgYZ0m06UUdX6P8ycbQTexNqYFj3n jDMIQwsoRINqyhAgMArgn3+EyYvmd8SNrbOCYb8YZDU19qrsDKP9x0p+R6vo8cNXcIcB u7Og== X-Gm-Message-State: AOAM530BcpeUSkRSgGkFaxX4GNJDi65ox0OmjsYjGLalFZdQFQVurXwO mSHi7j/dhdCoJDz6C5vH6+JAPTPABXFTDA== X-Google-Smtp-Source: ABdhPJyiK+t94mJrHo83ZcAaX4kP3srNoclJNU6go6uyayIdEhbAL0kG/J2Jm+lgYNRZxkoimyy+Tw== X-Received: by 2002:a5d:6048:: with SMTP id j8mr30169640wrt.115.1617628471556; Mon, 05 Apr 2021 06:14:31 -0700 (PDT) Received: from localhost.localdomain (bzq-84-110-34-91.static-ip.bezeqint.net. [84.110.34.91]) by smtp.gmail.com with ESMTPSA id e9sm12661542wrv.92.2021.04.05.06.14.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Apr 2021 06:14:31 -0700 (PDT) From: Basil Salman To: qemu-devel@nongnu.org, Michael Roth Subject: [PATCH 2/3] qga-win: Fix build_guest_fsinfo() close of nonexistent handle Date: Mon, 5 Apr 2021 16:14:19 +0300 Message-Id: <20210405131420.598273-2-basil@daynix.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20210405131420.598273-1-basil@daynix.com> References: <20210405131420.598273-1-basil@daynix.com> Received-SPF: none client-ip=2a00:1450:4864:20::42b; envelope-from=basil@daynix.com; helo=mail-wr1-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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Kostiantyn Kostiuk Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On the current error path of build_guest_fsinfo(), a non existent handle is passed to CloseHandle(). This patch add initialization of hLocalDiskHandle to INVALID_HANDLE_VALUE, and checks for handle validity before the handle is closed. Signed-off-by: Basil Salman Signed-off-by: Basil Salman --- qga/commands-win32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 27baf17d6c..d51833ef15 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1091,7 +1091,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp) size_t len; uint64_t i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; GuestFilesystemInfo *fs = NULL; - HANDLE hLocalDiskHandle = NULL; + HANDLE hLocalDiskHandle = INVALID_HANDLE_VALUE; GetVolumePathNamesForVolumeName(guid, (LPCH)&mnt, 0, &info_size); if (GetLastError() != ERROR_MORE_DATA) { @@ -1149,7 +1149,8 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp) fs->type = g_strdup(fs_name); fs->disk = build_guest_disk_info(guid, errp); free: - CloseHandle(hLocalDiskHandle); + if (hLocalDiskHandle != INVALID_HANDLE_VALUE) { + CloseHandle(hLocalDiskHandle); + } g_free(mnt_point); return fs; } -- 2.17.2