Hello Michael

I agree, it also seems to be the style used elsewhere (and the reason
elsewhere didn't segfault).

Best regards

Pieter

On Thu, 7 Sep 2017 at 23:26 Laslo Hunhold <d...@frign.de> wrote:

> On Thu, 7 Sep 2017 14:23:02 -0700
> Michael Forney <mfor...@mforney.org> wrote:
>
> Dear Michael,
>
> > What do you think about just moving unescape to right after `adelim =
> > EARGF(usage());`? The default value does not need escaping.
>
> this would be a nice idea and would save us an allocation.
>
> With best regards
>
> Laslo Hunhold
>
> --
> Laslo Hunhold <d...@frign.de>
>
>
From 9d7d618026353910e2629edee6913688c6b89b37 Mon Sep 17 00:00:00 2001
From: Pieter Kockx <pieterko...@gmail.com>
Date: Thu, 7 Sep 2017 19:00:10 +0200
Subject: [PATCH] Fix segmentation fault in paste(1)

libutil/unescape received a pointer to a a string in
read-only memory.
---
 paste.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/paste.c b/paste.c
index 1d4e9f6..b0ac761 100644
--- a/paste.c
+++ b/paste.c
@@ -97,6 +97,7 @@ main(int argc, char *argv[])
 		break;
 	case 'd':
 		adelim = EARGF(usage());
+		unescape(adelim);
 		break;
 	default:
 		usage();
@@ -107,7 +108,6 @@ main(int argc, char *argv[])
 
 	/* populate delimiters */
 	/* TODO: fix libutf to accept sizes */
-	unescape(adelim);
 	delim = ereallocarray(NULL, utflen(adelim) + 1, sizeof(*delim));
 	if (!(delimlen = utftorunestr(adelim, delim)))
 		usage();
-- 
2.13.5

Reply via email to