3261 linker should ignore unknown hardware capabilities
Reviewed by: Joshua M. Clulow <
[email protected]>
Reviewed by: Gary Mills <
[email protected]>
Reviewed by: Eric Schrock <
[email protected]>
Approved by: Gordon Ross <
[email protected]>
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README Fri Oct 05 17:07:38 2012 -0400
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README Fri Oct 05 17:35:59 2012 -0400
@@ -1638,3 +1638,4 @@
3228 Want -zassert-deflib for ld
3230 ld.so.1 should check default paths for DT_DEPAUDIT
3260 linker is insufficiently careful with strtok
+3261 linker should ignore unknown hardware capabilities
--- a/usr/src/cmd/sgs/rtld/common/cap.c Fri Oct 05 17:07:38 2012 -0400
+++ b/usr/src/cmd/sgs/rtld/common/cap.c Fri Oct 05 17:35:59 2012 -0400
@@ -922,6 +922,8 @@
* Invalid indexes are ignored.
*/
if (val == 0) {
+ char *end;
+
if ((*ptr == '[') && (*(ptr + 2) == ']')) {
if (*(ptr + 1) == '1') {
ndx = tag;
@@ -942,9 +944,21 @@
ndx = tag;
errno = 0;
- if (((val = strtol(ptr, NULL, 16)) == 0) && errno)
+ if (((val = strtol(ptr, &end, 16)) == 0) && errno)
continue;
+
+ /*
+ * If the value wasn't an entirely valid hexadecimal
+ * integer, assume it was intended as a capability
+ * name and skip it.
+ */
+ if (*end != '\0') {
+ eprintf(NULL, ERR_WARNING,
+ MSG_INTL(MSG_CAP_IGN_UNKCAP), ptr);
+ continue;
+ }
}
+
cap_settings[ndx - 1].cs_val[mode] |= val;
cap_settings[ndx - 1].cs_set[mode]++;
--- a/usr/src/cmd/sgs/rtld/common/rtld.msg Fri Oct 05 17:07:38 2012 -0400
+++ b/usr/src/cmd/sgs/rtld/common/rtld.msg Fri Oct 05 17:35:59 2012 -0400
@@ -300,6 +300,7 @@
@ MSG_STR_ONE "1"
@ MSG_CAP_DELIMIT ","
+@ MSG_CAP_IGN_UNKCAP "ignoring unknown capability: %s"
@ MSG_SUNW_OST_SGS "SUNW_OST_SGS"
@ MSG_SUNW_OST_OSLIB "SUNW_OST_OSLIB"