if StrBuf_ServGetln() is called in a loop, its return value has to be checked for...
[citadel.git] / webcit / serv_func.c
index 50bf1f771d993d5f306d67fd9ece24090d53562e..f4162a5a0e84ed87dc8ec71bc5bca0d537e84092 100644 (file)
@@ -54,6 +54,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent)
        ServInfo *info;
        StrBuf *Buf;
        int a;
+       int rc;
 
        Buf = NewStrBuf();
 
@@ -100,7 +101,11 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent)
        info = (ServInfo*)malloc(sizeof(ServInfo));
        memset(info, 0, sizeof(ServInfo));
        a = 0;
-       while (StrBuf_ServGetln(Buf), (strcmp(ChrPtr(Buf), "000")!= 0)) {
+       while (rc = StrBuf_ServGetln(Buf),
+              (rc >= 0) &&
+              ((rc != 3) || 
+               strcmp(ChrPtr(Buf), "000")))
+       {
                switch (a) {
                case 0:
                        info->serv_pid = StrToi(Buf);