[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 60/87: trans/hello{, -mt}: properly escape contents in trivfs_app
From: |
Samuel Thibault |
Subject: |
[hurd] 60/87: trans/hello{, -mt}: properly escape contents in trivfs_append_args |
Date: |
Sun, 09 Nov 2014 11:05:04 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 74fc3df9e4ecd84b971904d3e14e5a710d941836
Author: Justus Winter <address@hidden>
Date: Thu Sep 4 12:48:32 2014 +0200
trans/hello{,-mt}: properly escape contents in trivfs_append_args
Fixes https://savannah.gnu.org/bugs/?15806 .
* trans/hello-mt.c (trivfs_append_args): Escape contents.
* trans/hello.c (trivfs_append_args): Likewise.
---
trans/hello-mt.c | 28 ++++++++++++++++++++++------
trans/hello.c | 21 +++++++++++++++++++--
2 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/trans/hello-mt.c b/trans/hello-mt.c
index ba9329a..44d54de 100644
--- a/trans/hello-mt.c
+++ b/trans/hello-mt.c
@@ -273,16 +273,32 @@ trivfs_append_args (struct trivfs_control *fsys,
{
error_t err;
char *opt;
+ size_t opt_len;
+ FILE *s;
+ char *c;
+
+ s = open_memstream (&opt, &opt_len);
+ fprintf (s, "--contents='");
pthread_rwlock_rdlock (&contents_lock);
- err = asprintf (&opt, "--contents=%s", contents) < 0 ? ENOMEM : 0;
+ for (c = contents; *c; c++)
+ switch (*c)
+ {
+ case 0x27: /* Single quote. */
+ fprintf (s, "'\"'\"'");
+ break;
+
+ default:
+ fprintf (s, "%c", *c);
+ }
pthread_rwlock_unlock (&contents_lock);
- if (!err)
- {
- err = argz_add (argz, argz_len, opt);
- free (opt);
- }
+ fprintf (s, "'");
+ fclose (s);
+
+ err = argz_add (argz, argz_len, opt);
+
+ free (opt);
return err;
}
diff --git a/trans/hello.c b/trans/hello.c
index 4e88c60..d1884df 100644
--- a/trans/hello.c
+++ b/trans/hello.c
@@ -246,9 +246,26 @@ trivfs_append_args (struct trivfs_control *fsys,
{
error_t err;
char *opt;
+ size_t opt_len;
+ FILE *s;
+ char *c;
- if (asprintf (&opt, "--contents=%s", contents) < 0)
- return ENOMEM;
+ s = open_memstream (&opt, &opt_len);
+ fprintf (s, "--contents='");
+
+ for (c = contents; *c; c++)
+ switch (*c)
+ {
+ case 0x27: /* Single quote. */
+ fprintf (s, "'\"'\"'");
+ break;
+
+ default:
+ fprintf (s, "%c", *c);
+ }
+
+ fprintf (s, "'");
+ fclose (s);
err = argz_add (argz, argz_len, opt);
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 51/87: Fix ifsock permission check, (continued)
- [hurd] 51/87: Fix ifsock permission check, Samuel Thibault, 2014/11/09
- [hurd] 55/87: libihash: fix comparison between signed and unsigned integer, Samuel Thibault, 2014/11/09
- [hurd] 54/87: trans/mtab: use setnullauth to drop privileges, Samuel Thibault, 2014/11/09
- [hurd] 21/87: ext2fs: fix compiler warning, Samuel Thibault, 2014/11/09
- [hurd] 49/87: Add missing linefeed, Samuel Thibault, 2014/11/09
- [hurd] 58/87: libdiskfs: fix /servers/exec lookup, Samuel Thibault, 2014/11/09
- [hurd] 59/87: hurd: make memory_object parameter polymorphic, Samuel Thibault, 2014/11/09
- [hurd] 61/87: procfs: fix typo in comment, Samuel Thibault, 2014/11/09
- [hurd] 53/87: libtrivfs: fix typo, Samuel Thibault, 2014/11/09
- [hurd] 64/87: BSD apps want sin_zero cleared in sys_getname., Samuel Thibault, 2014/11/09
- [hurd] 60/87: trans/hello{, -mt}: properly escape contents in trivfs_append_args,
Samuel Thibault <=
- [hurd] 66/87: exec: redzone page zero before loading anything, Samuel Thibault, 2014/11/09
- [hurd] 52/87: libdiskfs: fix reference counting of peropen objects, Samuel Thibault, 2014/11/09
- [hurd] 62/87: hurd: add symbolic name for the mtab translator, Samuel Thibault, 2014/11/09
- [hurd] 70/87: procfs: generalize the translator linkage code, Samuel Thibault, 2014/11/09
- [hurd] 56/87: hurd: fix semantic of file_get_children, Samuel Thibault, 2014/11/09
- [hurd] 47/87: Make the ncursesw driver of the console client compile properly, Samuel Thibault, 2014/11/09
- [hurd] 65/87: exec: add proper argument parsing, add --device-master-port, Samuel Thibault, 2014/11/09
- [hurd] 18/87: hurd: fix type of optimal_transfer_size, Samuel Thibault, 2014/11/09
- [hurd] 50/87: sutils: add urandom device target to MAKEDEV, Samuel Thibault, 2014/11/09
- [hurd] 45/87: Revert "libpipe: fix calls to pipe_send with no data", Samuel Thibault, 2014/11/09