qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, mrezanin@redhat.com
Cc: pmatouse@redhat.com, Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org, P J P <pjp@fedoraproject.org>
Subject: Re: [Qemu-devel] [PATCH] net: fix insecure temporary file creation in SLiRP
Date: Mon, 01 Jun 2015 10:47:07 +0200	[thread overview]
Message-ID: <556C1C0B.6030209@redhat.com> (raw)
In-Reply-To: <87iob7lv1p.fsf@blackfin.pond.sub.org>



On 01/06/2015 09:58, 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) {
>> > -        error_report("could not create samba server dir '%s'", s->smb_dir);
>> > +    if (!(tmpdir = mkdtemp(smb_dir))) {

mkdtemp is unfortunately missing on Windows, and g_mkdtemp requires glib
2.30.

Paolo

>> > +        error_report("could not create samba server dir '%s'", smb_dir);
>> >          return -1;
>> >      }
>> > +    strncpy(s->smb_dir, tmpdir, sizeof(s->smb_dir));
> We tend to eschew strncpy() and use our (slightly less bad) pstrcpy().
> Recommend to use it here, too.
> 
>> >      snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir,
>> >      "smb.conf");
>> >  
>> >      f = fopen(smb_conf, "w");
> Michael (cc'ed) already posted "[PATCH] slirp: use less predictable
> directory name in /tmp for smb config (CVE-2015-4037)"[*].  His patch
> clobbers s->smb_dir[] when mkdtemp() fails (missed that in my review),
> yours doesn't.
> 
> Suggest you guys figure out together which solution you want.
> 
> Preferably with strncpy() replaced by pstrcpy():
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

  parent reply	other threads:[~2015-06-01  8:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01  7:06 [Qemu-devel] [PATCH] net: fix insecure temporary file creation in SLiRP mrezanin
2015-06-01  7:58 ` Markus Armbruster
2015-06-01  8:38   ` Miroslav Rezanina
2015-06-01  8:47   ` Paolo Bonzini [this message]
2015-06-01  8:49     ` Michael Tokarev
2015-06-02  6:51   ` P J P
2015-06-03 11:03     ` Markus Armbruster
2015-06-04  4:29       ` P J P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556C1C0B.6030209@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=mrezanin@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=pmatouse@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).