summaryrefslogtreecommitdiff
path: root/src/Logger.cc
Commit message (Collapse)AuthorAgeFilesLines
* Logger: Fix format string overflow in writeHeader()Alexander Egorenkov2023-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This problem occurred on a 32-bit ARM OpenWRT router running Linux 6.1. The method writeHeader() assumes that the size of struct timeval is 8 bytes which is not true on this machine, it is 16 bytes large. Therefore, first cast tv.tv_usec to the unsigned long type. ========= GDB trace ========= (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. 0xb6f4f9b4 in memchr (src=src@entry=0x3b6a, c=c@entry=0x0, n=n@entry=0x7fffffff) at src/string/memchr.c:16 16 for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--); 0xb6f4f98c <memchr+12>: 00 00 52 e3 cmp r2, #0 0xb6f4f990 <memchr+16>: 00 30 a0 e1 mov r3, r0 0xb6f4f994 <memchr+20>: 05 00 00 1a bne 0xb6f4f9b0 <memchr+48> 0xb6f4f998 <memchr+24>: 32 00 00 ea b 0xb6f4fa68 <memchr+232> 0xb6f4f99c <memchr+28>: 03 00 13 e3 tst r3, #3 0xb6f4f9a0 <memchr+32>: 01 20 42 e2 sub r2, r2, #1 0xb6f4f9a4 <memchr+36>: 36 00 00 0a beq 0xb6f4fa84 <memchr+260> 0xb6f4f9a8 <memchr+40>: 00 00 52 e3 cmp r2, #0 0xb6f4f9ac <memchr+44>: 2d 00 00 0a beq 0xb6f4fa68 <memchr+232> 0xb6f4f9b0 <memchr+48>: 03 00 a0 e1 mov r0, r3 => 0xb6f4f9b4 <memchr+52>: 01 c0 d3 e4 ldrb r12, [r3], #1 0xb6f4f9b8 <memchr+56>: 01 00 5c e1 cmp r12, r1 0xb6f4f9bc <memchr+60>: f6 ff ff 1a bne 0xb6f4f99c <memchr+28> (gdb) bt #0 0xb6f4f9b4 in memchr (src=src@entry=0x3b6a, c=c@entry=0x0, n=n@entry=0x7fffffff) at src/string/memchr.c:16 #1 0xb6f512b4 in strnlen (s=s@entry=0x3b6a <error: Cannot access memory at address 0x3b6a>, n=n@entry=0x7fffffff) at src/string/strnlen.c:5 #2 0xb6f19eb4 in printf_core (f=f@entry=0xb67d35b0, fmt=fmt@entry=0x101856 "%s.%06ld [%s] [%s:%d] ", ap=ap@entry=0xbe8f5a1c, nl_arg=nl_arg@entry=0xbe8f5a48, nl_type=<optimized out>, nl_type@entry=0xbe8f5a20) at src/stdio/vfprintf.c:599 #3 0xb6f4b86c in vfprintf (f=0xb67d35b0, fmt=0x101856 "%s.%06ld [%s] [%s:%d] ", ap=...) at src/stdio/vfprintf.c:688 #4 0x0001d92c in aria2::OutputFile::printf (this=<optimized out>, format=0x101856 "%s.%06ld [%s] [%s:%d] ") at OutputFile.h:58 #5 0x00027910 in aria2::(anonymous namespace)::writeHeader<aria2::OutputFile> (lineNum=0xba, sourceFile=0x10d842 "HttpServer.cc", level=aria2::Logger::A2_INFO, fp=...) at Logger.cc:136 #6 aria2::Logger::writeLog (this=0xb67cf78c, level=aria2::Logger::A2_INFO, sourceFile=0x10d842 "HttpServer.cc", lineNum=0xba, msg=0xb6766280 "HTTP Server received request\nPOST /jsonrpc HTTP/1.1\r\nHost: 192.168 .1.1:6800\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0\r\nAccept: application/json, text/plain, *"..., msg@entry=0x10d842 "HttpServer.cc", trace=trace@entry=0x124806 "") a t Logger.cc:196 #7 0x00028bf0 in aria2::Logger::log (this=<optimized out>, level=<optimized out>, sourceFile=<optimized out>, lineNum=<optimized out>, msg=0xb6766280 "HTTP Server received request\nPOST /jsonrpc HTTP/1.1\r\nHost : 192.168.1.1:6800\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0\r\nAccept: application/json, text/plain, *"...) at Logger.cc:213 #8 0x00081708 in aria2::HttpServer::receiveRequest (this=0xb6774430) at /home/egorenar/Repositories/openwrt-rel/staging_dir/toolchain-arm_cortex-a15+neon-vfpv4_gcc-12.3.0_musl_eabi/arm-openwrt-linux-muslgnueabi/ include/c++/12.3.0/bits/basic_string.h:233 #9 aria2::HttpServerCommand::execute (this=0xb6772620) at HttpServerCommand.cc:194 #10 0x00076de4 in aria2::(anonymous namespace)::executeCommand (commands=..., statusFilter=aria2::Command::STATUS_ALL) at DownloadEngine.cc:139 #11 0x0001913c in aria2::DownloadEngine::run (oneshot=0x0, this=0xb67967e0) at DownloadEngine.cc:180 #12 aria2::MultiUrlRequestInfo::execute (this=0xb67dee6c) at MultiUrlRequestInfo.cc:361 #13 aria2::main (argv=<optimized out>, argc=<optimized out>) at main.cc:78 #14 main (argc=<optimized out>, argv=<optimized out>) at main.cc:91 (gdb) p tv $13 = { tv_sec = 0x652134fd, tv_usec = 0x3b6a } (gdb) call sizeof(tv) $14 = 0x10 (gdb) call sizeof(tv.tv_usec) $15 = 0x8 (gdb) call sizeof(long) $16 = 0x4 (gdb) call sizeof(unsigned long) $17 = 0x4 (gdb) call sizeof(time_t) $18 = 0x8 Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
* Use default where possibleNils Maier2016-08-291-1/+1
|
* make clang-format using clang-format-3.6Tatsuhiro Tsujikawa2015-12-271-69/+42
|
* Use std::make_shared and make_unique where possible, part 2Tatsuhiro Tsujikawa2014-09-131-1/+2
|
* Add --enable-color option to enable/disable terminal color outputTatsuhiro Tsujikawa2014-01-301-2/+7
|
* Implement basic color support for the Windows consoleNils Maier2013-11-211-7/+1
| | | | Only \033[*m (SGR) is supported, with a 16+16 color terminal.
* Convert most 0/NULL pointers to nullptrNils Maier2013-08-201-2/+2
| | | | Courtesy of llvm cpp11-migrate 3.3
* Require -std=c++11 and use std::shared_ptr instead of SharedHandleTatsuhiro Tsujikawa2013-06-221-0/+1
|
* Bring back datetime in console logTatsuhiro Tsujikawa2013-03-031-2/+13
|
* Added --console-log-level optionTatsuhiro Tsujikawa2013-01-051-23/+24
| | | | --console-log-level option sets log level to output to console.
* Console color outputTatsuhiro Tsujikawa2012-12-081-4/+36
| | | | Log level and download result string is now colored.
* Logger: Simplified console output and change level format in logTatsuhiro Tsujikawa2012-12-081-5/+11
| | | | | The date and time are now removed from console output. The log level is now formatted as "[LEVEL]".
* Made BufferedFile ctor take const char* argsTatsuhiro Tsujikawa2012-09-251-1/+1
|
* Use const char* instead of static const std::stringTatsuhiro Tsujikawa2012-09-241-21/+8
|
* Fixed segmentation fault when logger failed to open log fileTatsuhiro Tsujikawa2012-06-271-1/+1
|
* global cout and cerr is now retrieved using global::cout() and global::cerr()Tatsuhiro Tsujikawa2011-08-101-6/+6
| | | | | This is necessary to avoid global variable initialization order problem.
* Use global::cout to output string to stdout.Tatsuhiro Tsujikawa2011-08-091-17/+19
| | | | | | | In MinGW32 build, global::cout is WinConsoleFile. When outputing to console, it uses WriteConsoleW, so Unicode characters are written. Fixed memory leak in WChar<->MultiByte conversion functions. The portion of code which uses std::cout is rewritten to use global::cout.
* Removed utf8ToNative from log message and exception message.Tatsuhiro Tsujikawa2011-08-081-1/+1
|
* Rewritten Logger using BufferedFile.Tatsuhiro Tsujikawa2011-08-071-35/+39
|
* Applied patch from Dan Fandrich.Tatsuhiro Tsujikawa2011-05-071-0/+1
| | | | | Thanks to Dan Fandrich. I modified some lines to suite my taste.
* 2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-201-6/+1
| | | | | | | | | | | | Made LogFactory::logger_ as SharedHandle<Logger> to make dtor of Logger called at the program exit. Rewritten A2_LOG_* macro and moved them to LogFactory.h * src/LogFactory.cc * src/LogFactory.h * src/Logger.cc * src/Logger.h
* 2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-201-113/+124
| | | | | | | Rewritten Logger interface. Logger now writes source file name and line number in log file.
* 2010-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-141-0/+10
| | | | | | | | | Added .cc file for classes/structs that only provided by header file. Defined non-POD classes' ctor, dtor in .cc file. Moved implementation code in header file to .cc file for major classes/strucsts.
* 2010-11-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-11-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Capture errno right after system/library call to avoid it to get overwritten. Use util::safeStrerror instead of strerror directly because strerror might return NULL. We don't check errno for std::fstream anymore. * src/AbstractDiskWriter.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTRoutingTableDeserializer.cc * src/DHTRoutingTableSerializer.cc * src/DefaultBtProgressInfoFile.cc * src/EpollEventPoll.cc * src/IteratableChunkChecksumValidator.cc * src/KqueueEventPoll.cc * src/Logger.cc * src/MessageDigestHelper.cc * src/PortEventPoll.cc * src/SelectEventPoll.cc * src/SocketCore.cc * src/message.h * src/util.cc * src/util.h
* 2010-06-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-231-1/+28
| | | | | | | | | | | | | | | | | | | | | | | Made log and log-level option modifiable using aria2.changeGlobalOption. This means you can dynamically start or stop logging and change log file and log level. * doc/aria2c.1.txt * src/LogFactory.cc * src/LogFactory.h * src/LogFormatter.h * src/Logger.cc * src/Logger.h * src/Makefile.am * src/Makefile.in * src/SimpleLogFormatter.cc * src/SimpleLogFormatter.h * src/SimpleLogger.cc: Removed * src/SimpleLogger.h: Removed * src/XmlRpcMethod.cc * src/XmlRpcMethodImpl.cc * src/main.cc
* 2010-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-211-16/+16
| | | | | | | Changed naming standards for class member variable: now it looks like var_ instead of _var.
* 2010-06-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-06-201-0/+95
| | | | | | | | Moved non-trivial functions to *.cc file * src/Logger.cc * src/Logger.h
* 2010-04-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-04-161-1/+1
| | | | | | | | | | | | | Fixed compile error with openssl 1.1.0 and mingw32. * src/AsyncNameResolver.cc * src/LogFactory.cc * src/Logger.cc * src/Logger.h * src/SocketCore.cc * src/SocketCore.h * src/a2netcompat.h
* 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2010-01-051-1/+1
| | | | | | | | | Untabify. Fixed one line in copyright which is longer than 80 columns. * src * test
* 2009-07-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>Tatsuhiro Tsujikawa2009-07-181-0/+79
Added missing src/Logger.cc * src/Logger.cc