Re: [Cppcms-users] [BUG] Custom 'syslog.id' and 'openlog'
Brought to you by:
artyom-beilis
From: Artyom B. <art...@gm...> - 2017-02-22 06:43:01
|
Ok, Thanks for the report!!! Can you please open the ticket? I'll fix it in trunk, Artyom On Tue, Feb 21, 2017 at 1:49 AM, Nazım Can Bedir <naz...@ne...> wrote: > Hi Artyom, > > For any reason, if user needs to specify custom syslog.id value; CppCMS is > calling 'openlog' function with id variable stored on the stack. > > According to > > man page at https://linux.die.net/man/3/openlog, and > this Debian bug report at > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=102350 > > 'openlog' is free to use given 'ident' pointer as-is (without making a copy > of it). Even on Ubuntu 16.04 system, it's not copying given ident. > > In the following code excerpt, the pointer given at the line colored with > red will point to invalid memory location at the moment code reach to end of > active if block. > > service.cpp > > if(settings.get("logging.syslog.enable",false)==true) { > #ifndef CPPCMS_POSIX > throw cppcms_error("Syslog is not availible on Windows"); > #else > std::string id = settings.get("logging.syslog.id",""); > std::vector<std::string> vops = > settings.get("logging.syslog.options",std::vector<std::string>()); > std::string sfacility = settings.get("logging.syslog.options",""); > int ops = 0; > for(unsigned i=0;i<vops.size();i++) { > std::string const &op=vops[i]; > if(op=="LOG_CONS") ops|=LOG_CONS; > else if(op=="LOG_NDELAY") ops|=LOG_NDELAY; > else if(op=="LOG_NOWAIT") ops|=LOG_NOWAIT; > else if(op=="LOG_ODELAY") ops|=LOG_ODELAY; > #ifdef LOG_PERROR > else if(op=="LOG_PERROR") ops|=LOG_PERROR; > #endif > else if(op=="LOG_PID") ops|=LOG_PID; > } > if(id.empty()) > ::openlog(0,ops,0); > else > ::openlog(id.c_str(),ops,0); > logger::instance().add_sink(booster::shared_ptr<sink>(new > sinks::syslog())); > #endif > } > > std::string log_file; > > Regards, > Nazim Can. > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |