]> git.pond.sub.org Git - empserver/commitdiff
(recvline): Cope with multiple-digit ids. Server doesn't send such
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Dec 2007 07:36:27 +0000 (07:36 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Dec 2007 07:36:27 +0000 (07:36 +0000)
ids at this time.

src/client/expect.c

index 7e27b515df39e9b4c37ea2eba81055c3e604f941..cb0e9571ce2d9f370a6eb459ae50a3ad3cec2041 100644 (file)
@@ -45,6 +45,7 @@
 #include <unistd.h>
 #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