zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: caps strings
@ 2009-03-03 17:43 Peter Stephenson
  2009-03-03 17:55 ` Mikael Magnusson
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2009-03-03 17:43 UTC (permalink / raw)
  To: Zsh hackers list

This should fix string arguments to functions in the caps module as
noticed by Mikael.  It looks like all the returned strings are output
directly by library calls so aren't affected.

Index: Src/Modules/cap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/cap.c,v
retrieving revision 1.7
diff -u -r1.7 cap.c
--- Src/Modules/cap.c	6 Jul 2007 21:52:40 -0000	1.7
+++ Src/Modules/cap.c	3 Mar 2009 17:39:34 -0000
@@ -38,6 +38,7 @@
     int ret = 0;
     cap_t caps;
     if(*argv) {
+	unmetafy(*argv, NULL);
 	caps = cap_from_text(*argv);
 	if(!caps) {
 	    zwarnnam(nam, "invalid capability string");
@@ -90,6 +91,7 @@
     cap_t caps;
     int ret = 0;
 
+    unmetafy(*argv, NULL);
     caps = cap_from_text(*argv++);
     if(!caps) {
 	zwarnnam(nam, "invalid capability string");
@@ -97,6 +99,7 @@
     }
 
     do {
+	unmetafy(*argv, NULL);
 	if(cap_set_file(*argv, caps)) {
 	    zwarnnam(nam, "%s: %e", *argv, errno);
 	    ret = 1;


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: caps strings
  2009-03-03 17:43 PATCH: caps strings Peter Stephenson
@ 2009-03-03 17:55 ` Mikael Magnusson
  2009-03-03 18:00   ` Mikael Magnusson
  2009-03-03 18:10   ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Magnusson @ 2009-03-03 17:55 UTC (permalink / raw)
  To: Zsh hackers list

2009/3/3 Peter Stephenson <pws@csr.com>:
> This should fix string arguments to functions in the caps module as
> noticed by Mikael.  It looks like all the returned strings are output
> directly by library calls so aren't affected.
>
> Index: Src/Modules/cap.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/Modules/cap.c,v
> retrieving revision 1.7
> diff -u -r1.7 cap.c
> --- Src/Modules/cap.c   6 Jul 2007 21:52:40 -0000       1.7
> +++ Src/Modules/cap.c   3 Mar 2009 17:39:34 -0000
> @@ -38,6 +38,7 @@
>     int ret = 0;
>     cap_t caps;
>     if(*argv) {
> +       unmetafy(*argv, NULL);
>        caps = cap_from_text(*argv);
>        if(!caps) {
>            zwarnnam(nam, "invalid capability string");
> @@ -90,6 +91,7 @@
>     cap_t caps;
>     int ret = 0;
>
> +    unmetafy(*argv, NULL);
>     caps = cap_from_text(*argv++);
>     if(!caps) {
>        zwarnnam(nam, "invalid capability string");
> @@ -97,6 +99,7 @@
>     }
>
>     do {
> +       unmetafy(*argv, NULL);
>        if(cap_set_file(*argv, caps)) {
>            zwarnnam(nam, "%s: %e", *argv, errno);
>            ret = 1;

I think the two zwarnnam calls with *argv needs them to be
re-metafy()ed. When i didn't do that in attr.c, I got output like
myutf8file\M-p.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: caps strings
  2009-03-03 17:55 ` Mikael Magnusson
@ 2009-03-03 18:00   ` Mikael Magnusson
  2009-03-03 18:10   ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Mikael Magnusson @ 2009-03-03 18:00 UTC (permalink / raw)
  To: Zsh hackers list

2009/3/3 Mikael Magnusson <mikachu@gmail.com>:
> 2009/3/3 Peter Stephenson <pws@csr.com>:
>> This should fix string arguments to functions in the caps module as
>> noticed by Mikael.  It looks like all the returned strings are output
>> directly by library calls so aren't affected.
>>
> I think the two zwarnnam calls with *argv needs them to be
> re-metafy()ed. When i didn't do that in attr.c, I got output like
> myutf8file\M-p.

Ie,

diff --git a/Src/Modules/cap.c b/Src/Modules/cap.c
index 4242d44..3fb653b 100644
--- a/Src/Modules/cap.c
+++ b/Src/Modules/cap.c
@@ -72,11 +72,12 @@
     do {
 	char *result = NULL;
 	ssize_t length;
+	unmetafy(*argv, NULL);
 	cap_t caps = cap_get_file(*argv);
 	if(caps)
 	    result = cap_to_text(caps, &length);
 	if (!caps || !result) {
-	    zwarnnam(nam, "%s: %e", *argv, errno);
+	    zwarnnam(nam, "%s: %e", metafy(*argv, slen, META_NOALLOC), errno);
 	    ret = 1;
 	} else
 	    printf("%s %s\n", *argv, result);
@@ -101,7 +102,7 @@
     do {
 	unmetafy(*argv, NULL);
 	if(cap_set_file(*argv, caps)) {
-	    zwarnnam(nam, "%s: %e", *argv, errno);
+	    zwarnnam(nam, "%s: %e", metafy(*argv, slen, META_NOALLOC), errno);
 	    ret = 1;
 	}
     } while(*++argv);


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: caps strings
  2009-03-03 17:55 ` Mikael Magnusson
  2009-03-03 18:00   ` Mikael Magnusson
@ 2009-03-03 18:10   ` Peter Stephenson
  2009-03-03 18:21     ` Mikael Magnusson
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2009-03-03 18:10 UTC (permalink / raw)
  To: Zsh hackers list

On Tue, 3 Mar 2009 18:55:30 +0100
Mikael Magnusson <mikachu@gmail.com> wrote:
> I think the two zwarnnam calls with *argv needs them to be
> re-metafy()ed. When i didn't do that in attr.c, I got output like
> myutf8file\M-p.

Index: Src/Modules/cap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/cap.c,v
retrieving revision 1.8
diff -u -r1.8 cap.c
--- Src/Modules/cap.c	3 Mar 2009 17:46:51 -0000	1.8
+++ Src/Modules/cap.c	3 Mar 2009 18:09:50 -0000
@@ -72,7 +72,10 @@
     do {
 	char *result = NULL;
 	ssize_t length;
-	cap_t caps = cap_get_file(*argv);
+	cap_t caps;
+	char *filename;
+
+	caps = cap_get_file(unmetafy(dupstring(*argv), NULL));
 	if(caps)
 	    result = cap_to_text(caps, &length);
 	if (!caps || !result) {
@@ -99,8 +102,7 @@
     }
 
     do {
-	unmetafy(*argv, NULL);
-	if(cap_set_file(*argv, caps)) {
+	if(cap_set_file(unmetafy(dupstring(*argv, NULL)), caps)) {
 	    zwarnnam(nam, "%s: %e", *argv, errno);
 	    ret = 1;
 	}


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: caps strings
  2009-03-03 18:10   ` Peter Stephenson
@ 2009-03-03 18:21     ` Mikael Magnusson
  2009-03-03 18:31       ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Magnusson @ 2009-03-03 18:21 UTC (permalink / raw)
  To: Zsh hackers list

2009/3/3 Peter Stephenson <pws@csr.com>:
> On Tue, 3 Mar 2009 18:55:30 +0100
> Mikael Magnusson <mikachu@gmail.com> wrote:
>> I think the two zwarnnam calls with *argv needs them to be
>> re-metafy()ed. When i didn't do that in attr.c, I got output like
>> myutf8file\M-p.
>
> Index: Src/Modules/cap.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/Modules/cap.c,v
> retrieving revision 1.8
> diff -u -r1.8 cap.c
> --- Src/Modules/cap.c   3 Mar 2009 17:46:51 -0000       1.8
> +++ Src/Modules/cap.c   3 Mar 2009 18:09:50 -0000
> @@ -72,7 +72,10 @@
>     do {
>        char *result = NULL;
>        ssize_t length;
> -       cap_t caps = cap_get_file(*argv);
> +       cap_t caps;
> +       char *filename;

Where did this variable come from?

> +
> +       caps = cap_get_file(unmetafy(dupstring(*argv), NULL));
>        if(caps)
>            result = cap_to_text(caps, &length);
>        if (!caps || !result) {
> @@ -99,8 +102,7 @@
>     }
>
>     do {
> -       unmetafy(*argv, NULL);
> -       if(cap_set_file(*argv, caps)) {
> +       if(cap_set_file(unmetafy(dupstring(*argv, NULL)), caps)) {
>            zwarnnam(nam, "%s: %e", *argv, errno);
>            ret = 1;
>        }

Does dupstring somehow allocate from the stack? Should I use it
instead of re-metafy()ing in attr.c too, or maybe it doesn't really
matter which you do?

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: caps strings
  2009-03-03 18:21     ` Mikael Magnusson
@ 2009-03-03 18:31       ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2009-03-03 18:31 UTC (permalink / raw)
  To: Zsh hackers list

Mikael Magnusson wrote:
> Does dupstring somehow allocate from the stack?

Yes.

> Should I use it
> instead of re-metafy()ing in attr.c too, or maybe it doesn't really
> matter which you do?

It's not crucial; dupstring() is probably slightly neater.

pws


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-03 18:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-03 17:43 PATCH: caps strings Peter Stephenson
2009-03-03 17:55 ` Mikael Magnusson
2009-03-03 18:00   ` Mikael Magnusson
2009-03-03 18:10   ` Peter Stephenson
2009-03-03 18:21     ` Mikael Magnusson
2009-03-03 18:31       ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).