From 88cdeed0922c31f523ee91987675bd8fa6c61d27 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Fri, 15 Apr 2022 11:23:47 +0200 Subject: [PATCH] Fixed bad parser error message on "socat /tmp/x\"x/x -" --- CHANGES | 2 ++ xioopen.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 716680c..ede923c 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,8 @@ Corrections: instead of a free port in range 640..1023 Test: UDP_LOWPORT + Fixed bad parser error message on "socat /tmp/x\"x/x -" + Porting: OpenSSL, at least 1.1 on Ubuntu, crashed with SIGSEGV under certain conditions: client connection to server with certificate with empty diff --git a/xioopen.c b/xioopen.c index d1eca2c..d822e38 100644 --- a/xioopen.c +++ b/xioopen.c @@ -494,6 +494,7 @@ static xiosingle_t *xioparse_single(const char **addr) { char token[512], *tokp; size_t len; int i; + int result; /* init */ i = 0; @@ -510,9 +511,12 @@ static xiosingle_t *xioparse_single(const char **addr) { sfd->argc = 0; len = sizeof(token); tokp = token; - if (nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests, - true, true, false) < 0) { + result = nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests, + true, true, false); + if (result < 0) { Error2("keyword too long, in address \"%s%s\"", token, *addr); + } else if (result > 0){ + Error1("unexpected end of address \"%s\"", *addr); } *tokp = '\0'; /*! len? */ ae = (struct addrname *) @@ -564,9 +568,12 @@ static xiosingle_t *xioparse_single(const char **addr) { while (!strncmp(*addr, xioopts.paramsep, strlen(xioopts.paramsep))) { *addr += strlen(xioopts.paramsep); len = sizeof(token); tokp = token; - if (nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests, - true, true, false) != 0) { - Error1("syntax error in address \"%s\"", addr0); + result = nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests, + true, true, false); + if (result < 0) { + Error1("address \"%s\" too long", addr0); + } else if (result > 0){ + Error1("unexpected end of address \"%s\"", addr0); } *tokp = '\0'; if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {