if StrBuf_ServGetln() is called in a loop, its return value has to be checked for...
[citadel.git] / webcit / serv_func.c
index 6e9b3001c1c16117fb1214bd39c1f19b05a5cb98..0c89245516b225e459433d0ba970a0ef5863067a 100644 (file)
@@ -50,6 +50,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent)
        ServInfo *info;
        StrBuf *Buf;
        int a;
+       int rc;
 
        Buf = NewStrBuf();
 
@@ -96,7 +97,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);