mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
dm: hw: Replace strlen with strnlen
Replace strlen function with strnlen function in device-model Tracked-On: #2079 Signed-off-by: Long Liu <long.liu@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: <yonghua.huang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
eab7cd47ae
commit
63b814e7e9
@ -2315,6 +2315,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
#define MAX_OPTS_LEN 256
|
||||||
#ifdef AHCI_DEBUG
|
#ifdef AHCI_DEBUG
|
||||||
dbg = fopen("/tmp/log", "w+");
|
dbg = fopen("/tmp/log", "w+");
|
||||||
#endif
|
#endif
|
||||||
@ -2376,7 +2377,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts, int atapi)
|
|||||||
* Use parts of the md5 sum of the filename
|
* Use parts of the md5 sum of the filename
|
||||||
*/
|
*/
|
||||||
MD5_Init(&mdctx);
|
MD5_Init(&mdctx);
|
||||||
MD5_Update(&mdctx, opts, strlen(opts));
|
MD5_Update(&mdctx, opts, strnlen(opts, MAX_OPTS_LEN));
|
||||||
MD5_Final(digest, &mdctx);
|
MD5_Final(digest, &mdctx);
|
||||||
rc = snprintf(ahci_dev->port[p].ident,
|
rc = snprintf(ahci_dev->port[p].ident,
|
||||||
sizeof(ahci_dev->port[p].ident),
|
sizeof(ahci_dev->port[p].ident),
|
||||||
|
@ -1006,7 +1006,7 @@ basl_make_templates(void)
|
|||||||
tmpdir = _PATH_TMP;
|
tmpdir = _PATH_TMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(tmpdir);
|
len = strnlen(tmpdir, MAXPATHLEN);
|
||||||
|
|
||||||
if ((len + sizeof(ASL_TEMPLATE) + 1) < MAXPATHLEN) {
|
if ((len + sizeof(ASL_TEMPLATE) + 1) < MAXPATHLEN) {
|
||||||
strncpy(basl_template, tmpdir, len + 1);
|
strncpy(basl_template, tmpdir, len + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user