msm8974-common: libril: Replace strncpy with strlcpy.

Use strlcpy instead of strncpy when copying strings to make sure
the copy is always null-terminated.

Bug:73436938

[haggertk: Our original CAF base had the actual "replace strncpy
 with strlcpy" part of this change already. This just adds the
 expected sendErrorResponse()]

Change-Id: I12d4883c22a180e2136dc8c85bc0394ddcdcb706
This commit is contained in:
Ashit Sood 2018-09-06 14:10:34 -07:00 committed by Kevin F. Haggerty
parent e11fb2c255
commit 0902dcd5a7
No known key found for this signature in database
GPG Key ID: 6D95512933112729

View File

@ -539,6 +539,9 @@ bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI,
RLOGE("Copy of the HIDL string has been truncated, as "
"the string length reported by size() does not "
"match the length of string returned by c_str().");
free(*dest);
*dest = NULL;
sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
return false;
}
return true;