X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgenconf%2Fparse_confnode.c;h=5c8202bdf99e694df64e31211e3fe0d6faf8050f;hb=5dbaf53aa2c6187d464108e360621ebfff6e0bc4;hp=b4da9dd5107e96efbbeff138d592157eed4a1e04;hpb=504b523d94543a7bb7301a3b1bfe929aabf7fb36;p=libcmdline.git diff --git a/src/genconf/parse_confnode.c b/src/genconf/parse_confnode.c index b4da9dd..5c8202b 100644 --- a/src/genconf/parse_confnode.c +++ b/src/genconf/parse_confnode.c @@ -142,20 +142,13 @@ parse_conf_node(cmdline_parse_token_hdr_t *tk, const char *buf, void *res) struct confnode *n; struct confnode_list l; unsigned int token_len = 0; - char token[BUFSIZ]; + char token[CMDLINE_MAX_TOKEN_SIZE]; - if (*buf == 0) + /* if token is too big... */ + token_len = snprintf(token, sizeof(token), "%s", buf); + if (token_len >= sizeof(token)) return -1; - while(!cmdline_isendoftoken(buf[token_len])) - token_len++; - - if (token_len > sizeof(token) - 1) - return -1; - - memcpy(token, buf, token_len); - token[token_len] = '\0'; - TAILQ_INIT(&l); /* absolute path */ @@ -181,7 +174,7 @@ parse_conf_node(cmdline_parse_token_hdr_t *tk, const char *buf, void *res) if (res) *(struct confnode **)res = TAILQ_FIRST(&l); - return token_len; + return token_len; } int complete_get_nb_conf_node(cmdline_parse_token_hdr_t *tk)