From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UN202-0006e7-5v for qemu-devel@nongnu.org; Tue, 02 Apr 2013 10:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UN1zw-0008Jt-1E for qemu-devel@nongnu.org; Tue, 02 Apr 2013 10:15:46 -0400 Received: from mail-gh0-f179.google.com ([209.85.160.179]:60346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UN1zv-0008Jj-UF for qemu-devel@nongnu.org; Tue, 02 Apr 2013 10:15:39 -0400 Received: by mail-gh0-f179.google.com with SMTP id z12so58063ghb.10 for ; Tue, 02 Apr 2013 07:15:39 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Tue, 2 Apr 2013 09:13:13 -0500 Message-Id: <1364911993-31042-6-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1364911993-31042-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1364911993-31042-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 5/5] qemu-ga: ga_get_fd_handle(): abort if fd_counter overflows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, lersek@redhat.com, lilei@linux.vnet.ibm.com, lcapitulino@redhat.com From: Luiz Capitulino Today we reset fd_counter if it wraps, but it's better to abort() instead, as fd_counter should never reach INT64_MAX. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake *fixed typo: s/resonable/reasonable/ Signed-off-by: Michael Roth --- qga/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qga/main.c b/qga/main.c index 74ef788..1841759 100644 --- a/qga/main.c +++ b/qga/main.c @@ -889,9 +889,13 @@ int64_t ga_get_fd_handle(GAState *s, Error **errp) g_assert(!ga_is_frozen(s)); handle = s->pstate.fd_counter++; - if (s->pstate.fd_counter < 0) { - s->pstate.fd_counter = 0; + + /* This should never happen on a reasonable timeframe, as guest-file-open + * would have to be issued 2^63 times */ + if (s->pstate.fd_counter == INT64_MAX) { + abort(); } + if (!write_persistent_state(&s->pstate, s->pstate_filepath)) { error_setg(errp, "failed to commit persistent state to disk"); } -- 1.7.9.5