aboutsummaryrefslogtreecommitdiffstats
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-03-22 19:34:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:12 -0400
commit26297607e09ca6c7e6f2a6b86a8bee2f23503bb8 (patch)
treeb0fbb98f7d25c5aa18f972cbcddb1c81035e387c /lib/vsprintf.c
parent3bb598fb23b6040e67b5e6db9a00b28cd26e5809 (diff)
vsprintf: neaten %pK kptr_restrict, save a bit of code space
If kptr restrictions are on, just set the passed pointer to NULL. $ size lib/vsprintf.o.* text data bss dec hex filename 8247 4 2 8253 203d lib/vsprintf.o.new 8282 4 2 8288 2060 lib/vsprintf.o.old Signed-off-by: Joe Perches <joe@perches.com> Cc: Dan Rosenberg <drosenberg@vsecurity.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d3023df8477f..070d134eef71 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1047,16 +1047,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1047 if (spec.field_width == -1) 1047 if (spec.field_width == -1)
1048 spec.field_width = 2 * sizeof(void *); 1048 spec.field_width = 2 * sizeof(void *);
1049 return string(buf, end, "pK-error", spec); 1049 return string(buf, end, "pK-error", spec);
1050 } else if ((kptr_restrict == 0) ||
1051 (kptr_restrict == 1 &&
1052 has_capability_noaudit(current, CAP_SYSLOG)))
1053 break;
1054
1055 if (spec.field_width == -1) {
1056 spec.field_width = 2 * sizeof(void *);
1057 spec.flags |= ZEROPAD;
1058 } 1050 }
1059 return number(buf, end, 0, spec); 1051 if (!((kptr_restrict == 0) ||
1052 (kptr_restrict == 1 &&
1053 has_capability_noaudit(current, CAP_SYSLOG))))
1054 ptr = NULL;
1055 break;
1060 } 1056 }
1061 spec.flags |= SMALL; 1057 spec.flags |= SMALL;
1062 if (spec.field_width == -1) { 1058 if (spec.field_width == -1) {