static int fp_getline(FILE *fp, ConfigArgs *c);
static void fp_getline_init(ConfigArgs *c);
-static char *strtok_quote(char *line, char *sep, char **quote_ptr);
+static char *strtok_quote(char *line, char *sep, char **quote_ptr, int *inquote);
static char *strtok_quote_ldif(char **line);
ConfigArgs *
static char *
-strtok_quote( char *line, char *sep, char **quote_ptr )
+strtok_quote( char *line, char *sep, char **quote_ptr, int *iqp )
{
int inquote;
char *tmp;
break;
}
}
+ *iqp = inquote;
return( tmp );
}
};
char *quote_ptr;
int i = (int)(sizeof(hide)/sizeof(hide[0])) - 1;
+ int inquote = 0;
c->tline = ch_strdup(c->line);
- token = strtok_quote(c->tline, " \t", "e_ptr);
+ token = strtok_quote(c->tline, " \t", "e_ptr, &inquote);
if(token) for(i = 0; hide[i]; i++) if(!strcasecmp(token, hide[i])) break;
if(quote_ptr) *quote_ptr = ' ';
- Debug(LDAP_DEBUG_CONFIG, "line %d (%s%s)\n", c->lineno,
+ Debug(LDAP_DEBUG_CONFIG, "%s (%s%s)\n", c->log,
hide[i] ? hide[i] : c->line, hide[i] ? " ***" : "");
if(quote_ptr) *quote_ptr = '\0';
- for(;; token = strtok_quote(NULL, " \t", "e_ptr)) {
+ for(;; token = strtok_quote(NULL, " \t", "e_ptr, &inquote)) {
if(c->argc >= c->argv_size) {
char **tmp;
tmp = ch_realloc(c->argv, (c->argv_size + ARGS_STEP) * sizeof(*c->argv));
if(!tmp) {
- Debug(LDAP_DEBUG_ANY, "line %d: out of memory\n", c->lineno, 0, 0);
+ Debug(LDAP_DEBUG_ANY, "%s: out of memory\n", c->log, 0, 0);
return -1;
}
c->argv = tmp;
break;
c->argv[c->argc++] = token;
}
+ if (inquote) {
+ Debug(LDAP_DEBUG_ANY, "%s: unterminated quoted string \"%s\"\n", c->log, c->argv[c->argc-1], 0);
+ return -1;
+ }
c->argv[c->argc] = NULL;
return(0);
}