unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: 30116@debbugs.gnu.org
Subject: bug#30116: [PATCH] `substitute' crashes when file contains NUL characters (core-updates))
Date: Sun, 17 Jun 2018 00:36:00 -0400	[thread overview]
Message-ID: <87d0wq3u8f.fsf@netris.org> (raw)
In-Reply-To: <87tvq2smpm.fsf@gmail.com> (Maxim Cournoyer's message of "Sat, 16 Jun 2018 12:47:01 -0400")

Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

> Mark H Weaver <mhw@netris.org> writes:
>
>> With the changes suggested above, I would have no objection to pushing
>> this to core-updates.  However, it occurs to me that we could handle the
>> NUL case in a better way:
>>
>> Since the C regex functions that we use cannot handle NUL bytes, we
>> could use a different code point to represent NUL during those
>> operations.  We could choose a code point from one of the Unicode
>> Private Use Areas <https://en.wikipedia.org/wiki/Private_Use_Areas> that
>> does not occur in the string.
>>
>> Let NUL* be the code point which will represent NUL bytes.  First
>> replace all NULs with NUL*s, then perform the substitutions, and finally
>> replace all ALT*s with NULs before writing to the output.
>
> Do I understand this transformation as NULs -> NUL*s and back from NUL*s
> -> NULs correctly? I'm not sure how NUL*s became ALT*s in your explanation.

Sorry, it's a typo.  Where I wrote "ALT*s", I meant to write "NUL*s".

>> What do you think?
>
> It raises the complexity level a bit for something which doesn't seem to
> be a very common scenario,

FWIW, I agree that it's not a common scenario, and it's not entirely
clear that it was worth the time I spent on it, or the added complexity.
On the other hand, I would dislike having a basic API like 'substitute*'
be subtly broken in this way.

> but otherwise seems a very elegant
> workaround. It seems to me that your implementation is already pretty
> complete. I'll try write a test for validating it and report back.

Sounds good.  Thank you!

      Mark

  reply	other threads:[~2018-06-17  4:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  1:27 bug#30116: [PATCH] `substitute' crashes when file contains NUL characters (core-updates) Maxim Cournoyer
     [not found] ` <handler.30116.B.15159796942311.ack@debbugs.gnu.org>
2018-01-15  1:38   ` bug#30116: [PATCH] `substitute' crashes when file contains NUL characters (core-updates)) Maxim Cournoyer
2018-01-17 14:37     ` Ludovic Courtès
2018-06-14  1:40       ` Maxim Cournoyer
2018-06-14  8:01         ` Ludovic Courtès
2018-06-14  7:02     ` Mark H Weaver
2018-06-14  8:02       ` Ludovic Courtès
2018-06-16 16:47       ` Maxim Cournoyer
2018-06-17  4:36         ` Mark H Weaver [this message]
2021-01-08 19:14           ` bug#30116: [PATCH] `substitute' crashes when file contains NUL characters (core-updates) Maxim Cournoyer
2021-01-08 21:42             ` Mark H Weaver
2018-01-16 11:23 ` Ludovic Courtès
2018-01-21  4:24   ` Maxim Cournoyer
2018-01-21 18:17     ` Mark H Weaver
2018-01-22 10:58       ` Ludovic Courtès
2018-01-23  4:27         ` Maxim Cournoyer
2018-01-23 14:11           ` Ludovic Courtès
2018-01-25  5:11             ` Maxim Cournoyer
2018-01-25 11:11               ` Ludovic Courtès

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87d0wq3u8f.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=30116@debbugs.gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).