1
1

Simplified _libssh2_check_length (#350)

* Simplified _libssh2_check_length

misc.c : _libssh2_check_length()

Removed cast and improved bounds checking and format.

Credit : Yuriy M. Kaminskiy
Этот коммит содержится в:
Will Cosgrove 2019-04-05 09:46:03 -07:00 коммит произвёл GitHub
родитель c07bc647f2
Коммит ff1b155731
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23

Просмотреть файл

@ -811,10 +811,9 @@ int _libssh2_get_bignum_bytes(struct string_buf *buf, unsigned char **outbuf)
int _libssh2_check_length(struct string_buf *buf, size_t len)
{
if(len > buf->len)
return 0;
return ((int)(buf->dataptr - buf->data) <= (int)(buf->len - len)) ? 1 : 0;
unsigned char *endp = &buf->data[buf->len];
size_t left = endp - buf->dataptr;
return ((len <= left) && (left <= buf->len));
}
/* Wrappers */