summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/auth.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-12-20 20:30:02 +0000
committerbrian <brian@FreeBSD.org>1999-12-20 20:30:02 +0000
commit4145fb0c1be9e8321d6d4e6f465453c2cc0aed50 (patch)
treefce823325831d2a7126e8d74c67c40f44d69b13c /usr.sbin/ppp/auth.c
parentff8174b1b3e9f7d40f556d9af0d8168f7b81cefa (diff)
downloadFreeBSD-src-4145fb0c1be9e8321d6d4e6f465453c2cc0aed50.zip
FreeBSD-src-4145fb0c1be9e8321d6d4e6f465453c2cc0aed50.tar.gz
Notice and warn about unterminated quoted strings in commands.
The entire command is ignored if the syntax is invalid...
Diffstat (limited to 'usr.sbin/ppp/auth.c')
-rw-r--r--usr.sbin/ppp/auth.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index e6020d4..7c66fcd 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -104,18 +104,21 @@ int
auth_SetPhoneList(const char *name, char *phone, int phonelen)
{
FILE *fp;
- int n;
+ int n, lineno;
char *vector[6];
char buff[LINE_LEN];
fp = OpenSecret(SECRETFILE);
+ lineno = 0;
if (fp != NULL) {
while (fgets(buff, sizeof buff, fp)) {
+ lineno++;
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = '\0';
memset(vector, '\0', sizeof vector);
- n = MakeArgs(buff, vector, VECSIZE(vector));
+ if ((n = MakeArgs(buff, vector, VECSIZE(vector))) < 0)
+ log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
if (n < 5)
continue;
if (strcmp(vector[0], name) == 0) {
@@ -137,7 +140,7 @@ int
auth_Select(struct bundle *bundle, const char *name)
{
FILE *fp;
- int n;
+ int n, lineno;
char *vector[5];
char buff[LINE_LEN];
@@ -157,13 +160,16 @@ auth_Select(struct bundle *bundle, const char *name)
#endif
fp = OpenSecret(SECRETFILE);
+ lineno = 0;
if (fp != NULL) {
while (fgets(buff, sizeof buff, fp)) {
+ lineno++;
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = '\0';
memset(vector, '\0', sizeof vector);
- n = MakeArgs(buff, vector, VECSIZE(vector));
+ if ((n = MakeArgs(buff, vector, VECSIZE(vector))) < 0)
+ log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
if (n < 2)
continue;
if (strcmp(vector[0], name) == 0) {
@@ -208,18 +214,21 @@ auth_Validate(struct bundle *bundle, const char *name,
/* Used by PAP routines */
FILE *fp;
- int n;
+ int n, lineno;
char *vector[5];
char buff[LINE_LEN];
fp = OpenSecret(SECRETFILE);
+ lineno = 0;
if (fp != NULL) {
while (fgets(buff, sizeof buff, fp)) {
+ lineno++;
if (buff[0] == '#')
continue;
buff[strlen(buff) - 1] = 0;
memset(vector, '\0', sizeof vector);
- n = MakeArgs(buff, vector, VECSIZE(vector));
+ if ((n = MakeArgs(buff, vector, VECSIZE(vector))) < 0)
+ log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
if (n < 2)
continue;
if (strcmp(vector[0], name) == 0) {
@@ -245,7 +254,7 @@ auth_GetSecret(struct bundle *bundle, const char *name, int len,
/* Used by CHAP routines */
FILE *fp;
- int n;
+ int n, lineno;
char *vector[5];
static char buff[LINE_LEN]; /* vector[] will point here when returned */
@@ -253,14 +262,17 @@ auth_GetSecret(struct bundle *bundle, const char *name, int len,
if (fp == NULL)
return (NULL);
+ lineno = 0;
while (fgets(buff, sizeof buff, fp)) {
+ lineno++;
if (buff[0] == '#')
continue;
n = strlen(buff) - 1;
if (buff[n] == '\n')
buff[n] = '\0'; /* Trim the '\n' */
memset(vector, '\0', sizeof vector);
- n = MakeArgs(buff, vector, VECSIZE(vector));
+ if ((n = MakeArgs(buff, vector, VECSIZE(vector))) < 0)
+ log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
if (n < 2)
continue;
if (strlen(vector[0]) == len && strncmp(vector[0], name, len) == 0) {
OpenPOWER on IntegriCloud