From: Andreas Schneider Date: Tue, 30 Apr 2024 12:33:51 +0000 (+0200) Subject: lib:ldb: Use correct integer types for sizes X-Git-Tag: tdb-1.4.11~901 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d650f884ec1be0745af93020366b9e115670b771;p=thirdparty%2Fsamba.git lib:ldb: Use correct integer types for sizes Error: INTEGER_OVERFLOW (CWE-190): ldb-2.9.0/common/ldb_ldif.c:84: tainted_data_return: Called function "read(f, buf, size)", and a possible return value may be less than zero. ldb-2.9.0/common/ldb_ldif.c:84: cast_overflow: An assign that casts to a different type, which might trigger an overflow. ldb-2.9.0/common/ldb_ldif.c:92: overflow: The expression "size" is considered to have possibly overflowed. ldb-2.9.0/common/ldb_ldif.c:84: overflow_sink: "size", which might be negative, is passed to "read(f, buf, size)". [Note: The source code implementation of the function has been overridden by a builtin model.] 82| buf = (char *)value->data; 83| while (count < statbuf.st_size) { 84|-> bytes = read(f, buf, size); 85| if (bytes == -1) { 86| talloc_free(value->data); Signed-off-by: Andreas Schneider Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Tue Apr 30 15:33:32 UTC 2024 on atb-devel-224 --- diff --git a/lib/ldb/common/ldb_ldif.c b/lib/ldb/common/ldb_ldif.c index 96237dd0abf..24a0bcdefa5 100644 --- a/lib/ldb/common/ldb_ldif.c +++ b/lib/ldb/common/ldb_ldif.c @@ -45,7 +45,8 @@ static int ldb_read_data_file(TALLOC_CTX *mem_ctx, struct ldb_val *value) { struct stat statbuf; char *buf; - int count, size, bytes; + size_t count, size; + ssize_t bytes; int ret; int f; const char *fname = (const char *)value->data;