changes in HTTPS service checks (issue #1086)
authorVictor Kirhenshtein <victor@netxms.org>
Sat, 14 May 2016 11:24:23 +0000 (14:24 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Sat, 14 May 2016 11:24:23 +0000 (14:24 +0300)
ChangeLog
src/agent/subagents/portCheck/http.cpp

index ed997bd..e91f21e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,7 +13,7 @@
        - DCI filter in DCI selection dialog
 - Android console
        - Reorganized alarm notification section (issue #1194)
-- Fixed issues: #859, #1194, #1195, #1197, #1200
+- Fixed issues: #859, #1086, #1194, #1195, #1196, #1197, #1200
 
 
 *
index f5f2b2a..4169657 100644 (file)
@@ -16,9 +16,7 @@
 static void SaveResponse(char *host, UINT32 ip, char *buffer)
 {
    if (g_szFailedDir[0] == 0)
-   {
       return;
-   }
 
    time_t now = time(NULL);
    char fileName[2048];
@@ -146,7 +144,6 @@ int CheckHTTP(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHos
                                                else 
                   {
                                                        safe_free_and_null(buff);
-                                                       buffSize = 0;
                      break;
                                                }
                                        }
@@ -171,7 +168,7 @@ int CheckHTTP(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHos
             }
                        }
 
-         safe_free(buff);
+         free(buff);
                }
                NetClose(nSd);
        }
@@ -181,7 +178,6 @@ int CheckHTTP(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHos
        }
 
        regfree(&preg);
-
        return nRet;
 }
 
@@ -280,7 +276,7 @@ int CheckHTTPS(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHo
 
                      int i;
                      int offset = 0;
-                     while (true)
+                     while(offset < BUFSIZE - 1)
                      {
                         i = BIO_read(out, buffer + offset, BUFSIZE - offset - 1);
                         if (i == 0)
@@ -293,7 +289,8 @@ int CheckHTTPS(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHo
                            {
                               continue;
                            }
-                           AgentWriteDebugLog(7, _T("PortCheck: BIO_read failed"));
+                           AgentWriteDebugLog(7, _T("PortCheck: BIO_read failed (offset=%d)"), offset);
+                           buffer[0] = 0;  // do not check incomplete buffer
                            break;
                         }
                         offset += i;
@@ -311,7 +308,7 @@ int CheckHTTPS(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHo
                         }
                      }
 
-                     safe_free(buffer);
+                     free(buffer);
                   }
                }
                BIO_free_all(out);
@@ -334,7 +331,6 @@ int CheckHTTPS(char *szAddr, UINT32 dwAddr, short nPort, char *szURI, char *szHo
    }
 
    regfree(&preg);
-
    return ret;
 
 #else