Skip to content

Commit

Permalink
devinfo: Use strlcpy and correct allocation size
Browse files Browse the repository at this point in the history
  • Loading branch information
ktullavik committed Oct 20, 2024
1 parent 0f668e6 commit 5aa5e86
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions usr.sbin/devinfo/devinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ print_resource(struct devinfo_res *res)
bool hexmode;
rman_res_t end;
char *safe_desc;
size_t len;

rman = devinfo_handle_to_rman(res->dr_rman);
hexmode = (rman->dm_size > 1000) || (rman->dm_size == 0);
end = res->dr_start + res->dr_size - 1;

safe_desc = malloc(strlen(rman->dm_desc));
strcpy(safe_desc, rman->dm_desc);
len = strlen(rman->dm_desc) + 1;
safe_desc = malloc(len);
strlcpy(safe_desc, rman->dm_desc, len);
xml_safe_string(safe_desc);

xo_open_instance(safe_desc);
Expand Down

0 comments on commit 5aa5e86

Please sign in to comment.