Received: from eggs.gnu.org ([2001:4830:134:3::10]:38591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzLL4-0006O5-1c for qemu-devel@nongnu.org; Mon, 01 Jun 2015 04:44:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzLKx-0003un-JA for qemu-devel@nongnu.org; Mon, 01 Jun 2015 04:44:53 -0400 Message-ID: <556C1B70.3060209@msgid.tls.msk.ru> Date: Mon, 01 Jun 2015 11:44:32 +0300 From: Michael Tokarev MIME-Version: 1.0 References: <1432811743-2423-1-git-send-email-mjt@msgid.tls.msk.ru> <87bngzluvg.fsf@blackfin.pond.sub.org> In-Reply-To: <87bngzluvg.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] slirp: use less predictable directory name in /tmp for smb config (CVE-2015-4037) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: pmatouse@redhat.com, P J P , qemu-trivial@nongnu.org, Jan Kiszka , qemu-devel@nongnu.org, Miroslav Rezanina 01.06.2015 11:01, Markus Armbruster wrote: [] >> - snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", >> - (long)getpid(), instance++); >> - if (mkdir(s->smb_dir, 0700) < 0) { >> + strcpy(s->smb_dir, "/tmp/qemu-smb.XXXXXX"); >> + if (!mkdtemp(s->smb_dir)) { >> error_report("could not create samba server dir '%s'", s->smb_dir); >> return -1; >> } > > Uh, I have to suspend my R-by. This clobbers s->smb_dir[] when > mkdtemp() fails. Is that safe? Explain why, and get my R-by back. At least this is not different from the original behavour. The only place where this variable is used is in the slirp_smb_cleanup() function, which, if smb_dir[0] != 0, does rm -rf on it. I think it will be better to add s->smb_dir[0] = 0 here before return. On the other hand this isn't really that important given when we can expect mkdtemp() to fail. Thanks, /mjt