summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-02-26 10:17:06 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-02-26 19:29:40 +0100
commita602b0d5ec3d7493d94435cf6f039e5e5029cd8a (patch)
tree40d2223bf3af5d06c274bb828344cf8cabdac77e /src/responder
parentcfaa16fe871f10f5bba0a55beb39e8223dbdf001 (diff)
downloadsssd-a602b0d5ec3d7493d94435cf6f039e5e5029cd8a.tar.gz
sssd-a602b0d5ec3d7493d94435cf6f039e5e5029cd8a.tar.xz
sssd-a602b0d5ec3d7493d94435cf6f039e5e5029cd8a.zip
NSS: Fix warning access array with index then check
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 <blen) to (i < blen && a[i]). That way the array will not be accessed if the index is out of limits. Reviewed-by: Michal Žídek <mzidek@redhat.com>
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/nss/nsssrv_services.c6
1 files changed, 3 insertions, 3 deletions
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++;