From f260ae4bd74da633d309aacf55c8c5e40c3e1a8d Mon Sep 17 00:00:00 2001 From: ramonn Date: Tue, 22 Nov 2011 12:44:47 +0000 Subject: [PATCH] 2011-11-22 Ramon Novoa * pandora_windows_service.cc: Fixed a bug that resulted in a buffer overflow. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/win32/ChangeLog | 5 ++++ .../win32/pandora_windows_service.cc | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 3040c7ca77..b9ba7b61df 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,8 @@ +2011-11-22 Ramon Novoa + + * pandora_windows_service.cc: Fixed a bug that resulted in a buffer + overflow. + 2011-11-15 Ramon Novoa * build.sh, modules/pandora_module_odbc.cc, Makefile.am: Made diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 66d1072d14..879c9f60fa 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -216,17 +216,10 @@ Pandora_Windows_Service::pandora_init () { string name_agent, name; string proxy_mode, server_ip; int pos, num; - static unsigned char first_run = 0; + static unsigned char first_run = 1; setPandoraDebug (true); - // Add the util subdirectory to the PATH - util_dir = Pandora::getPandoraInstallDir (); - util_dir += "util"; - path = getenv ("PATH"); - env = "PATH=" + path + ";" + util_dir; - putenv (env.c_str ()); - conf_file = Pandora::getPandoraInstallDir (); conf_file += "pandora_agent.conf"; @@ -273,7 +266,6 @@ Pandora_Windows_Service::pandora_init () { } } - srand ((unsigned) time (0)); this->setSleepTime (this->interval); /*Check if proxy mode is set*/ @@ -292,8 +284,19 @@ Pandora_Windows_Service::pandora_init () { ((UDP_Server *)this->udp_server)->start (); } - if (first_run == 0) { - first_run = 1; + if (first_run == 1) { + first_run = 0; + + // Add the util subdirectory to the PATH + util_dir = Pandora::getPandoraInstallDir (); + util_dir += "util"; + path = getenv ("PATH"); + env = "PATH=" + path + ";" + util_dir; + putenv (env.c_str ()); + + // Set the seed for rand + srand ((unsigned) time (0)); + pandoraLog ("Pandora agent started"); } }