mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-31 11:25:30 +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;
|
||||
|
||||
#define MAX_OPTS_LEN 256
|
||||
#ifdef AHCI_DEBUG
|
||||
dbg = fopen("/tmp/log", "w+");
|
||||
#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
|
||||
*/
|
||||
MD5_Init(&mdctx);
|
||||
MD5_Update(&mdctx, opts, strlen(opts));
|
||||
MD5_Update(&mdctx, opts, strnlen(opts, MAX_OPTS_LEN));
|
||||
MD5_Final(digest, &mdctx);
|
||||
rc = snprintf(ahci_dev->port[p].ident,
|
||||
sizeof(ahci_dev->port[p].ident),
|
||||
|
@ -1006,7 +1006,7 @@ basl_make_templates(void)
|
||||
tmpdir = _PATH_TMP;
|
||||
}
|
||||
|
||||
len = strlen(tmpdir);
|
||||
len = strnlen(tmpdir, MAXPATHLEN);
|
||||
|
||||
if ((len + sizeof(ASL_TEMPLATE) + 1) < MAXPATHLEN) {
|
||||
strncpy(basl_template, tmpdir, len + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user