aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoberto Vargas <roberto.vargas@arm.com>2018-05-09 10:49:24 +0100
committerRoberto Vargas <roberto.vargas@arm.com>2018-05-09 11:26:36 +0100
commita83a74d2308400245209192c6e49d8370d6e8a2b (patch)
treef6ecc38408bd5443a2c10c82ee0e87445f179ffe /lib
parente9eb1460121709a9509f428fb94c8bd4a913361c (diff)
downloadplatform_external_arm-trusted-firmware-a83a74d2308400245209192c6e49d8370d6e8a2b.tar.gz
platform_external_arm-trusted-firmware-a83a74d2308400245209192c6e49d8370d6e8a2b.tar.bz2
platform_external_arm-trusted-firmware-a83a74d2308400245209192c6e49d8370d6e8a2b.zip
Don't use variables as tf_printf format strings
Using variables as format strings can generate security problems when the user can control those strings. Some compilers generate warnings in that cases, even when the variables are constants and are not controlled by the user. Change-Id: I65dee1d1b66feab38cbf298290a86fa56e6cca40 Signed-off-by: Roberto Vargas <roberto.vargas@arm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/xlat_tables_v2/xlat_tables_internal.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/xlat_tables_v2/xlat_tables_internal.c b/lib/xlat_tables_v2/xlat_tables_internal.c
index 584d7c475..8be6d942d 100644
--- a/lib/xlat_tables_v2/xlat_tables_internal.c
+++ b/lib/xlat_tables_v2/xlat_tables_internal.c
@@ -1066,18 +1066,19 @@ static void xlat_desc_print(const xlat_ctx_t *ctx, uint64_t desc)
if (xlat_regime == EL3_REGIME) {
/* For EL3, the AP[2] bit is all what matters */
- tf_printf((desc & LOWER_ATTRS(AP_RO)) ? ro_str : rw_str);
+ tf_printf("%s", (desc & LOWER_ATTRS(AP_RO)) ? ro_str : rw_str);
} else {
const char *ap_str = (desc & LOWER_ATTRS(AP_RO)) ? ro_str : rw_str;
- tf_printf(ap_str);
- tf_printf(priv_str);
+ tf_printf("%s", ap_str);
+ tf_printf("%s", priv_str);
/*
* EL0 can only have the same permissions as EL1 or no
* permissions at all.
*/
- tf_printf((desc & LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED))
+ tf_printf("%s",
+ (desc & LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED))
? ap_str : no_access_str);
- tf_printf(user_str);
+ tf_printf("%s", user_str);
}
const char *xn_str = "-XN";
@@ -1085,14 +1086,14 @@ static void xlat_desc_print(const xlat_ctx_t *ctx, uint64_t desc)
if (xlat_regime == EL3_REGIME) {
/* For EL3, the XN bit is all what matters */
- tf_printf(LOWER_ATTRS(XN) & desc ? xn_str : exec_str);
+ tf_printf("%s", LOWER_ATTRS(XN) & desc ? xn_str : exec_str);
} else {
/* For EL0 and EL1, we need to know who has which rights */
- tf_printf(LOWER_ATTRS(PXN) & desc ? xn_str : exec_str);
- tf_printf(priv_str);
+ tf_printf("%s", LOWER_ATTRS(PXN) & desc ? xn_str : exec_str);
+ tf_printf("%s", priv_str);
- tf_printf(LOWER_ATTRS(UXN) & desc ? xn_str : exec_str);
- tf_printf(user_str);
+ tf_printf("%s", LOWER_ATTRS(UXN) & desc ? xn_str : exec_str);
+ tf_printf("%s", user_str);
}
tf_printf(LOWER_ATTRS(NS) & desc ? "-NS" : "-S");