From: Chandan B Rajenda <chandan@xxxxxxxxxxxxxxxxxx> string_to_idarray() will incorrectly exit with an error when the last element of the passed in array gets filled. However it should only exit with an error if there is more input. To fix this move the array bounds check. Signed-off-by: Chandan B Rajenda <chandan@xxxxxxxxxxxxxxxxxx> Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx> --- lib/strutils.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/strutils.c b/lib/strutils.c index 7586160..c40daf2 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -393,6 +393,8 @@ int string_to_idarray(const char *list, int ary[], size_t arysz, const char *end = NULL; int id; + if (n >= arysz) + return -2; if (!begin) begin = p; /* begin of the column name */ if (*p == ',') @@ -408,8 +410,6 @@ int string_to_idarray(const char *list, int ary[], size_t arysz, if (id == -1) return -1; ary[ n++ ] = id; - if (n >= arysz) - return -2; begin = NULL; if (end && !*end) break; -- 1.7.9 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html