From 9f0bffebd070115ab47a92eadc6890a721c7b78d Mon Sep 17 00:00:00 2001 From: Michal Židek Date: Wed, 22 Jul 2015 16:35:35 +0200 Subject: sssd: incorrect checks on length values during packet decoding https://fedorahosted.org/sssd/ticket/1697 It is safer to isolate the checked (unknown/untrusted) value on the left hand side in the conditions to avoid overflows/underflows. Reviewed-by: Petr Cech --- src/sss_client/ssh/sss_ssh_client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/sss_client') diff --git a/src/sss_client/ssh/sss_ssh_client.c b/src/sss_client/ssh/sss_ssh_client.c index 245a02056..e5097337f 100644 --- a/src/sss_client/ssh/sss_ssh_client.c +++ b/src/sss_client/ssh/sss_ssh_client.c @@ -171,7 +171,7 @@ sss_ssh_get_ent(TALLOC_CTX *mem_ctx, /* parse reply */ c = 0; - if (rep_len-c < 2*sizeof(uint32_t)) { + if (rep_len < c + 2*sizeof(uint32_t)) { ret = EINVAL; goto done; } @@ -214,7 +214,7 @@ sss_ssh_get_ent(TALLOC_CTX *mem_ctx, SAFEALIGN_COPY_UINT32(&len, rep+c, &c); - if (rep_len-c < len + sizeof(uint32_t)) { + if (len > rep_len - c - sizeof(uint32_t)) { ret = EINVAL; goto done; } @@ -237,7 +237,7 @@ sss_ssh_get_ent(TALLOC_CTX *mem_ctx, SAFEALIGN_COPY_UINT32(&len, rep+c, &c); - if (rep_len-c < len) { + if (len > rep_len - c) { ret = EINVAL; goto done; } -- cgit