mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 15:32:35 +00:00
Fixed return value of nestlex()
This commit is contained in:
parent
98028900e0
commit
0219d6ac27
2 changed files with 53 additions and 10 deletions
2
CHANGES
2
CHANGES
|
@ -23,6 +23,8 @@ corrections:
|
|||
Test: ABSTRACT_BIND
|
||||
Thanks to Denis Shatov for reporting this bug.
|
||||
|
||||
Fixed return value of nestlex()
|
||||
|
||||
####################### V 1.7.2.4:
|
||||
|
||||
corrections:
|
||||
|
|
61
xioopts.c
61
xioopts.c
|
@ -1826,7 +1826,11 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
|
|||
parsres =
|
||||
nestlex(a, &tokp, &len, endkey, hquotes, squotes, nests,
|
||||
true, true, false);
|
||||
if (parsres != 0) {
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", *a);
|
||||
return -1;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", *a);
|
||||
return -1;
|
||||
}
|
||||
if (tokp == token) {
|
||||
|
@ -1861,7 +1865,11 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
|
|||
parsres =
|
||||
nestlex(a, &tokp, &len, endval, hquotes, squotes, nests,
|
||||
true, true, false);
|
||||
if (parsres != 0) {
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", *a);
|
||||
return -1;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", *a);
|
||||
return -1;
|
||||
}
|
||||
*tokp = '\0';
|
||||
|
@ -2339,9 +2347,17 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
|
|||
/* parse first IP address, expect ':' */
|
||||
tokp = token;
|
||||
/*! result= */
|
||||
nestlex((const char **)&tokp, &buffp, &bufspc,
|
||||
ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
parsres =
|
||||
nestlex((const char **)&tokp, &buffp, &bufspc,
|
||||
ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", *a);
|
||||
return -1;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", *a);
|
||||
return -1;
|
||||
}
|
||||
if (*tokp != ':') {
|
||||
Error1("syntax in option %s: missing ':'", token);
|
||||
}
|
||||
|
@ -2352,9 +2368,17 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
|
|||
/* parse second IP address, expect ':' or '\0'' */
|
||||
buffp = buff;
|
||||
/*! result= */
|
||||
nestlex((const char **)&tokp, &buffp, &bufspc,
|
||||
ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
parsres =
|
||||
nestlex((const char **)&tokp, &buffp, &bufspc,
|
||||
ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", *a);
|
||||
return -1;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", *a);
|
||||
return -1;
|
||||
}
|
||||
*buffp++ = '\0';
|
||||
(*opts)[i].value.u_ip_mreq.param2 = strdup(buff); /*!!! NULL */
|
||||
|
||||
|
@ -2392,9 +2416,17 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
|
|||
char buff[512], *buffp=buff; size_t bufspc = sizeof(buff)-1;
|
||||
|
||||
tokp = token;
|
||||
parsres =
|
||||
nestlex((const char **)&tokp, &buffp, &bufspc,
|
||||
ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", *a);
|
||||
return -1;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", *a);
|
||||
return -1;
|
||||
}
|
||||
if (*tokp != '\0') {
|
||||
Error1("trailing data in option \"%s\"", token);
|
||||
}
|
||||
|
@ -2841,6 +2873,7 @@ int retropt_bind(struct opt *opts,
|
|||
char *bindname, *bindp;
|
||||
char hostname[512], *hostp = hostname, *portp = NULL;
|
||||
size_t hostlen = sizeof(hostname)-1;
|
||||
int parsres;
|
||||
int result;
|
||||
|
||||
if (retropt_string(opts, OPT_BIND, &bindname) < 0) {
|
||||
|
@ -2874,8 +2907,16 @@ int retropt_bind(struct opt *opts,
|
|||
case AF_INET6:
|
||||
#endif /*WITH_IP6 */
|
||||
portallowed = (feats>=2);
|
||||
nestlex((const char **)&bindp, &hostp, &hostlen, ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
parsres =
|
||||
nestlex((const char **)&bindp, &hostp, &hostlen, ends, NULL, NULL, nests,
|
||||
true, false, false);
|
||||
if (parsres < 0) {
|
||||
Error1("option too long: \"%s\"", bindp);
|
||||
return STAT_NORETRY;
|
||||
} else if (parsres > 0) {
|
||||
Error1("syntax error in \"%s\"", bindp);
|
||||
return STAT_NORETRY;
|
||||
}
|
||||
*hostp++ = '\0';
|
||||
if (!strncmp(bindp, portsep, strlen(portsep))) {
|
||||
if (!portallowed) {
|
||||
|
|
Loading…
Reference in a new issue