From c9c9305c2fdc54558f23fd65d7042f129efb7e5b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 14 Dec 2007 07:36:27 +0000 Subject: [PATCH] (recvline): Cope with multiple-digit ids. Server doesn't send such ids at this time. --- src/client/expect.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/client/expect.c b/src/client/expect.c index 7e27b515d..cb0e9571c 100644 --- a/src/client/expect.c +++ b/src/client/expect.c @@ -45,6 +45,7 @@ #include #endif #include "misc.h" +#include "proto.h" #ifdef _WIN32 #define read(sock, buffer, buf_size) \ @@ -57,9 +58,10 @@ int recvline(int s, char *buf) { int sz = 1024; - char *bp; + char *bp, *end; char ch; ssize_t n; + long id; bp = buf; for (;;) { @@ -83,11 +85,14 @@ recvline(int s, char *buf) *bp++ = ch; *bp = 0; - if (!isxdigit(buf[0]) || buf[1] != ' ') { - fprintf(stderr, "Malformed line %s\n", buf); - return 0; + id = strtol(buf, &end, 16); + if (end == buf || *end != ' ') { + fprintf(stderr, "Malformed id in line %s", buf); + id = -1; } - return strtol(buf, NULL, 16); + if (id > C_LAST) + id = -1; + return id; } int -- 2.43.0