9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: Re: bug: disk/mkfs crashes in libdisk when given a directory as a protofile
Date: Fri, 12 Oct 2018 03:11:51 -0700	[thread overview]
Message-ID: <CAH_zEu4HX1_Hm2GFnBDwbuNXntjc80eJeDhOdQB3SvTeSNwwUg@mail.gmail.com> (raw)
In-Reply-To: <CAH_zEu4vPwyeeEer+XDHsOtpCTA6LiEbnjymnUiQqL0wjzbuog@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

this bug was introduced in revision c7027d120f0c. attached is a diff
which prevents this crash in libdisk. any thoughts?
On Tue, Sep 18, 2018 at 8:42 PM Nick Owens <mischief@offblast.org> wrote:
>
> the following command will crash:
>
> disk/mkfs -a -o .
>
> with a null pointer dereference in libdisk, in the proto file parser.
>
> obviously it is wrong to pass a directory as a protofile to mkfs, but
> it was an accident on my part.

[-- Attachment #2: libdisk.patch --]
[-- Type: text/x-patch, Size: 338 bytes --]

diff --git a/sys/src/libdisk/proto.c b/sys/src/libdisk/proto.c
--- a/sys/src/libdisk/proto.c
+++ b/sys/src/libdisk/proto.c
@@ -537,7 +537,10 @@ loop:
 		goto loop;
 	p--;
 	popopt(mkaux);
-	*strchr(p, '\n') = 0;
+	s = strchr(p, '\n');
+	if(s == nil)
+		return nil;
+	*s = 0;
 	if(s = strchr(p, '=')){
 		*s++ = 0;
 		setopt(mkaux, p, s);

      reply	other threads:[~2018-10-12 10:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19  3:42 Nick Owens
2018-10-12 10:11 ` Nick Owens [this message]

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=CAH_zEu4HX1_Hm2GFnBDwbuNXntjc80eJeDhOdQB3SvTeSNwwUg@mail.gmail.com \
    --to=mischief@offblast.org \
    --cc=9front@9front.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).