From 6032e4f4e7c1892a4e3f0a1a2007e4cd0fe99937 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 2 Oct 2012 21:36:39 +0200 Subject: get rid of strlcpy.h Don't use hand-rolled string manipulation routine with a fixed buffer in the bitcoin core, instead make use of c++ strings and boost. --- src/irc.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/irc.cpp') diff --git a/src/irc.cpp b/src/irc.cpp index ec7eea3cf4..17d5ff1a5a 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -5,9 +5,10 @@ #include "irc.h" #include "net.h" -#include "strlcpy.h" #include "base58.h" +#include // for startswith() and endswith() + using namespace std; using namespace boost; @@ -324,30 +325,27 @@ void ThreadIRCSeed2(void* parg) if (vWords.size() < 2) continue; - char pszName[10000]; - pszName[0] = '\0'; + std::string strName; if (vWords[1] == "352" && vWords.size() >= 8) { // index 7 is limited to 16 characters // could get full length name at index 10, but would be different from join messages - strlcpy(pszName, vWords[7].c_str(), sizeof(pszName)); + strName = vWords[7].c_str(); printf("IRC got who\n"); } if (vWords[1] == "JOIN" && vWords[0].size() > 1) { // :username!username@50000007.F000000B.90000002.IP JOIN :#channelname - strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName)); - if (strchr(pszName, '!')) - *strchr(pszName, '!') = '\0'; + strName = vWords[0].substr(1, vWords[0].find('!', 1) - 1); printf("IRC got join\n"); } - if (pszName[0] == 'u') + if (boost::algorithm::starts_with(strName, "u")) { CAddress addr; - if (DecodeAddress(pszName, addr)) + if (DecodeAddress(strName, addr)) { addr.nTime = GetAdjustedTime(); if (addrman.Add(addr, addrConnect, 51 * 60)) -- cgit v1.2.3