Change in coreboot[master]: util/kconfig/nconf.c: change strlen to strnlen and int to size_t
Jude Rich has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/38139 ) Change subject: util/kconfig/nconf.c: change strlen to strnlen and int to size_t ...................................................................... util/kconfig/nconf.c: change strlen to strnlen and int to size_t size_t is a more appropriate data type for strings, and strnlen is safer than strlen when faced with no null termination. Function argument spacing has also been changed to be more consistent with the rest of the file. Signed-off-by: Jude A Rich <juder11@gmail.com> Change-Id: I950a65a8a2051e296c4e72afc4a72f789eb5be22 --- M util/kconfig/nconf.c 1 file changed, 8 insertions(+), 5 deletions(-) git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/38139/1 diff --git a/util/kconfig/nconf.c b/util/kconfig/nconf.c index 4181c41..afbeb52 100644 --- a/util/kconfig/nconf.c +++ b/util/kconfig/nconf.c @@ -567,14 +567,16 @@ va_list ap; char *append_ptr; /* pointer to the free space in the target string */ int index = items_num-1; /* index of item to append string */ - int kmi_str_len; /* length of initial string */ - int str_space; /* length of unused space in string */ + size_t kmi_str_len; /* length of initial string */ + size_t str_space; /* length of unused space in string */ /* return if there's no item to work with */ if (index < 0) return; - kmi_str_len = strlen(k_menu_items[index].str); + kmi_str_len = strnlen( + k_menu_items[index].str, + sizeof(k_menu_items[index].str)); str_space = sizeof(k_menu_items[index].str) - kmi_str_len; append_ptr = k_menu_items[index].str + kmi_str_len; @@ -585,8 +587,9 @@ /* set menu item to new item string */ free_item(curses_menu_items[index]); - curses_menu_items[index] = new_item(k_menu_items[index].str, - k_menu_items[index].str); + curses_menu_items[index] = new_item( + k_menu_items[index].str, + k_menu_items[index].str); set_item_userptr(curses_menu_items[index], &k_menu_items[index]); } -- To view, visit https://review.coreboot.org/c/coreboot/+/38139 To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings Gerrit-Project: coreboot Gerrit-Branch: master Gerrit-Change-Id: I950a65a8a2051e296c4e72afc4a72f789eb5be22 Gerrit-Change-Number: 38139 Gerrit-PatchSet: 1 Gerrit-Owner: Jude Rich <juder11@gmail.com> Gerrit-MessageType: newchange
participants (1)
-
Jude Rich (Code Review)