summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi/sbi_platform.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/sbi/sbi_platform.c b/lib/sbi/sbi_platform.c
index 99bd8f5..445a8c1 100644
--- a/lib/sbi/sbi_platform.c
+++ b/lib/sbi/sbi_platform.c
@@ -48,9 +48,18 @@ void sbi_platform_get_features_str(const struct sbi_platform *plat,
if (features & feat) {
temp = sbi_platform_feature_id2string(feat);
if (temp) {
- sbi_snprintf(features_str + offset, nfstr,
- "%s,", temp);
- offset = offset + sbi_strlen(temp) + 1;
+ int len = sbi_snprintf(features_str + offset,
+ nfstr - offset,
+ "%s,", temp);
+ if (len < 0)
+ break;
+
+ if (offset + len >= nfstr) {
+ /* No more space for features */
+ offset = nfstr;
+ break;
+ } else
+ offset = offset + len;
}
}
feat = feat << 1;