diff --git a/SOURCES/db-5.3.28-add_getopt_h.patch b/SOURCES/db-5.3.28-add_getopt_h.patch
new file mode 100644
index 0000000..94cc915
--- /dev/null
+++ b/SOURCES/db-5.3.28-add_getopt_h.patch
@@ -0,0 +1,14 @@
+Patch for coverity issue:
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def182
+
+diff -up db-5.3.28/util/db_dump185.c.add_getopt_h db-5.3.28/util/db_dump185.c
+--- db-5.3.28/util/db_dump185.c.add_getopt_h	2019-02-11 10:20:37.739871387 +0100
++++ db-5.3.28/util/db_dump185.c	2019-02-11 10:21:11.348371222 +0100
+@@ -19,6 +19,7 @@ static const char copyright[] =
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <getopt.h>
+ 
+ #ifdef HAVE_DB_185_H
+ #include <db_185.h>
diff --git a/SOURCES/db-5.3.28-add_stdio_h.patch b/SOURCES/db-5.3.28-add_stdio_h.patch
new file mode 100644
index 0000000..fd30d5c
--- /dev/null
+++ b/SOURCES/db-5.3.28-add_stdio_h.patch
@@ -0,0 +1,14 @@
+Patch for https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def1
+
+
+diff -up db-5.3.28/db.1.85/PORT/clib/snprintf.c.add_stdio_h db-5.3.28/db.1.85/PORT/clib/snprintf.c
+--- db-5.3.28/db.1.85/PORT/clib/snprintf.c.add_stdio_h	2019-02-11 10:01:03.386405802 +0100
++++ db-5.3.28/db.1.85/PORT/clib/snprintf.c	2019-02-11 10:01:26.805754113 +0100
+@@ -2,6 +2,7 @@
+ #include <sys/cdefs.h>
+ 
+ #include <compat.h>
++#include <stdio.h>
+ 
+ #ifdef __STDC__
+ #include <stdarg.h>
diff --git a/SOURCES/db-5.3.28-add_sys_file_h.patch b/SOURCES/db-5.3.28-add_sys_file_h.patch
new file mode 100644
index 0000000..220f39a
--- /dev/null
+++ b/SOURCES/db-5.3.28-add_sys_file_h.patch
@@ -0,0 +1,14 @@
+Patch for coverity issue:
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def141
+
+diff -up db-5.3.28/src/os/os_flock.c.add_sys_file_h db-5.3.28/src/os/os_flock.c
+--- db-5.3.28/src/os/os_flock.c.add_sys_file_h	2019-02-11 10:17:20.575939063 +0100
++++ db-5.3.28/src/os/os_flock.c	2019-02-11 10:17:41.037243374 +0100
+@@ -9,6 +9,7 @@
+ #include "db_config.h"
+ 
+ #include "db_int.h"
++#include <sys/file.h>
+ 
+ #if !defined(HAVE_FCNTL) || !defined(HAVE_FLOCK)
+ static int __os_filelocking_notsup __P((ENV *));
diff --git a/SOURCES/db-5.3.28-wbool_compare.patch b/SOURCES/db-5.3.28-wbool_compare.patch
new file mode 100644
index 0000000..63577bb
--- /dev/null
+++ b/SOURCES/db-5.3.28-wbool_compare.patch
@@ -0,0 +1,30 @@
+Patch for coverity issues:
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def41
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def42
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def44
+    https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def45
+
+diff -up db-5.3.28/lang/sql/generated/sqlite3.c.libdb-5.3.28-31_coverity_41_42 db-5.3.28/lang/sql/generated/sqlite3.c
+--- db-5.3.28/lang/sql/generated/sqlite3.c.libdb-5.3.28-31_coverity_41_42	2018-11-26 15:01:56.427828116 +0100
++++ db-5.3.28/lang/sql/generated/sqlite3.c	2018-11-26 14:59:10.085403911 +0100
+@@ -114393,7 +114394,7 @@ static int deserializeGeometry(sqlite3_v
+   int nBlob;
+ 
+   /* Check that value is actually a blob. */
+-  if( !sqlite3_value_type(pValue)==SQLITE_BLOB ) return SQLITE_ERROR;
++  if( !(sqlite3_value_type(pValue)==SQLITE_BLOB) ) return SQLITE_ERROR;
+ 
+   /* Check that the blob is roughly the right size. */
+   nBlob = sqlite3_value_bytes(pValue);
+diff -up db-5.3.28/lang/sql/sqlite/ext/rtree/rtree.c.libdb-5.3.28-31_coverity_44_45 db-5.3.28/lang/sql/sqlite/ext/rtree/rtree.c
+--- db-5.3.28/lang/sql/sqlite/ext/rtree/rtree.c.libdb-5.3.28-31_coverity_44_45	2018-11-26 15:07:02.732326934 +0100
++++ db-5.3.28/lang/sql/sqlite/ext/rtree/rtree.c	2018-11-26 15:07:43.104917470 +0100
+@@ -1193,7 +1193,7 @@ static int deserializeGeometry(sqlite3_v
+   int nBlob;
+ 
+   /* Check that value is actually a blob. */
+-  if( !sqlite3_value_type(pValue)==SQLITE_BLOB ) return SQLITE_ERROR;
++  if( !(sqlite3_value_type(pValue)==SQLITE_BLOB) ) return SQLITE_ERROR;
+ 
+   /* Check that the blob is roughly the right size. */
+   nBlob = sqlite3_value_bytes(pValue);
diff --git a/SPECS/libdb.spec b/SPECS/libdb.spec
index f2e4e72..2861812 100644
--- a/SPECS/libdb.spec
+++ b/SPECS/libdb.spec
@@ -4,7 +4,7 @@
 Summary: The Berkeley DB database library for C
 Name: libdb
 Version: 5.3.28
-Release: 36%{?dist}
+Release: 37%{?dist}
 Source0: http://download.oracle.com/berkeley-db/db-%{version}.tar.gz
 Source1: http://download.oracle.com/berkeley-db/db.1.85.tar.gz
 # For mt19937db.c
@@ -56,6 +56,18 @@ Patch38: db-5.3.28-openssl.patch
 # https://community.oracle.com/message/13274780#13274780
 Patch39: libdb-limit-cpu.patch
 
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def182
+Patch200: db-5.3.28-add_getopt_h.patch
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def1
+Patch201: db-5.3.28-add_stdio_h.patch
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def141
+Patch202: db-5.3.28-add_sys_file_h.patch
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def41
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def42
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def44
+# https://cov01.lab.eng.brq.redhat.com/el8-results/el8/libdb-5.3.28-31.el8+7/scan-results-imp.html#def45
+Patch203: db-5.3.28-wbool_compare.patch
+
 URL: http://www.oracle.com/database/berkeley-db/
 License: BSD and LGPLv2 and Sleepycat
 Group: System Environment/Libraries
@@ -258,6 +270,12 @@ popd
 %patch37 -p1
 %patch38 -p1 -b .openssl
 %patch39 -p1
+%patch200 -p1
+%patch201 -p1
+%patch202 -p1
+%patch203 -p1
+
+
 
 # Delete internal AES implementation
 rm -rf src/crypto/rijndael
@@ -478,6 +496,10 @@ rm -rf ${RPM_BUILD_ROOT}
 %{_libdir}/libdb_java.so
 
 %changelog
+* Mon Jun 01 2019 Matej Mužila <mmzuila@redhat.com> - 5.3.28-37
+- Fixed flaws found by coverity
+- Resolves: #1606978
+
 * Tue Jan 22 2019 Petr Kubat <pkubat@redhat.com> - 5.3.28-36
 - Add patch to workaround issues on large systems (>1024 CPU)
   Resolves: #1664031