From a602b0d5ec3d7493d94435cf6f039e5e5029cd8a Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 26 Feb 2014 10:17:06 +0100 Subject: NSS: Fix warning access array with index then check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by:cppcheck Defensive programming: The variable 'i' is used as an array index before it is checked that is within limits. This can mean that the array might be accessed out of bounds. This patch eorder condition such as '(a[i] && i --- src/responder/nss/nsssrv_services.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/responder/nss') diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c index c37e0b366..774176802 100644 --- a/src/responder/nss/nsssrv_services.c +++ b/src/responder/nss/nsssrv_services.c @@ -908,7 +908,7 @@ errno_t parse_getservbyname(TALLOC_CTX *mem_ctx, i = j = 0; /* Copy in the service name */ - while (body[i] && i < (blen - 1)) { + while (i < (blen - 1) && body[i]) { rawname[j] = body[i]; i++; j++; @@ -943,7 +943,7 @@ errno_t parse_getservbyname(TALLOC_CTX *mem_ctx, goto done; } - while (body[i] && i < blen) { + while (i < blen && body[i]) { protocol[j] = body[i]; i++; j++; @@ -1071,7 +1071,7 @@ errno_t parse_getservbyport(TALLOC_CTX *mem_ctx, goto done; } - while (body[i] && i < blen) { + while (i < blen && body[i]) { protocol[j] = body[i]; i++; j++; -- cgit