diff options
author | brian <brian@FreeBSD.org> | 1999-12-27 11:43:31 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-12-27 11:43:31 +0000 |
commit | 8d3683f53b3d5744a2026aa9b81196dd6a4a4a1b (patch) | |
tree | 94166715268d35a6faf276b4828f0f243857c33c /usr.sbin | |
parent | 216d01507f39e9ea892e22ba17d9f7bc780aca8b (diff) | |
download | FreeBSD-src-8d3683f53b3d5744a2026aa9b81196dd6a4a4a1b.zip FreeBSD-src-8d3683f53b3d5744a2026aa9b81196dd6a4a4a1b.tar.gz |
Don't allowt '#' as a comment when it's embedded in quotes:
set something "xxx yyy # zzz" aaa
shouldn't be interpreted as
set something "xxx yyy" aaa
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/auth.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/chat.c | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/command.c | 2 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.c | 11 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.h | 5 | ||||
-rw-r--r-- | usr.sbin/ppp/exec.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/systems.c | 33 |
7 files changed, 34 insertions, 33 deletions
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index cc22b5e..62a525f1 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -117,7 +117,7 @@ auth_SetPhoneList(const char *name, char *phone, int phonelen) continue; buff[strlen(buff) - 1] = '\0'; memset(vector, '\0', sizeof vector); - if ((n = MakeArgs(buff, vector, VECSIZE(vector), 1)) < 0) + if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0) log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno); if (n < 5) continue; @@ -168,7 +168,7 @@ auth_Select(struct bundle *bundle, const char *name) continue; buff[strlen(buff) - 1] = '\0'; memset(vector, '\0', sizeof vector); - if ((n = MakeArgs(buff, vector, VECSIZE(vector), 1)) < 0) + if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0) log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno); if (n < 2) continue; @@ -227,7 +227,7 @@ auth_Validate(struct bundle *bundle, const char *name, continue; buff[strlen(buff) - 1] = 0; memset(vector, '\0', sizeof vector); - if ((n = MakeArgs(buff, vector, VECSIZE(vector), 1)) < 0) + if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0) log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno); if (n < 2) continue; @@ -271,7 +271,7 @@ auth_GetSecret(struct bundle *bundle, const char *name, int len, if (buff[n] == '\n') buff[n] = '\0'; /* Trim the '\n' */ memset(vector, '\0', sizeof vector); - if ((n = MakeArgs(buff, vector, VECSIZE(vector), 1)) < 0) + if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0) log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno); if (n < 2) continue; diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index 499bc98..c6acdb1 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -561,7 +561,7 @@ chat_Setup(struct chat *c, const char *data, const char *phone) } else { strncpy(c->script, data, sizeof c->script - 1); c->script[sizeof c->script - 1] = '\0'; - c->argc = MakeArgs(c->script, c->argv, VECSIZE(c->argv), 0); + c->argc = MakeArgs(c->script, c->argv, VECSIZE(c->argv), PARSE_NOHASH); } c->arg = -1; @@ -702,7 +702,8 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) int stat, nb, argc, i; log_Printf(LogCHAT, "Exec: %s\n", command); - if ((argc = MakeArgs(command, vector, VECSIZE(vector), 1)) <= 0) { + if ((argc = MakeArgs(command, vector, VECSIZE(vector), + PARSE_REDUCE|PARSE_NOHASH)) <= 0) { if (argc < 0) log_Printf(LogWARN, "Syntax error in exec command\n"); *out = '\0'; diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 5ec071a..98ad92b 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -913,7 +913,7 @@ command_Interpret(char *buff, int nb, char *argv[MAXARGS]) cp = buff + strcspn(buff, "\r\n"); if (cp) *cp = '\0'; - return MakeArgs(buff, argv, MAXARGS, 1); + return MakeArgs(buff, argv, MAXARGS, PARSE_REDUCE); } return 0; } diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c index 31d355e..bf7492d 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -264,14 +264,14 @@ IntToSpeed(int nspeed) } char * -findblank(char *p, int reduce) +findblank(char *p, int flags) { int instring; instring = 0; while (*p) { if (*p == '\\') { - if (reduce) { + if (flags & PARSE_REDUCE) { memmove(p, p + 1, strlen(p)); if (!*p) break; @@ -281,7 +281,8 @@ findblank(char *p, int reduce) memmove(p, p + 1, strlen(p)); instring = !instring; continue; - } else if (!instring && (issep(*p) || *p == '#')) + } else if (!instring && (issep(*p) || + (*p == '#' && !(flags & PARSE_NOHASH)))) return p; p++; } @@ -290,7 +291,7 @@ findblank(char *p, int reduce) } int -MakeArgs(char *script, char **pvect, int maxargs, int reduce) +MakeArgs(char *script, char **pvect, int maxargs, int flags) { int nargs; @@ -302,7 +303,7 @@ MakeArgs(char *script, char **pvect, int maxargs, int reduce) break; *pvect++ = script; nargs++; - script = findblank(script, reduce); + script = findblank(script, flags); if (script == NULL) return -1; else if (*script == '#') diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index 2cd375b..a47c12e 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -91,6 +91,11 @@ #define PHYS_FOREGROUND 64 /* Pseudo mode, same as background */ #define PHYS_ALL 127 +/* flags passed to findblank() and MakeArgs() */ +#define PARSE_NORMAL 0 +#define PARSE_REDUCE 1 +#define PARSE_NOHASH 2 + extern void randinit(void); extern ssize_t fullread(int, void *, size_t); extern const char *mode2Nam(int); diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c index cc89964..e9bf01a 100644 --- a/usr.sbin/ppp/exec.c +++ b/usr.sbin/ppp/exec.c @@ -141,7 +141,8 @@ exec_Create(struct physical *p) log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); - if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), 1)) < 0) { + if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), + PARSE_REDUCE|PARSE_NOHASH)) < 0) { log_Printf(LogWARN, "Syntax error in exec command\n"); _exit(127); } diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index 9574648..a570ceb 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -265,28 +265,22 @@ xgets(char *buf, int buflen, FILE *fp) static char * GetLabel(char *line, const char *filename, int linenum) { - char *wp; - - if ((wp = findblank(line, 1)) != NULL) { - while (issep(*wp)) - *wp++ = '\0'; - if (*wp == '#') - *wp = '\0'; - if (*wp != '\0') { - log_Printf(LogWARN, "Bad label in %s (line %d) - too many words.\n", - filename, linenum); - return NULL; - } - } - wp = strchr(line, ':'); - if (wp == NULL || wp[1] != '\0') { - log_Printf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n", + char *argv[MAXARGS]; + int argc, len; + + argc = MakeArgs(line, argv, MAXARGS, PARSE_REDUCE); + + if (argc == 2 && !strcmp(argv[1], ":")) + return argv[0]; + + if (argc != 1 || (len = strlen(argv[0])) < 2 || argv[0][len-1] != ':') { + log_Printf(LogWARN, "Bad label in %s (line %d) - missing colon\n", filename, linenum); return NULL; } - *wp = '\0'; + argv[0][len-1] = '\0'; /* Lose the ':' */ - return line; + return argv[0]; } /* Returns -2 for ``file not found'' and -1 for ``label not found'' */ @@ -349,7 +343,6 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, default: if ((cp = GetLabel(cp, filename, linenum)) == NULL) continue; - cp = strip(cp); /* lose any spaces between the label and the ':' */ if (strcmp(cp, name) == 0) { /* We're in business */ @@ -365,7 +358,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, if (!indent) { /* start of next section */ if (*cp != '!' && how == SYSTEM_EXEC) - GetLabel(cp, filename, linenum); + cp = GetLabel(cp, filename, linenum); break; } |