From: Amos Jeffries Date: Fri, 23 May 2008 06:28:32 +0000 (+1200) Subject: Author: Bojan Smojver X-Git-Tag: SQUID_3_1_0_1~49^2~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92a9a48db4fa804dbee374508ccce5f1d0d0f200;p=thirdparty%2Fsquid.git Author: Bojan Smojver Bug 2350: Memory allocation problem in restoreCapabilities(), tools.cc Part 2 - Kernel folks are suggesting that the code in tools.cc should test _LINUX_CAPABILITY_VERSION_1 where possible --- diff --git a/src/tools.cc b/src/tools.cc index 178994eaf2..838b39c57a 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1262,14 +1262,22 @@ restoreCapabilities(int keep) cap_user_header_t head = (cap_user_header_t) xcalloc(1, sizeof(*head)); cap_user_data_t cap = (cap_user_data_t) xcalloc(1, sizeof(*cap)); +#ifdef _LINUX_CAPABILITY_VERSION_1 + head->version = _LINUX_CAPABILITY_VERSION_1; +#else head->version = _LINUX_CAPABILITY_VERSION; +#endif if (capget(head, cap) != 0) { debugs(50, 1, "Can't get current capabilities"); goto nocap; } +#ifdef _LINUX_CAPABILITY_VERSION_1 + if (head->version != _LINUX_CAPABILITY_VERSION_1) { +#else if (head->version != _LINUX_CAPABILITY_VERSION) { +#endif debugs(50, 1, "Invalid capability version " << head->version << " (expected " << _LINUX_CAPABILITY_VERSION << ")"); goto nocap; }