Fix two off-by-ones.

Coverity CID:	1087999, 1011375
Approved by:	re (glebius)
Sponsored by:	FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2013-10-09 12:30:52 +00:00
parent 846c5adb77
commit bd32ec0619

View File

@ -3442,7 +3442,7 @@ cctl_islist_start_element(void *user_data, const char *name, const char **attr)
islist = (struct cctl_islist_data *)user_data;
cur_conn = islist->cur_conn;
islist->level++;
if ((u_int)islist->level > (sizeof(islist->cur_sb) /
if ((u_int)islist->level >= (sizeof(islist->cur_sb) /
sizeof(islist->cur_sb[0])))
errx(1, "%s: too many nesting levels, %zd max", __func__,
sizeof(islist->cur_sb) / sizeof(islist->cur_sb[0]));
@ -3848,7 +3848,7 @@ cctl_start_element(void *user_data, const char *name, const char **attr)
devlist = (struct cctl_devlist_data *)user_data;
cur_lun = devlist->cur_lun;
devlist->level++;
if ((u_int)devlist->level > (sizeof(devlist->cur_sb) /
if ((u_int)devlist->level >= (sizeof(devlist->cur_sb) /
sizeof(devlist->cur_sb[0])))
errx(1, "%s: too many nesting levels, %zd max", __func__,
sizeof(devlist->cur_sb) / sizeof(devlist->cur_sb[0]));