diff options
author | wkoszek <wkoszek@FreeBSD.org> | 2007-05-12 22:37:52 +0000 |
---|---|---|
committer | wkoszek <wkoszek@FreeBSD.org> | 2007-05-12 22:37:52 +0000 |
commit | 542df97fc9c459380269954857d9f515488ca7ab (patch) | |
tree | 7dc03d779c719986d7a33725e07f40530405b872 /usr.sbin/config | |
parent | 4ee2adff4ad71c701de1e3070c3e78301778c3ef (diff) | |
download | FreeBSD-src-542df97fc9c459380269954857d9f515488ca7ab.zip FreeBSD-src-542df97fc9c459380269954857d9f515488ca7ab.tar.gz |
This is loser's commit message:
Remember about tricky cases, where options contain unfriendly characters,
from the ANSI-C string point of view ('"' in this case). The x09 build
breakage was caused by SC_CUT_SEPCHARS options.
I did test this patch number of times; each time unprofessionally and
inappropriately.
OKed by: cognet (mentor)
Diffstat (limited to 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/main.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index aede132..c0c6b2a 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -52,6 +52,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <stdio.h> +#include <string.h> #include <sysexits.h> #include <unistd.h> #include <dirent.h> @@ -397,6 +398,7 @@ configfile_dynamic(struct sbuf *sb) struct device *d; struct opt *ol; char *lend; + unsigned int i; asprintf(&lend, "\\n\\\n"); assert(lend != NULL); @@ -413,7 +415,16 @@ configfile_dynamic(struct sbuf *sb) continue; sbuf_printf(sb, "options\t%s", ol->op_name); if (ol->op_value != NULL) { - sbuf_printf(sb, "=%s%s", ol->op_value, lend); + sbuf_putc(sb, '='); + for (i = 0; i < strlen(ol->op_value); i++) { + if (ol->op_value[i] == '"') + sbuf_printf(sb, "\\%c", + ol->op_value[i]); + else + sbuf_printf(sb, "%c", + ol->op_value[i]); + } + sbuf_printf(sb, "%s", lend); } else { sbuf_printf(sb, "%s", lend); } |