From patchwork Thu Nov 3 05:56:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Xin X-Patchwork-Id: 9410307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 180EA601C2 for ; Thu, 3 Nov 2016 05:57:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F123529FCC for ; Thu, 3 Nov 2016 05:57:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D38322A031; Thu, 3 Nov 2016 05:57:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3891C29FCC for ; Thu, 3 Nov 2016 05:56:59 +0000 (UTC) Received: from localhost ([::1]:59194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2B1G-0002ng-AU for patchwork-qemu-devel@patchwork.kernel.org; Thu, 03 Nov 2016 01:56:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2B0y-0002nO-7C for qemu-devel@nongnu.org; Thu, 03 Nov 2016 01:56:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2B0v-0001tx-5f for qemu-devel@nongnu.org; Thu, 03 Nov 2016 01:56:40 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:45922) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1c2B0u-0001oC-3i for qemu-devel@nongnu.org; Thu, 03 Nov 2016 01:56:37 -0400 Received: from 172.24.1.136 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.136]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQA25605; Thu, 03 Nov 2016 13:56:19 +0800 (CST) Received: from localhost (10.177.218.69) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Thu, 3 Nov 2016 13:56:08 +0800 From: Wang Xin To: , Date: Thu, 3 Nov 2016 13:56:00 +0800 Message-ID: <1478152560-24740-1-git-send-email-wangxinxin.wang@huawei.com> X-Mailer: git-send-email 2.8.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.218.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH] keyboard: fix qemu load empty keymap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wang Xin , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP qemu_find_file do not check file is a directory or just a file. If qemu start with "-k ''", qemu_find_file get a empty string as keymap file name, then, qemu treat the keymap path as keymap file, it makes vnc keyboard input unusable. Signed-off-by: Wang Xin diff --git a/vl.c b/vl.c index ebd47af..2ec3832 100644 --- a/vl.c +++ b/vl.c @@ -2264,6 +2264,7 @@ char *qemu_find_file(int type, const char *name) int i; const char *subdir; char *buf; + struct stat file_stat; /* Try the name as a straight path first */ if (access(name, R_OK) == 0) { @@ -2284,7 +2285,13 @@ char *qemu_find_file(int type, const char *name) for (i = 0; i < data_dir_idx; i++) { buf = g_strdup_printf("%s/%s%s", data_dir[i], subdir, name); - if (access(buf, R_OK) == 0) { + if (stat(buf, &file_stat) < 0) { + error_report("can not get file '%s' stat: %s\n", buf, + strerror(errno)); + g_free(buf); + return NULL; + } + if (!S_ISDIR(file_stat.st_mode) && access(buf, R_OK) == 0) { trace_load_file(name, buf); return buf; }