Received: from eggs.gnu.org ([2001:4830:134:3::10]:48536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2BY6-00024N-DO for qemu-devel@nongnu.org; Thu, 03 Nov 2016 02:30:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2BY1-0007IE-Cv for qemu-devel@nongnu.org; Thu, 03 Nov 2016 02:30:54 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:43330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2BY1-0007Hf-4R for qemu-devel@nongnu.org; Thu, 03 Nov 2016 02:30:49 -0400 References: <1478152560-24740-1-git-send-email-wangxinxin.wang@huawei.com> From: Michael Tokarev Message-ID: <7d02cdc1-44bc-590d-4eae-a23d6e38ee2e@msgid.tls.msk.ru> Date: Thu, 3 Nov 2016 09:30:46 +0300 MIME-Version: 1.0 In-Reply-To: <1478152560-24740-1-git-send-email-wangxinxin.wang@huawei.com> Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] keyboard: fix qemu load empty keymap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wang Xin , armbru@redhat.com Cc: qemu-devel@nongnu.org 03.11.2016 08:56, Wang Xin wrote: > 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. Do we really care? "Garbage in, garbage out" I'd say :) Thanks, /mjt > 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; > } >