--------------------- PatchSet 12264 Date: 2008/06/27 21:02:06 Author: hno Branch: SQUID_2_6 Tag: (none) Log: Bug #2350: Bugs in Linux kernel capabilities code - Memory allocation problem in restoreCapabilities() - version mismatch causing startup crash on newer kernels Members: src/tools.c:1.250.2.4->1.250.2.5 Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid/squid/src/tools.c,v retrieving revision 1.250.2.4 retrieving revision 1.250.2.5 diff -u -r1.250.2.4 -r1.250.2.5 --- squid/src/tools.c 2 Jan 2008 17:06:50 -0000 1.250.2.4 +++ squid/src/tools.c 27 Jun 2008 21:02:06 -0000 1.250.2.5 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.250.2.4 2008/01/02 17:06:50 hno Exp $ + * $Id: tools.c,v 1.250.2.5 2008/06/27 21:02:06 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -1337,15 +1337,18 @@ restoreCapabilities(int keep) { #if defined(_SQUID_LINUX_) && HAVE_SYS_CAPABILITY_H - cap_user_header_t head = (cap_user_header_t) xcalloc(1, sizeof(cap_user_header_t)); - cap_user_data_t cap = (cap_user_data_t) xcalloc(1, sizeof(cap_user_data_t)); +#ifndef _LINUX_CAPABILITY_VERSION_1 +#define _LINUX_CAPABILITY_VERSION_1 _LINUX_CAPABILITY_VERSION +#endif + cap_user_header_t head = xcalloc(1, sizeof(*head)); + cap_user_data_t cap = xcalloc(1, sizeof(*cap)); - head->version = _LINUX_CAPABILITY_VERSION; + head->version = _LINUX_CAPABILITY_VERSION_1; if (capget(head, cap) != 0) { debug(50, 1) ("Can't get current capabilities\n"); goto nocap; } - if (head->version != _LINUX_CAPABILITY_VERSION) { + if (head->version != _LINUX_CAPABILITY_VERSION_1) { debug(50, 1) ("Invalid capability version %d (expected %d)\n", head->version, _LINUX_CAPABILITY_VERSION); goto nocap; }