summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorwkoszek <wkoszek@FreeBSD.org>2007-05-12 22:37:52 +0000
committerwkoszek <wkoszek@FreeBSD.org>2007-05-12 22:37:52 +0000
commit542df97fc9c459380269954857d9f515488ca7ab (patch)
tree7dc03d779c719986d7a33725e07f40530405b872 /usr.sbin/config
parent4ee2adff4ad71c701de1e3070c3e78301778c3ef (diff)
downloadFreeBSD-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.c13
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);
}
OpenPOWER on IntegriCloud