From 5c3b3dfe12a7e953935a5cb4b2759f77a5a0806d Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Tue, 19 Oct 1999 22:15:11 +0000 Subject: [PATCH] (parse_binding): handle line with no whitespace before = (krb5_config_parse_file_debug): set lineno earlier so that we don't use it unitialized git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7193 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/config_file.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/krb5/config_file.c b/lib/krb5/config_file.c index 0f579b2c2..d3f488c45 100644 --- a/lib/krb5/config_file.c +++ b/lib/krb5/config_file.c @@ -151,25 +151,17 @@ parse_binding(FILE *f, unsigned *lineno, char *p, char **error_message) { krb5_config_binding *tmp; - char *p1; + char *p1, *p2; int ret = 0; p1 = p; - while (*p && !isspace((unsigned char)*p)) + while (*p && *p != '=' && !isspace((unsigned char)*p)) ++p; if (*p == '\0') { *error_message = "no ="; return -1; } - *p = '\0'; - tmp = malloc(sizeof(*tmp)); - if (tmp == NULL) { - *error_message = "out of memory"; - return -1; - } - tmp->name = strdup(p1); - tmp->next = NULL; - ++p; + p2 = p; while (isspace((unsigned char)*p)) ++p; if (*p != '=') { @@ -179,6 +171,14 @@ parse_binding(FILE *f, unsigned *lineno, char *p, ++p; while(isspace((unsigned char)*p)) ++p; + tmp = malloc(sizeof(*tmp)); + if (tmp == NULL) { + *error_message = "out of memory"; + return -1; + } + *p2 = '\0'; + tmp->name = strdup(p1); + tmp->next = NULL; if (*p == '{') { tmp->type = krb5_config_list; tmp->u.list = NULL; @@ -219,13 +219,13 @@ krb5_config_parse_file_debug (const char *fname, s = NULL; b = NULL; + *lineno = 0; f = fopen (fname, "r"); if (f == NULL) { *error_message = "cannot open file"; return -1; } *res = NULL; - *lineno = 0; while (fgets(buf, sizeof(buf), f) != NULL) { char *p;