Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libjpeg-turbo for openSUSE:Factory checked in at 2021-11-28 21:29:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libjpeg-turbo (Old) and /work/SRC/openSUSE:Factory/.libjpeg-turbo.new.1895 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libjpeg-turbo" Sun Nov 28 21:29:55 2021 rev:60 rq:933730 version:unknown Changes: -------- --- /work/SRC/openSUSE:Factory/libjpeg-turbo/libjpeg-turbo.changes 2021-10-06 19:50:10.508062767 +0200 +++ /work/SRC/openSUSE:Factory/.libjpeg-turbo.new.1895/libjpeg-turbo.changes 2021-11-28 21:29:59.654098201 +0100 @@ -1,0 +2,26 @@ +Wed Nov 24 21:39:14 UTC 2021 - Dirk M??ller <[email protected]> + +- update to 2.1.2: + * Fixed a regression introduced by 2.1 beta1[13] that caused the remaining + GAS implementations of AArch64 (Arm 64-bit) Neon SIMD functions (which are used + by default with GCC for performance reasons) to be placed in the `.rodata` + section rather than in the `.text` section. This caused the GNU linker to + automatically place the `.rodata` section in an executable segment, which + prevented libjpeg-turbo from working properly with other linkers and also + represented a potential security risk. + * Fixed an issue whereby the `tjTransform()` function incorrectly computed the + MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus + unduly rejected some cropping regions, even though those regions aligned with + 8x8 MCU block boundaries. + * Fixed a regression introduced by 2.1 beta1[13] that caused the build system + to enable the Arm Neon SIMD extensions when targetting Armv6 and other legacy + architectures that do not support Neon instructions. + * libjpeg-turbo now performs run-time detection of AltiVec instructions on + FreeBSD/PowerPC systems if AltiVec instructions are not enabled at compile + time. This allows both AltiVec-equipped and non-AltiVec-equipped CPUs to be + supported using the same build of libjpeg-turbo. + * cjpeg now accepts a `-strict` argument similar to that of djpeg and + jpegtran, which causes the compressor to abort if an LZW-compressed GIF input + image contains incomplete or corrupt image data. + +------------------------------------------------------------------- Old: ---- libjpeg-turbo-2.1.1.tar.gz libjpeg-turbo-2.1.1.tar.gz.sig New: ---- libjpeg-turbo-2.1.2.tar.gz libjpeg-turbo-2.1.2.tar.gz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libjpeg-turbo.spec ++++++ --- /var/tmp/diff_new_pack.nmrI61/_old 2021-11-28 21:30:00.286096179 +0100 +++ /var/tmp/diff_new_pack.nmrI61/_new 2021-11-28 21:30:00.290096166 +0100 @@ -18,7 +18,7 @@ %define asan_build 0 %define debug_build 0 -%define srcver 2.1.1 +%define srcver 2.1.2 %define major 8 %define minor 2 %define micro 2 ++++++ libjpeg62-turbo.spec ++++++ --- /var/tmp/diff_new_pack.nmrI61/_old 2021-11-28 21:30:00.306096115 +0100 +++ /var/tmp/diff_new_pack.nmrI61/_new 2021-11-28 21:30:00.310096103 +0100 @@ -19,7 +19,7 @@ %define major 62 %define minor 3 %define micro 0 -%define srcver 2.1.1 +%define srcver 2.1.2 %define libver %{major}.%{minor}.%{micro} Name: libjpeg62-turbo Version: %{srcver} ++++++ libjpeg-turbo-2.1.1.tar.gz -> libjpeg-turbo-2.1.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/CMakeLists.txt new/libjpeg-turbo-2.1.2/CMakeLists.txt --- old/libjpeg-turbo-2.1.1/CMakeLists.txt 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/CMakeLists.txt 2021-11-19 04:04:35.000000000 +0100 @@ -1,11 +1,16 @@ cmake_minimum_required(VERSION 2.8.12) +# When using CMake 3.4 and later, don't export symbols from executables unless +# the CMAKE_ENABLE_EXPORTS variable is set. +if(POLICY CMP0065) + cmake_policy(SET CMP0065 NEW) +endif() if(CMAKE_EXECUTABLE_SUFFIX) set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX}) endif() project(libjpeg-turbo C) -set(VERSION 2.1.1) +set(VERSION 2.1.2) string(REPLACE "." ";" VERSION_TRIPLET ${VERSION}) list(GET VERSION_TRIPLET 0 VERSION_MAJOR) list(GET VERSION_TRIPLET 1 VERSION_MINOR) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/ChangeLog.md new/libjpeg-turbo-2.1.2/ChangeLog.md --- old/libjpeg-turbo-2.1.1/ChangeLog.md 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/ChangeLog.md 2021-11-19 04:04:35.000000000 +0100 @@ -1,3 +1,35 @@ +2.1.2 +===== + +### Significant changes relative to 2.1.1 + +1. Fixed a regression introduced by 2.1 beta1[13] that caused the remaining +GAS implementations of AArch64 (Arm 64-bit) Neon SIMD functions (which are used +by default with GCC for performance reasons) to be placed in the `.rodata` +section rather than in the `.text` section. This caused the GNU linker to +automatically place the `.rodata` section in an executable segment, which +prevented libjpeg-turbo from working properly with other linkers and also +represented a potential security risk. + +2. Fixed an issue whereby the `tjTransform()` function incorrectly computed the +MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus +unduly rejected some cropping regions, even though those regions aligned with +8x8 MCU block boundaries. + +3. Fixed a regression introduced by 2.1 beta1[13] that caused the build system +to enable the Arm Neon SIMD extensions when targetting Armv6 and other legacy +architectures that do not support Neon instructions. + +4. libjpeg-turbo now performs run-time detection of AltiVec instructions on +FreeBSD/PowerPC systems if AltiVec instructions are not enabled at compile +time. This allows both AltiVec-equipped and non-AltiVec-equipped CPUs to be +supported using the same build of libjpeg-turbo. + +5. cjpeg now accepts a `-strict` argument similar to that of djpeg and +jpegtran, which causes the compressor to abort if an LZW-compressed GIF input +image contains incomplete or corrupt image data. + + 2.1.1 ===== @@ -22,9 +54,9 @@ 5. libjpeg-turbo should now build and run on CHERI-enabled architectures, which use capability pointers that are larger than the size of `size_t`. -6. Fixed a regression introduced by 2.1 beta1[5] that caused a segfault in the -64-bit SSE2 Huffman encoder when attempting to losslessly transform a -specially-crafted malformed JPEG image. +6. Fixed a regression (CVE-2021-37972) introduced by 2.1 beta1[5] that caused a +segfault in the 64-bit SSE2 Huffman encoder when attempting to losslessly +transform a specially-crafted malformed JPEG image. 2.1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/cjpeg.1 new/libjpeg-turbo-2.1.2/cjpeg.1 --- old/libjpeg-turbo-2.1.1/cjpeg.1 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/cjpeg.1 2021-11-19 04:04:35.000000000 +0100 @@ -1,4 +1,4 @@ -.TH CJPEG 1 "4 November 2020" +.TH CJPEG 1 "18 November 2021" .SH NAME cjpeg \- compress an image file to a JPEG file .SH SYNOPSIS @@ -226,6 +226,11 @@ .BI \-report Report compression progress. .TP +.BI \-strict +Treat all warnings as fatal. Enabling this option will cause the compressor to +abort if an LZW-compressed GIF input image contains incomplete or corrupt image +data. +.TP .B \-verbose Enable debug printout. More .BR \-v 's diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/cjpeg.c new/libjpeg-turbo-2.1.2/cjpeg.c --- old/libjpeg-turbo-2.1.1/cjpeg.c 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/cjpeg.c 2021-11-19 04:04:35.000000000 +0100 @@ -147,6 +147,7 @@ static char *outfilename; /* for -outfile switch */ boolean memdst; /* for -memdst switch */ boolean report; /* for -report switch */ +boolean strict; /* for -strict switch */ #ifdef CJPEG_FUZZER @@ -240,6 +241,7 @@ fprintf(stderr, " -memdst Compress to memory instead of file (useful for benchmarking)\n"); #endif fprintf(stderr, " -report Report compression progress\n"); + fprintf(stderr, " -strict Treat all warnings as fatal\n"); fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, " -version Print version information and exit\n"); fprintf(stderr, "Switches for wizards:\n"); @@ -285,6 +287,7 @@ outfilename = NULL; memdst = FALSE; report = FALSE; + strict = FALSE; cinfo->err->trace_level = 0; /* Scan command line options, adjust parameters */ @@ -493,6 +496,9 @@ usage(); cinfo->smoothing_factor = val; + } else if (keymatch(arg, "strict", 2)) { + strict = TRUE; + } else if (keymatch(arg, "targa", 1)) { /* Input file is Targa format. */ is_targa = TRUE; @@ -540,6 +546,19 @@ } +METHODDEF(void) +my_emit_message(j_common_ptr cinfo, int msg_level) +{ + if (msg_level < 0) { + /* Treat warning as fatal */ + cinfo->err->error_exit(cinfo); + } else { + if (cinfo->err->trace_level >= msg_level) + cinfo->err->output_message(cinfo); + } +} + + /* * The main program. */ @@ -600,6 +619,9 @@ file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); + if (strict) + jerr.emit_message = my_emit_message; + #ifdef TWO_FILE_COMMANDLINE if (!memdst) { /* Must have either -outfile switch or explicit output file name */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/simd/CMakeLists.txt new/libjpeg-turbo-2.1.2/simd/CMakeLists.txt --- old/libjpeg-turbo-2.1.1/simd/CMakeLists.txt 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/simd/CMakeLists.txt 2021-11-19 04:04:35.000000000 +0100 @@ -244,6 +244,17 @@ include(CheckSymbolExists) if(BITS EQUAL 32) set(CMAKE_REQUIRED_FLAGS "-mfpu=neon ${SOFTFP_FLAG}") + check_c_source_compiles(" + #include <arm_neon.h> + int main(int argc, char **argv) { + uint16x8_t input = vdupq_n_u16((uint16_t)argc); + uint8x8_t output = vmovn_u16(input); + return (int)output[0]; + }" HAVE_NEON) + if(NOT HAVE_NEON) + simd_fail("SIMD extensions not available for this architecture") + return() + endif() endif() check_symbol_exists(vld1_s16_x3 arm_neon.h HAVE_VLD1_S16_X3) check_symbol_exists(vld1_u16_x2 arm_neon.h HAVE_VLD1_U16_X2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/simd/arm/aarch64/jsimd_neon.S new/libjpeg-turbo-2.1.2/simd/arm/aarch64/jsimd_neon.S --- old/libjpeg-turbo-2.1.1/simd/arm/aarch64/jsimd_neon.S 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/simd/arm/aarch64/jsimd_neon.S 2021-11-19 04:04:35.000000000 +0100 @@ -182,6 +182,8 @@ .byte 4, 5, 6, 7, 255, 255, 255, 255, \ 255, 255, 255, 255, 255, 255, 255, 255 /* L7 : 1 line OK */ +.text + /*****************************************************************************/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/simd/powerpc/jsimd.c new/libjpeg-turbo-2.1.2/simd/powerpc/jsimd.c --- old/libjpeg-turbo-2.1.1/simd/powerpc/jsimd.c 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/simd/powerpc/jsimd.c 2021-11-19 04:04:35.000000000 +0100 @@ -35,6 +35,9 @@ #include <sys/param.h> #include <sys/sysctl.h> #include <machine/cpu.h> +#elif defined(__FreeBSD__) +#include <machine/cpu.h> +#include <sys/auxv.h> #endif static unsigned int simd_support = ~0; @@ -122,6 +125,8 @@ int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC }; int altivec; size_t len = sizeof(altivec); +#elif defined(__FreeBSD__) + unsigned long cpufeatures = 0; #endif if (simd_support != ~0U) @@ -144,6 +149,10 @@ #elif defined(__OpenBSD__) if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0) simd_support |= JSIMD_ALTIVEC; +#elif defined(__FreeBSD__) + elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures)); + if (cpufeatures & PPC_FEATURE_HAS_ALTIVEC) + simd_support |= JSIMD_ALTIVEC; #endif #ifndef NO_GETENV diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/turbojpeg-jni.c new/libjpeg-turbo-2.1.2/turbojpeg-jni.c --- old/libjpeg-turbo-2.1.1/turbojpeg-jni.c 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/turbojpeg-jni.c 2021-11-19 04:04:35.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (C)2011-2020 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2021 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -44,6 +44,12 @@ } \ } +#define BAILIF0NOEC(f) { \ + if (!(f)) { \ + goto bailout; \ + } \ +} + #define THROW(msg, exceptionClass) { \ jclass _exccls = (*env)->FindClass(env, exceptionClass); \ \ @@ -87,10 +93,12 @@ #endif #define PROP2ENV(property, envvar) { \ - if ((jName = (*env)->NewStringUTF(env, property)) != NULL && \ - (jValue = (*env)->CallStaticObjectMethod(env, cls, mid, \ - jName)) != NULL) { \ - if ((value = (*env)->GetStringUTFChars(env, jValue, 0)) != NULL) { \ + if ((jName = (*env)->NewStringUTF(env, property)) != NULL) { \ + jboolean exception; \ + jValue = (*env)->CallStaticObjectMethod(env, cls, mid, jName); \ + exception = (*env)->ExceptionCheck(env); \ + if (jValue && !exception && \ + (value = (*env)->GetStringUTFChars(env, jValue, 0)) != NULL) { \ setenv(envvar, value, 1); \ (*env)->ReleaseStringUTFChars(env, jValue, value); \ } \ @@ -242,8 +250,8 @@ if (ProcessSystemProperties(env) < 0) goto bailout; - BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjCompress2(handle, &srcBuf[y * actualPitch + x * tjPixelSize[pf]], width, pitch, height, pf, &jpegBuf, &jpegSize, jpegSubsamp, @@ -328,8 +336,7 @@ jbyteArray jSrcPlanes[3] = { NULL, NULL, NULL }; const unsigned char *srcPlanesTmp[3] = { NULL, NULL, NULL }; const unsigned char *srcPlanes[3] = { NULL, NULL, NULL }; - int *srcOffsetsTmp = NULL, srcOffsets[3] = { 0, 0, 0 }; - int *srcStridesTmp = NULL, srcStrides[3] = { 0, 0, 0 }; + int srcOffsets[3] = { 0, 0, 0 }, srcStrides[3] = { 0, 0, 0 }; unsigned char *jpegBuf = NULL; int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i; @@ -353,15 +360,11 @@ if (ProcessSystemProperties(env) < 0) goto bailout; - BAILIF0(srcOffsetsTmp = - (*env)->GetPrimitiveArrayCritical(env, jSrcOffsets, 0)); - for (i = 0; i < nc; i++) srcOffsets[i] = srcOffsetsTmp[i]; - SAFE_RELEASE(jSrcOffsets, srcOffsetsTmp); - - BAILIF0(srcStridesTmp = - (*env)->GetPrimitiveArrayCritical(env, jSrcStrides, 0)); - for (i = 0; i < nc; i++) srcStrides[i] = srcStridesTmp[i]; - SAFE_RELEASE(jSrcStrides, srcStridesTmp); + (*env)->GetIntArrayRegion(env, jSrcOffsets, 0, nc, srcOffsets); + if ((*env)->ExceptionCheck(env)) goto bailout; + + (*env)->GetIntArrayRegion(env, jSrcStrides, 0, nc, srcStrides); + if ((*env)->ExceptionCheck(env)) goto bailout; for (i = 0; i < nc; i++) { int planeSize = tjPlaneSizeYUV(i, width, srcStrides[i], height, subsamp); @@ -379,23 +382,27 @@ if ((*env)->GetArrayLength(env, jSrcPlanes[i]) < srcOffsets[i] + planeSize) THROW_ARG("Source plane is not large enough"); - - BAILIF0(srcPlanesTmp[i] = - (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0)); + } + for (i = 0; i < nc; i++) { + BAILIF0NOEC(srcPlanesTmp[i] = + (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0)); srcPlanes[i] = &srcPlanesTmp[i][srcOffsets[i]]; - SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); } - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjCompressFromYUVPlanes(handle, srcPlanes, width, srcStrides, height, subsamp, &jpegBuf, &jpegSize, jpegQual, flags | TJFLAG_NOREALLOC) == -1) { SAFE_RELEASE(dst, jpegBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); THROW_TJ(); } bailout: SAFE_RELEASE(dst, jpegBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); return (jint)jpegSize; } @@ -410,8 +417,7 @@ jbyteArray jDstPlanes[3] = { NULL, NULL, NULL }; unsigned char *dstPlanesTmp[3] = { NULL, NULL, NULL }; unsigned char *dstPlanes[3] = { NULL, NULL, NULL }; - int *dstOffsetsTmp = NULL, dstOffsets[3] = { 0, 0, 0 }; - int *dstStridesTmp = NULL, dstStrides[3] = { 0, 0, 0 }; + int dstOffsets[3] = { 0, 0, 0 }, dstStrides[3] = { 0, 0, 0 }; int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i; GET_HANDLE(); @@ -436,15 +442,11 @@ if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize) THROW_ARG("Source buffer is not large enough"); - BAILIF0(dstOffsetsTmp = - (*env)->GetPrimitiveArrayCritical(env, jDstOffsets, 0)); - for (i = 0; i < nc; i++) dstOffsets[i] = dstOffsetsTmp[i]; - SAFE_RELEASE(jDstOffsets, dstOffsetsTmp); - - BAILIF0(dstStridesTmp = - (*env)->GetPrimitiveArrayCritical(env, jDstStrides, 0)); - for (i = 0; i < nc; i++) dstStrides[i] = dstStridesTmp[i]; - SAFE_RELEASE(jDstStrides, dstStridesTmp); + (*env)->GetIntArrayRegion(env, jDstOffsets, 0, nc, dstOffsets); + if ((*env)->ExceptionCheck(env)) goto bailout; + + (*env)->GetIntArrayRegion(env, jDstStrides, 0, nc, dstStrides); + if ((*env)->ExceptionCheck(env)) goto bailout; for (i = 0; i < nc; i++) { int planeSize = tjPlaneSizeYUV(i, width, dstStrides[i], height, subsamp); @@ -462,23 +464,27 @@ if ((*env)->GetArrayLength(env, jDstPlanes[i]) < dstOffsets[i] + planeSize) THROW_ARG("Destination plane is not large enough"); - - BAILIF0(dstPlanesTmp[i] = - (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0)); + } + for (i = 0; i < nc; i++) { + BAILIF0NOEC(dstPlanesTmp[i] = + (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0)); dstPlanes[i] = &dstPlanesTmp[i][dstOffsets[i]]; - SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); } - BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); if (tjEncodeYUVPlanes(handle, &srcBuf[y * actualPitch + x * tjPixelSize[pf]], width, pitch, height, pf, dstPlanes, dstStrides, subsamp, flags) == -1) { SAFE_RELEASE(src, srcBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); THROW_TJ(); } bailout: SAFE_RELEASE(src, srcBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); } /* TurboJPEG 1.4.x: TJCompressor::encodeYUV() byte source */ @@ -533,8 +539,8 @@ (jsize)tjBufSizeYUV(width, height, subsamp)) THROW_ARG("Destination buffer is not large enough"); - BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); - BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjEncodeYUV2(handle, srcBuf, width, pitch, height, pf, dstBuf, subsamp, flags) == -1) { @@ -653,7 +659,7 @@ if ((*env)->GetArrayLength(env, src) < jpegSize) THROW_ARG("Source buffer is not large enough"); - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); if (tjDecompressHeader3(handle, jpegBuf, (unsigned long)jpegSize, &width, &height, &jpegSubsamp, &jpegColorspace) == -1) { @@ -701,8 +707,8 @@ if ((*env)->GetArrayLength(env, dst) * dstElementSize < arraySize) THROW_ARG("Destination buffer is not large enough"); - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); - BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize, &dstBuf[y * actualPitch + x * tjPixelSize[pf]], width, @@ -780,8 +786,7 @@ jbyteArray jDstPlanes[3] = { NULL, NULL, NULL }; unsigned char *dstPlanesTmp[3] = { NULL, NULL, NULL }; unsigned char *dstPlanes[3] = { NULL, NULL, NULL }; - int *dstOffsetsTmp = NULL, dstOffsets[3] = { 0, 0, 0 }; - int *dstStridesTmp = NULL, dstStrides[3] = { 0, 0, 0 }; + int dstOffsets[3] = { 0, 0, 0 }, dstStrides[3] = { 0, 0, 0 }; int jpegSubsamp = -1, jpegWidth = 0, jpegHeight = 0; int nc = 0, i, width, height, scaledWidth, scaledHeight, nsf = 0; tjscalingfactor *sf; @@ -815,15 +820,11 @@ if (i >= nsf) THROW_ARG("Could not scale down to desired image dimensions"); - BAILIF0(dstOffsetsTmp = - (*env)->GetPrimitiveArrayCritical(env, jDstOffsets, 0)); - for (i = 0; i < nc; i++) dstOffsets[i] = dstOffsetsTmp[i]; - SAFE_RELEASE(jDstOffsets, dstOffsetsTmp); - - BAILIF0(dstStridesTmp = - (*env)->GetPrimitiveArrayCritical(env, jDstStrides, 0)); - for (i = 0; i < nc; i++) dstStrides[i] = dstStridesTmp[i]; - SAFE_RELEASE(jDstStrides, dstStridesTmp); + (*env)->GetIntArrayRegion(env, jDstOffsets, 0, nc, dstOffsets); + if ((*env)->ExceptionCheck(env)) goto bailout; + + (*env)->GetIntArrayRegion(env, jDstStrides, 0, nc, dstStrides); + if ((*env)->ExceptionCheck(env)) goto bailout; for (i = 0; i < nc; i++) { int planeSize = tjPlaneSizeYUV(i, scaledWidth, dstStrides[i], scaledHeight, @@ -842,23 +843,27 @@ if ((*env)->GetArrayLength(env, jDstPlanes[i]) < dstOffsets[i] + planeSize) THROW_ARG("Destination plane is not large enough"); - - BAILIF0(dstPlanesTmp[i] = - (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0)); + } + for (i = 0; i < nc; i++) { + BAILIF0NOEC(dstPlanesTmp[i] = + (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0)); dstPlanes[i] = &dstPlanesTmp[i][dstOffsets[i]]; - SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); } - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); if (tjDecompressToYUVPlanes(handle, jpegBuf, (unsigned long)jpegSize, dstPlanes, desiredWidth, dstStrides, desiredHeight, flags) == -1) { SAFE_RELEASE(src, jpegBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); THROW_TJ(); } bailout: SAFE_RELEASE(src, jpegBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jDstPlanes[i], dstPlanesTmp[i]); } /* TurboJPEG 1.2.x: TJDecompressor::decompressToYUV() */ @@ -884,8 +889,8 @@ (jsize)tjBufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp)) THROW_ARG("Destination buffer is not large enough"); - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); - BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0)); + BAILIF0NOEC(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjDecompressToYUV(handle, jpegBuf, (unsigned long)jpegSize, dstBuf, flags) == -1) { @@ -909,8 +914,7 @@ jbyteArray jSrcPlanes[3] = { NULL, NULL, NULL }; const unsigned char *srcPlanesTmp[3] = { NULL, NULL, NULL }; const unsigned char *srcPlanes[3] = { NULL, NULL, NULL }; - int *srcOffsetsTmp = NULL, srcOffsets[3] = { 0, 0, 0 }; - int *srcStridesTmp = NULL, srcStrides[3] = { 0, 0, 0 }; + int srcOffsets[3] = { 0, 0, 0 }, srcStrides[3] = { 0, 0, 0 }; unsigned char *dstBuf = NULL; int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i; @@ -935,15 +939,11 @@ if ((*env)->GetArrayLength(env, dst) * dstElementSize < arraySize) THROW_ARG("Destination buffer is not large enough"); - BAILIF0(srcOffsetsTmp = - (*env)->GetPrimitiveArrayCritical(env, jSrcOffsets, 0)); - for (i = 0; i < nc; i++) srcOffsets[i] = srcOffsetsTmp[i]; - SAFE_RELEASE(jSrcOffsets, srcOffsetsTmp); - - BAILIF0(srcStridesTmp = - (*env)->GetPrimitiveArrayCritical(env, jSrcStrides, 0)); - for (i = 0; i < nc; i++) srcStrides[i] = srcStridesTmp[i]; - SAFE_RELEASE(jSrcStrides, srcStridesTmp); + (*env)->GetIntArrayRegion(env, jSrcOffsets, 0, nc, srcOffsets); + if ((*env)->ExceptionCheck(env)) goto bailout; + + (*env)->GetIntArrayRegion(env, jSrcStrides, 0, nc, srcStrides); + if ((*env)->ExceptionCheck(env)) goto bailout; for (i = 0; i < nc; i++) { int planeSize = tjPlaneSizeYUV(i, width, srcStrides[i], height, subsamp); @@ -961,23 +961,27 @@ if ((*env)->GetArrayLength(env, jSrcPlanes[i]) < srcOffsets[i] + planeSize) THROW_ARG("Source plane is not large enough"); - - BAILIF0(srcPlanesTmp[i] = - (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0)); + } + for (i = 0; i < nc; i++) { + BAILIF0NOEC(srcPlanesTmp[i] = + (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0)); srcPlanes[i] = &srcPlanesTmp[i][srcOffsets[i]]; - SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); } - BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); + BAILIF0NOEC(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0)); if (tjDecodeYUVPlanes(handle, srcPlanes, srcStrides, subsamp, &dstBuf[y * actualPitch + x * tjPixelSize[pf]], width, pitch, height, pf, flags) == -1) { SAFE_RELEASE(dst, dstBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); THROW_TJ(); } bailout: SAFE_RELEASE(dst, dstBuf); + for (i = 0; i < nc; i++) + SAFE_RELEASE(jSrcPlanes[i], srcPlanesTmp[i]); } /* TurboJPEG 1.4.x: TJDecompressor::decodeYUV() byte destination */ @@ -1183,10 +1187,10 @@ tjBufSize(w, h, jpegSubsamp)) THROW_ARG("Destination buffer is not large enough"); } - BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0)); + BAILIF0NOEC(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0)); for (i = 0; i < n; i++) - BAILIF0(dstBufs[i] = - (*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0)); + BAILIF0NOEC(dstBufs[i] = + (*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0)); if (tjTransform(handle, jpegBuf, jpegSize, n, dstBufs, dstSizes, t, flags | TJFLAG_NOREALLOC) == -1) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libjpeg-turbo-2.1.1/turbojpeg.c new/libjpeg-turbo-2.1.2/turbojpeg.c --- old/libjpeg-turbo-2.1.1/turbojpeg.c 2021-08-10 01:16:57.000000000 +0200 +++ new/libjpeg-turbo-2.1.2/turbojpeg.c 2021-11-19 04:04:35.000000000 +0100 @@ -1966,12 +1966,12 @@ THROW("tjTransform(): Transform is not perfect"); if (xinfo[i].crop) { - if ((t[i].r.x % xinfo[i].iMCU_sample_width) != 0 || - (t[i].r.y % xinfo[i].iMCU_sample_height) != 0) { + if ((t[i].r.x % tjMCUWidth[jpegSubsamp]) != 0 || + (t[i].r.y % tjMCUHeight[jpegSubsamp]) != 0) { snprintf(this->errStr, JMSG_LENGTH_MAX, "To crop this JPEG image, x must be a multiple of %d\n" "and y must be a multiple of %d.\n", - xinfo[i].iMCU_sample_width, xinfo[i].iMCU_sample_height); + tjMCUWidth[jpegSubsamp], tjMCUHeight[jpegSubsamp]); this->isInstanceError = TRUE; retval = -1; goto bailout; }
