From: Alex Rousskov Date: Wed, 7 Jul 2010 16:41:03 +0000 (-0600) Subject: Do not use NAME_MAX because it is not portable. X-Git-Tag: SQUID_3_2_0_1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9de6c973543bce1f87ae1c12946347caf309571e;p=thirdparty%2Fsquid.git Do not use NAME_MAX because it is not portable. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 88199d85f6..4dbdafd482 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -296,7 +296,7 @@ SubstituteMacro(char*& line, int& len, const char* macroName, const char* substS static void ProcessMacros(char*& line, int& len) { - SubstituteMacro(line, len, "${process_name}", KidName); + SubstituteMacro(line, len, "${process_name}", TheKidName); SubstituteMacro(line, len, "${process_number}", xitoa(KidIdentifier)); } diff --git a/src/ipc/Kids.cc b/src/ipc/Kids.cc index ad0da3786e..7e15ceb7d6 100644 --- a/src/ipc/Kids.cc +++ b/src/ipc/Kids.cc @@ -9,7 +9,7 @@ #include "ipc/Kids.h" Kids TheKids; -char KidName[NAME_MAX]; +KidName TheKidName; Kids::Kids() { diff --git a/src/ipc/Kids.h b/src/ipc/Kids.h index d2432a9d51..bf7a56c036 100644 --- a/src/ipc/Kids.h +++ b/src/ipc/Kids.h @@ -48,7 +48,8 @@ private: extern Kids TheKids; ///< All kids being maintained -extern char KidName[NAME_MAX]; ///< current Squid process name (e.g., squid2) +typedef char KidName[64]; ///< Squid process name (e.g., squid2) +extern KidName TheKidName; ///< current Squid process name #endif /* SQUID_IPC_KIDS_H */ diff --git a/src/main.cc b/src/main.cc index 3d57d31524..a570415856 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1215,11 +1215,12 @@ ConfigureCurrentKid(const char *processName) if (processName && processName[0] == '(') { if (const char *idStart = strrchr(processName, '-')) { KidIdentifier = atoi(idStart + 1); - const int nameLen = idStart - (processName + 1); - xstrncpy(KidName, processName + 1, nameLen + 1); + const size_t nameLen = idStart - (processName + 1); + assert(nameLen < sizeof(TheKidName)); + xstrncpy(TheKidName, processName + 1, nameLen + 1); } } else { - xstrncpy(KidName, APP_SHORTNAME, sizeof(KidName)); + xstrncpy(TheKidName, APP_SHORTNAME, sizeof(TheKidName)); KidIdentifier = 0; } }