From: John Hodge (sonata) Date: Thu, 28 Mar 2013 05:05:52 +0000 (+0800) Subject: Usermode - Fixed incorrect use of vsnprintf X-Git-Tag: rel0.15~484^2~17 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=cd5a9930815b6be88db4069ad680fba639853c95;p=tpg%2Facess2.git Usermode - Fixed incorrect use of vsnprintf --- diff --git a/Usermode/Applications/irc_src/main.c b/Usermode/Applications/irc_src/main.c index 3448dbd1..4ca24155 100644 --- a/Usermode/Applications/irc_src/main.c +++ b/Usermode/Applications/irc_src/main.c @@ -340,7 +340,7 @@ tMessage *Message_AppendF(tServer *Server, int Type, const char *Source, const c va_list args; int len; va_start(args, Message); - len = vsnprintf(NULL, 1000, Message, args); + len = vsnprintf(NULL, 0, Message, args); { char buf[len+1]; vsnprintf(buf, len+1, Message, args); @@ -602,6 +602,10 @@ void ParseServerLine(tServer *Server, char *Line) } //printf("[%s] NOTICE %s: %s\n", Server->Name, ident, message); + char *ident_bang = strchr(ident, '!'); + if( ident_bang ) { + *ident_bang = '\0'; + } Message_Append(Server, MSG_TYPE_NOTICE, ident, "", message); } else if( strcmp(cmd, "PRIVMSG") == 0 ) @@ -619,7 +623,10 @@ void ParseServerLine(tServer *Server, char *Line) // TODO: Catch when the privmsg is addressed to the user // Cmd_PRIVMSG(Server, dest, ident, message); - *strchr(ident, '!') = '\0'; // Hello SIGSEGV + char *ident_bang = strchr(ident, '!'); + if( ident_bang ) { + *ident_bang = '\0'; + } Message_Append(Server, MSG_TYPE_STANDARD, ident, dest, message); } else if( strcmp(cmd, "JOIN" ) == 0 ) @@ -709,7 +716,7 @@ int writef(int FD, const char *Format, ...) int len; va_start(args, Format); - len = vsnprintf(NULL, 1000, Format, args); + len = vsnprintf(NULL, 0, Format, args); va_end(args); { diff --git a/Usermode/Libraries/libnet.so_src/socket.c b/Usermode/Libraries/libnet.so_src/socket.c index f5933f22..85f7e54f 100644 --- a/Usermode/Libraries/libnet.so_src/socket.c +++ b/Usermode/Libraries/libnet.so_src/socket.c @@ -22,17 +22,17 @@ int Net_OpenSocket(int AddrType, void *Addr, const char *Filename) if(Filename) { - int len = snprintf(NULL, 100, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename); + int len = snprintf(NULL, 0, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename); char path[len+1]; - snprintf(path, 100, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename); + snprintf(path, len+1, "/Devices/ip/routes/@%i:%s/%s", AddrType, hexAddr, Filename); _SysDebug("%s", path); return _SysOpen(path, OPENFLAG_READ|OPENFLAG_WRITE); } else { - int len = snprintf(NULL, 100, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr); + int len = snprintf(NULL, 0, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr); char path[len+1]; - snprintf(path, 100, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr); + snprintf(path, len+1, "/Devices/ip/routes/@%i:%s", AddrType, hexAddr); return _SysOpen(path, OPENFLAG_READ); } }