From f8b687f1484afc9707eff0afe4c5d6b3a7755bbb Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 31 2023 14:53:50 +0000 Subject: import aide-0.16-14.el8_5.1 --- diff --git a/SOURCES/aide-0.16-CVE-2021-45417.patch b/SOURCES/aide-0.16-CVE-2021-45417.patch new file mode 100644 index 0000000..1752df3 --- /dev/null +++ b/SOURCES/aide-0.16-CVE-2021-45417.patch @@ -0,0 +1,123 @@ +diff --git a/include/base64.h b/include/base64.h +index 0ff7116..381ef5d 100644 +--- a/include/base64.h ++++ b/include/base64.h +@@ -36,7 +36,6 @@ + #include + #include "types.h" + +-#define B64_BUF 16384 + #define FAIL -1 + #define SKIP -2 + +diff --git a/src/base64.c b/src/base64.c +index fd01bac..1b0f301 100644 +--- a/src/base64.c ++++ b/src/base64.c +@@ -85,11 +85,9 @@ FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL + }; + + /* Returns NULL on error */ +-/* FIXME Possible buffer overflow on outputs larger than B64_BUF */ + char* encode_base64(byte* src,size_t ssize) + { + char* outbuf; +- char* retbuf; + int pos; + int i, l, left; + unsigned long triple; +@@ -101,7 +99,10 @@ char* encode_base64(byte* src,size_t ssize) + error(240,"\n"); + return NULL; + } +- outbuf = (char *)malloc(sizeof(char)*B64_BUF); ++ ++ /* length of encoded base64 string (padded) */ ++ size_t length = sizeof(char)* ((ssize + 2) / 3) * 4; ++ outbuf = (char *)malloc(length + 1); + + /* Initialize working pointers */ + inb = src; +@@ -162,20 +163,14 @@ char* encode_base64(byte* src,size_t ssize) + inb++; + } + +- /* outbuf is not completely used so we use retbuf */ +- retbuf=(char*)malloc(sizeof(char)*(pos+1)); +- memcpy(retbuf,outbuf,pos); +- retbuf[pos]='\0'; +- free(outbuf); ++ outbuf[pos]='\0'; + +- return retbuf; ++ return outbuf; + } + +-/* FIXME Possible buffer overflow on outputs larger than B64_BUF */ + byte* decode_base64(char* src,size_t ssize, size_t *ret_len) + { + byte* outbuf; +- byte* retbuf; + char* inb; + int i; + int l; +@@ -188,10 +183,18 @@ byte* decode_base64(char* src,size_t ssize, size_t *ret_len) + if (!ssize||src==NULL) + return NULL; + ++ /* exit on unpadded input */ ++ if (ssize % 4) { ++ error(3, "decode_base64: '%s' has invalid length (missing padding characters?)", src); ++ return NULL; ++ } ++ ++ /* calculate length of decoded string, substract padding chars if any (ssize is >= 4) */ ++ size_t length = sizeof(byte) * ((ssize / 4) * 3)- (src[ssize-1] == '=') - (src[ssize-2] == '='); + + /* Initialize working pointers */ + inb = src; +- outbuf = (byte *)malloc(sizeof(byte)*B64_BUF); ++ outbuf = (byte *)malloc(length + 1); + + l = 0; + triple = 0; +@@ -243,15 +246,11 @@ byte* decode_base64(char* src,size_t ssize, size_t *ret_len) + inb++; + } + +- retbuf=(byte*)malloc(sizeof(byte)*(pos+1)); +- memcpy(retbuf,outbuf,pos); +- retbuf[pos]='\0'; +- +- free(outbuf); ++ outbuf[pos]='\0'; + + if (ret_len) *ret_len = pos; + +- return retbuf; ++ return outbuf; + } + + size_t length_base64(char* src,size_t ssize) +diff --git a/src/db.c b/src/db.c +index 858240d..62c4faa 100644 +--- a/src/db.c ++++ b/src/db.c +@@ -664,13 +664,15 @@ db_line* db_char2line(char** ss,int db){ + + time_t base64totime_t(char* s){ + ++ if(strcmp(s,"0")==0){ ++ return 0; ++ } + byte* b=decode_base64(s,strlen(s),NULL); + char* endp; + +- if (b==NULL||strcmp(s,"0")==0) { ++ if (b==NULL) { + + /* Should we print error here? */ +- free(b); + + return 0; + } else { diff --git a/SPECS/aide.spec b/SPECS/aide.spec index 9b1aba3..6afb21c 100644 --- a/SPECS/aide.spec +++ b/SPECS/aide.spec @@ -1,7 +1,7 @@ Summary: Intrusion detection environment Name: aide Version: 0.16 -Release: 14%{?dist} +Release: 14%{?dist}.1 URL: http://sourceforge.net/projects/aide License: GPLv2+ Source0: %{url}/files/aide/%{version}/%{name}-%{version}.tar.gz @@ -37,6 +37,9 @@ Patch6: aide-0.16-crash-elf.patch # 1676487 - Null pointer dereference fix spotted by coverity Patch7: coverity2.patch +# 2041956 - CVE-2021-45417 aide: heap-based buffer overflow on outputs larger than B64_BUF +Patch8: aide-0.16-CVE-2021-45417.patch + %description AIDE (Advanced Intrusion Detection Environment) is a file integrity checker and intrusion detection program. @@ -81,6 +84,10 @@ mkdir -p -m0700 %{buildroot}%{_localstatedir}/lib/aide %dir %attr(0700,root,root) %{_localstatedir}/log/aide %changelog +* Tue Jan 25 2022 Radovan Sroka - 0.16.14.1 +- backported fix for CVE-2021-45417 + resolves: rhbz#2041956 + * Tue Jun 30 2020 Radovan Sroka = 0.16.14 - strict require for libgcrypt resolves: rhbz#1852407