DM: using 'strncpy' coding style cleanup

- check buffer boundaries to avoid buffer overflow

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang
2018-05-24 18:21:41 +08:00
committed by lijinxia
parent 2f3953a99a
commit 71975d63fd
5 changed files with 16 additions and 16 deletions

View File

@@ -922,7 +922,7 @@ basl_make_templates(void)
len = strlen(tmpdir);
if ((len + sizeof(ASL_TEMPLATE) + 1) < MAXPATHLEN) {
strncpy(basl_template, tmpdir, len);
strncpy(basl_template, tmpdir, len + 1);
while (len > 0 && basl_template[len - 1] == '/')
len--;
basl_template[len] = '/';
@@ -937,7 +937,7 @@ basl_make_templates(void)
*/
if ((len + sizeof(ASL_TEMPLATE) + 1 +
sizeof(ASL_SUFFIX)) < MAXPATHLEN) {
strncpy(basl_stemplate, tmpdir, len);
strncpy(basl_stemplate, tmpdir, len + 1);
basl_stemplate[len] = '/';
strncpy(&basl_stemplate[len + 1], ASL_TEMPLATE,
MAXPATHLEN - len - 1);