diff --git a/.gitignore b/.gitignore
index 375a7b5..944ece6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/openjpeg-2.3.0.tar.gz
+SOURCES/openjpeg-2.3.1.tar.gz
diff --git a/.openjpeg2.metadata b/.openjpeg2.metadata
index 8a2bd44..63c4d93 100644
--- a/.openjpeg2.metadata
+++ b/.openjpeg2.metadata
@@ -1 +1 @@
-430b9949b65a11fdf53323009ffedf0c6bb075ea SOURCES/openjpeg-2.3.0.tar.gz
+38321fa9730252039ad0b7f247a160a8164f5871 SOURCES/openjpeg-2.3.1.tar.gz
diff --git a/SOURCES/openjpeg2_CVE-2018-18088.patch b/SOURCES/openjpeg2_CVE-2018-18088.patch
deleted file mode 100644
index bb8343a..0000000
--- a/SOURCES/openjpeg2_CVE-2018-18088.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 3290295708fddcef482eb453432dc34bf4b54b19 Mon Sep 17 00:00:00 2001
-From: szukw000 <szukw000@arcor.de>
-Date: Fri, 12 Oct 2018 13:41:36 +0200
-Subject: [PATCH] Change in pnmtoimage if image->comps[].data is NULL
-
----
- src/bin/jp2/convert.c | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
-diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
-index 7040969..0b17602 100644
---- a/src/bin/jp2/convert.c
-+++ b/src/bin/jp2/convert.c
-@@ -1998,7 +1998,7 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
-     int *red, *green, *blue, *alpha;
-     int wr, hr, max;
-     int i;
--    unsigned int compno, ncomp;
-+    unsigned int compno, ncomp, ui;
-     int adjustR, adjustG, adjustB, adjustA;
-     int fails, two, want_gray, has_alpha, triple;
-     int prec, v;
-@@ -2006,6 +2006,18 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split)
-     const char *tmp = outfile;
-     char *destname;
- 
-+    fails = 0;
-+    ncomp = image->numcomps;
-+    for(ui = 0; ui < ncomp; ++ui) {
-+        if(image->comps[ui].data == NULL) {
-+            fprintf(stderr, "imagetopnm data[%u] == NULL\n", ui);
-+            fails = 1;
-+        }
-+    }
-+    if(fails) {
-+        return 1;
-+    }
-+
-     alpha = NULL;
- 
-     if ((prec = (int)image->comps[0].prec) > 16) {
--- 
-2.17.2
-
diff --git a/SOURCES/openjpeg2_coverity.patch b/SOURCES/openjpeg2_coverity.patch
deleted file mode 100644
index 88bfd6e..0000000
--- a/SOURCES/openjpeg2_coverity.patch
+++ /dev/null
@@ -1,278 +0,0 @@
-diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
-index 0b17602..34603eb 100644
---- a/src/bin/jp2/convert.c
-+++ b/src/bin/jp2/convert.c
-@@ -1416,6 +1416,9 @@ int imagetopgx(opj_image_t * image, const char *outfile)
-             unsigned char* line_buffer = malloc((size_t)w);
-             if (line_buffer == NULL) {
-                 fprintf(stderr, "Out of memory");
-+                if (total > 256) {
-+                    free(name);
-+                }
-                 goto fin;
-             }
-             for (j = 0; j < h; j++) {
-diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
-index 26454d9..e21431b 100644
---- a/src/bin/jp2/opj_compress.c
-+++ b/src/bin/jp2/opj_compress.c
-@@ -1739,6 +1739,8 @@ int main(int argc, char **argv)
-     img_fol_t img_fol;
-     dircnt_t *dirptr = NULL;
- 
-+    int ret;
-+
-     OPJ_BOOL bSuccess;
-     OPJ_BOOL bUseTiles = OPJ_FALSE; /* OPJ_TRUE */
-     OPJ_UINT32 l_nb_tiles = 4;
-@@ -1764,7 +1766,8 @@ int main(int argc, char **argv)
-                          255; /* This will be set later according to the input image or the provided option */
-     if (parse_cmdline_encoder(argc, argv, &parameters, &img_fol, &raw_cp,
-                               indexfilename, sizeof(indexfilename)) == 1) {
--        goto fails;
-+        ret = 1;
-+        goto end;
-     }
- 
-     /* Read directory if necessary */
-@@ -1776,18 +1779,21 @@ int main(int argc, char **argv)
-                     char)); /* Stores at max 10 image file names*/
-             dirptr->filename = (char**) malloc(num_images * sizeof(char*));
-             if (!dirptr->filename_buf) {
--                return 0;
-+                ret = 0;
-+                goto end;
-             }
-             for (i = 0; i < num_images; i++) {
-                 dirptr->filename[i] = dirptr->filename_buf + i * OPJ_PATH_LEN;
-             }
-         }
-         if (load_images(dirptr, img_fol.imgdirpath) == 1) {
--            return 0;
-+            ret = 0;
-+            goto end;
-         }
-         if (num_images == 0) {
-             fprintf(stdout, "Folder is empty\n");
--            return 0;
-+            ret = 0;
-+            goto end;
-         }
-     } else {
-         num_images = 1;
-@@ -1833,7 +1839,8 @@ int main(int argc, char **argv)
-             image = pgxtoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load pgx file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1841,7 +1848,8 @@ int main(int argc, char **argv)
-             image = pnmtoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load pnm file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1849,7 +1857,8 @@ int main(int argc, char **argv)
-             image = bmptoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load bmp file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1858,7 +1867,8 @@ int main(int argc, char **argv)
-             image = tiftoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load tiff file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- #endif /* OPJ_HAVE_LIBTIFF */
-@@ -1867,7 +1877,8 @@ int main(int argc, char **argv)
-             image = rawtoimage(parameters.infile, &parameters, &raw_cp);
-             if (!image) {
-                 fprintf(stderr, "Unable to load raw file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1875,7 +1886,8 @@ int main(int argc, char **argv)
-             image = rawltoimage(parameters.infile, &parameters, &raw_cp);
-             if (!image) {
-                 fprintf(stderr, "Unable to load raw file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1883,7 +1895,8 @@ int main(int argc, char **argv)
-             image = tgatoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load tga file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- 
-@@ -1892,7 +1905,8 @@ int main(int argc, char **argv)
-             image = pngtoimage(parameters.infile, &parameters);
-             if (!image) {
-                 fprintf(stderr, "Unable to load png file\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             break;
- #endif /* OPJ_HAVE_LIBPNG */
-@@ -1903,7 +1917,8 @@ int main(int argc, char **argv)
-         */
-         if (!image) {
-             fprintf(stderr, "Unable to load file: got no image\n");
--            return 1;
-+            ret = 1;
-+            goto end;
-         }
- 
-         /* Decide if MCT should be used */
-@@ -1914,12 +1929,14 @@ int main(int argc, char **argv)
-             if ((parameters.tcp_mct == 1) && (image->numcomps < 3)) {
-                 fprintf(stderr, "RGB->YCC conversion cannot be used:\n");
-                 fprintf(stderr, "Input image has less than 3 components\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-             if ((parameters.tcp_mct == 2) && (!parameters.mct_data)) {
-                 fprintf(stderr, "Custom MCT has been set but no array-based MCT\n");
-                 fprintf(stderr, "has been provided. Aborting.\n");
--                return 1;
-+                ret = 1;
-+                goto end;
-             }
-         }
- 
-@@ -1959,13 +1976,15 @@ int main(int argc, char **argv)
-             fprintf(stderr, "failed to encode image: opj_setup_encoder\n");
-             opj_destroy_codec(l_codec);
-             opj_image_destroy(image);
--            return 1;
-+            ret = 1;
-+            goto end;
-         }
- 
-         /* open a byte stream for writing and allocate memory for all tiles */
-         l_stream = opj_stream_create_default_file_stream(parameters.outfile, OPJ_FALSE);
-         if (! l_stream) {
--            return 1;
-+            ret = 1;
-+            goto end;
-         }
- 
-         /* encode the image */
-@@ -1978,7 +1997,8 @@ int main(int argc, char **argv)
-             OPJ_UINT32 l_data_size = 512 * 512 * 3;
-             l_data = (OPJ_BYTE*) calloc(1, l_data_size);
-             if (l_data == NULL) {
--                goto fails;
-+                ret = 1;
-+                goto end;
-             }
-             for (i = 0; i < l_nb_tiles; ++i) {
-                 if (! opj_write_tile(l_codec, i, l_data, l_data_size, l_stream)) {
-@@ -1987,7 +2007,8 @@ int main(int argc, char **argv)
-                     opj_stream_destroy(l_stream);
-                     opj_destroy_codec(l_codec);
-                     opj_image_destroy(image);
--                    return 1;
-+                    ret = 1;
-+                    goto end;
-                 }
-             }
-             free(l_data);
-@@ -2008,7 +2029,8 @@ int main(int argc, char **argv)
-             opj_image_destroy(image);
-             fprintf(stderr, "failed to encode image\n");
-             remove(parameters.outfile);
--            return 1;
-+            ret = 1;
-+            goto end;
-         }
- 
-         num_compressed_files++;
-@@ -2024,26 +2046,15 @@ int main(int argc, char **argv)
- 
-     }
- 
--    /* free user parameters structure */
--    if (parameters.cp_comment) {
--        free(parameters.cp_comment);
--    }
--    if (parameters.cp_matrice) {
--        free(parameters.cp_matrice);
--    }
--    if (raw_cp.rawComps) {
--        free(raw_cp.rawComps);
--    }
--
-     t = opj_clock() - t;
-     if (num_compressed_files) {
-         fprintf(stdout, "encode time: %d ms \n",
-                 (int)((t * 1000.0) / (OPJ_FLOAT64)num_compressed_files));
-     }
- 
--    return 0;
-+    ret = 0;
- 
--fails:
-+end:
-     if (parameters.cp_comment) {
-         free(parameters.cp_comment);
-     }
-@@ -2065,5 +2076,5 @@ fails:
-         }
-         free(dirptr);
-     }
--    return 1;
-+    return ret;
- }
-diff --git a/src/lib/openjp2/dwt.c b/src/lib/openjp2/dwt.c
-index 5b98d2b..17021de 100644
---- a/src/lib/openjp2/dwt.c
-+++ b/src/lib/openjp2/dwt.c
-@@ -2696,17 +2696,20 @@ OPJ_BOOL opj_dwt_decode_partial_97(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec,
-     /* overflow check */
-     if (l_data_size > (SIZE_MAX - 5U)) {
-         /* FIXME event manager error callback */
-+        opj_sparse_array_int32_free(sa);
-         return OPJ_FALSE;
-     }
-     l_data_size += 5U;
-     /* overflow check */
-     if (l_data_size > (SIZE_MAX / sizeof(opj_v4_t))) {
-         /* FIXME event manager error callback */
-+        opj_sparse_array_int32_free(sa);
-         return OPJ_FALSE;
-     }
-     h.wavelet = (opj_v4_t*) opj_aligned_malloc(l_data_size * sizeof(opj_v4_t));
-     if (!h.wavelet) {
-         /* FIXME event manager error callback */
-+        opj_sparse_array_int32_free(sa);
-         return OPJ_FALSE;
-     }
-     v.wavelet = h.wavelet;
diff --git a/SOURCES/openjpeg2_install.patch b/SOURCES/openjpeg2_install.patch
deleted file mode 100644
index 9e06fd2..0000000
--- a/SOURCES/openjpeg2_install.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -rupN openjpeg-2.3.0/src/lib/openjp2/CMakeLists.txt openjpeg-2.3.0-new/src/lib/openjp2/CMakeLists.txt
---- openjpeg-2.3.0/src/lib/openjp2/CMakeLists.txt	2017-10-05 00:23:14.000000000 +0200
-+++ openjpeg-2.3.0-new/src/lib/openjp2/CMakeLists.txt	2017-12-25 13:53:07.000000000 +0100
-@@ -99,6 +99,7 @@ else()
-     set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME} openjp2_static)
-   else()
-     add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
-+    set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME})
-   endif()
- endif()
- 
diff --git a/SOURCES/openjpeg2_opj2.patch b/SOURCES/openjpeg2_opj2.patch
index ff60009..0ee3302 100644
--- a/SOURCES/openjpeg2_opj2.patch
+++ b/SOURCES/openjpeg2_opj2.patch
@@ -1,12 +1,13 @@
-diff -rupN openjpeg-2.3.0/src/bin/jp2/CMakeLists.txt openjpeg-2.3.0-new/src/bin/jp2/CMakeLists.txt
---- openjpeg-2.3.0/src/bin/jp2/CMakeLists.txt	2017-10-05 00:23:14.000000000 +0200
-+++ openjpeg-2.3.0-new/src/bin/jp2/CMakeLists.txt	2017-12-25 14:55:37.562470567 +0100
+diff --git a/src/bin/jp2/CMakeLists.txt b/src/bin/jp2/CMakeLists.txt
+index 4d4bd95..619ea51 100644
+--- a/src/bin/jp2/CMakeLists.txt
++++ b/src/bin/jp2/CMakeLists.txt
 @@ -44,6 +44,8 @@ endif()
  # Loop over all executables:
  foreach(exe opj_decompress opj_compress opj_dump)
    add_executable(${exe} ${exe}.c ${common_SRCS})
-+  STRING(REPLACE "opj_" "opj2_" exe2 ${exe})
++  string(REPLACE "opj_" "opj2_" exe2 ${exe})
 +  set_target_properties(${exe} PROPERTIES OUTPUT_NAME ${exe2})
-   if(${CMAKE_VERSION} VERSION_GREATER "2.8.11")
+   if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
      target_compile_options(${exe} PRIVATE ${OPENJP2_COMPILE_OPTIONS})
    endif()
diff --git a/SOURCES/openjpeg2_remove-thirdparty.patch b/SOURCES/openjpeg2_remove-thirdparty.patch
index 6987fc2..a69f414 100644
--- a/SOURCES/openjpeg2_remove-thirdparty.patch
+++ b/SOURCES/openjpeg2_remove-thirdparty.patch
@@ -1,7 +1,8 @@
-diff -rupN openjpeg-2.1.1/CMakeLists.txt openjpeg-2.1.1-new/CMakeLists.txt
---- openjpeg-2.1.1/CMakeLists.txt	2016-07-05 16:54:17.000000000 +0200
-+++ openjpeg-2.1.1-new/CMakeLists.txt	2016-07-06 09:38:26.083029127 +0200
-@@ -270,7 +270,6 @@ if(BUILD_CODEC OR BUILD_MJ2)
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 3ea2424..af0e1cf 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -278,7 +278,6 @@ if(BUILD_CODEC OR BUILD_MJ2)
    # OFF: It will only build 3rd party libs if they are not found on the system
    # ON: 3rd party libs will ALWAYS be build, and used
    option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
diff --git a/SPECS/openjpeg2.spec b/SPECS/openjpeg2.spec
index bb45792..071c76b 100644
--- a/SPECS/openjpeg2.spec
+++ b/SPECS/openjpeg2.spec
@@ -4,8 +4,8 @@
 #global optional_components 1
 
 Name:           openjpeg2
-Version:        2.3.0
-Release:        8%{?dist}
+Version:        2.3.1
+Release:        1%{?dist}
 Summary:        C-Library for JPEG 2000
 
 # windirent.h is MIT, the rest is BSD
@@ -19,14 +19,8 @@ Source1:        data.tar.xz
 
 # Remove bundled libraries
 Patch0:         openjpeg2_remove-thirdparty.patch
-# Fix shared libraries not getting installed if static libraries are disabled
-Patch1:         openjpeg2_install.patch
 # Rename tool names to avoid conflicts with openjpeg-1.x
-Patch2:         openjpeg2_opj2.patch
-# CVE-2018-18088
-Patch3:         openjpeg2_CVE-2018-18088.patch
-# Fix Coverity defects
-Patch4:         openjpeg2_coverity.patch
+Patch1:         openjpeg2_opj2.patch
 
 BuildRequires:  cmake
 BuildRequires:  gcc
@@ -331,6 +325,9 @@ make test -C %{_target_platform}
 
 
 %changelog
+* Fri May 31 2019 Nikola Forró <nforro@redhat.com> - 2.3.1-1
+- Rebase to 2.3.1 (#1704255)
+
 * Tue Oct 16 2018 Nikola Forró <nforro@redhat.com> - 2.3.0-8
 - Fix important Covscan defects (#1602643)