From: Sangjin Lee Date: Tue, 26 Sep 2017 07:42:18 +0000 (+0900) Subject: fix the out-of-bounds access X-Git-Tag: accepted/tizen/4.0/unified/20170929.075541~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F152461%2F2;p=platform%2Fcore%2Fuifw%2Flibtbm.git fix the out-of-bounds access Change-Id: I2aafc4433ce6c10e5545d8d6d62d22d14a0fde77 --- diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index ac48c1e..c2c1d53 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -155,18 +155,22 @@ _tbm_flag_to_str(int f) int c = 0; if (f & TBM_BO_SCANOUT) - c = snprintf(&str[c], 255, "SCANOUT"); + c += snprintf(&str[c], 255-c, "SCANOUT"); if (f & TBM_BO_NONCACHABLE) { - if (c) - c = snprintf(&str[c], 255, ", "); - c = snprintf(&str[c], 255, "NONCACHABLE,"); + if (c >= 0 && c < 255) + c += snprintf(&str[c], 255-c, ", "); + + if (c >= 0 && c < 255) + c += snprintf(&str[c], 255-c, "NONCACHABLE,"); } if (f & TBM_BO_WC) { - if (c) - c = snprintf(&str[c], 255, ", "); - c = snprintf(&str[c], 255, "WC"); + if (c >= 0 && c < 255) + c += snprintf(&str[c], 255-c, ", "); + + if (c >= 0 && c < 255) + c += snprintf(&str[c], 255-c, "WC"); } }