1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

CVE-2012-4562: Fix possible integer overflow in ssh_get_hexa().

No exploit known, but it is better to check the string length.
This commit is contained in:
Xi Wang
2011-11-25 23:02:06 -05:00
committed by Andreas Schneider
parent cab00c3bfc
commit efaebad323

View File

@@ -45,6 +45,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#ifndef _WIN32
#include <netinet/in.h>
@@ -256,6 +257,10 @@ char *ssh_get_hexa(const unsigned char *what, size_t len) {
size_t i;
size_t hlen = len * 3;
if (len > (UINT_MAX - 1) / 3) {
return NULL;
}
hexa = malloc(hlen + 1);
if (hexa == NULL) {
return NULL;