cmd: fix b_arglist_get_* functions not checking index parameter
This commit is contained in:
@@ -698,6 +698,12 @@ b_status b_arglist_get_string(
|
|||||||
b_arglist_iterator it = {0};
|
b_arglist_iterator it = {0};
|
||||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||||
while (b_arglist_iterator_is_valid(&it)) {
|
while (b_arglist_iterator_is_valid(&it)) {
|
||||||
|
if (index > 0) {
|
||||||
|
index--;
|
||||||
|
b_arglist_iterator_next(&it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (it.value && it.value->val_str) {
|
if (it.value && it.value->val_str) {
|
||||||
*out = it.value->val_str;
|
*out = it.value->val_str;
|
||||||
return B_SUCCESS;
|
return B_SUCCESS;
|
||||||
@@ -716,6 +722,12 @@ b_status b_arglist_get_int(
|
|||||||
b_arglist_iterator it = {0};
|
b_arglist_iterator it = {0};
|
||||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||||
while (b_arglist_iterator_is_valid(&it)) {
|
while (b_arglist_iterator_is_valid(&it)) {
|
||||||
|
if (index > 0) {
|
||||||
|
index--;
|
||||||
|
b_arglist_iterator_next(&it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (it.value) {
|
if (it.value) {
|
||||||
*out = it.value->val_int;
|
*out = it.value->val_int;
|
||||||
return B_SUCCESS;
|
return B_SUCCESS;
|
||||||
@@ -734,6 +746,12 @@ b_status b_arglist_get_uint(
|
|||||||
b_arglist_iterator it = {0};
|
b_arglist_iterator it = {0};
|
||||||
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
b_arglist_iterator_begin(args, opt_id, arg_id, &it);
|
||||||
while (b_arglist_iterator_is_valid(&it)) {
|
while (b_arglist_iterator_is_valid(&it)) {
|
||||||
|
if (index > 0) {
|
||||||
|
index--;
|
||||||
|
b_arglist_iterator_next(&it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (it.value && it.value->val_uint) {
|
if (it.value && it.value->val_uint) {
|
||||||
*out = it.value->val_uint;
|
*out = it.value->val_uint;
|
||||||
return B_SUCCESS;
|
return B_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user