Commit Graph

149 Commits

Author SHA1 Message Date
John Cupitt 2c4c039056 add "unlimited" to jpegload
To disable DoS limits for JPEG loading. Adding API on a stable branch is
bad, but this fixes a regression, so I think it's necessary,
unfortunately.

See https://github.com/libvips/libvips/issues/2973
2022-08-02 13:50:09 +01:00
John Cupitt 5221df224f fix ssize_t / ssize_t confusion 2022-05-11 22:28:34 +01:00
John Cupitt 460a19b78e revise arg names
use _ everywhere (we have a few uses of - as a separator)
2022-05-07 14:50:05 +01:00
Kleis Auke Wolthuizen 6c03343581
Add comments to `setjmp` invocations (#2751)
Also, pre-increment `num_warnings` to ensure that we really stop
at 100 warnings.
2022-04-06 12:01:18 +01:00
Kleis Auke Wolthuizen df26bd1e46 Stop JPEG load after 100 warnings (#2749)
See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24383
2022-04-05 11:07:29 +02:00
John Cupitt 2dc319b1b1 Revert "stop JPEG load after 20 warnings"
This reverts commit 89bd46d1c4.
2022-04-05 08:34:45 +01:00
John Cupitt 1aebd95387 Revert "improve fail on too many warings"
This reverts commit ae7e5e7a54.
2022-04-05 08:34:20 +01:00
John Cupitt ae7e5e7a54 improve fail on too many warings
thanks lovell, see 89bd46d1c4 (commitcomment-70409015)
2022-04-04 15:44:37 +01:00
John Cupitt 89bd46d1c4 stop JPEG load after 20 warnings
mitigates some DoS attacks somewhat

see https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24383
2022-04-03 19:21:06 +01:00
Kleis Auke Wolthuizen 0337c09700
Cleanup gettext handling (#2695)
Use GLib's i18n support instead of copying and pasting that
logic into its own header. This deprecates the vips/intl.h
header in favour of glib/gi18n.h.
2022-02-27 15:27:28 +00:00
John Cupitt 260b2ddf92
Fix read from pipe with variable chunk sizes
free the header cache only once it's exhausted
2022-01-24 11:27:22 +00:00
John Cupitt 0c70f3dc7d
add fail-on : better control over loader error handling (#2360)
Instead of a simple fail/don't-fail boolean switch, add fail-on, an enum which sets the sensitivity of loaders to errors. 

There's a new sensitivity level which tries to detect truncated images, but ignores other types of error.
2021-10-31 14:13:18 +00:00
John Cupitt 757d031005 always check the return of vips_image_pipeline()
For consistency. Although I don't think it can meaningfully fail.
2021-06-29 16:12:17 +01:00
John Cupitt 7a1fb2a627 slight formatting improvement 2020-12-29 13:29:27 +00:00
John Cupitt 0982d0efbb signal error on EOF in jpegload more reliably
we were only warning on EOF in the read stub, even if fail was set

thanks bozaro

see https://github.com/libvips/libvips/issues/1946
2020-12-28 22:46:33 +00:00
John Cupitt 4227606f5a fix tiff thumbnail from buffer and source
We were missing the new tiff thumbnail logic on the source and buffer
paths.

see https://github.com/libvips/libvips/issues/1815
2020-09-14 17:38:20 +01:00
John Cupitt a88061dfec fix jpegload autorotate
thanks chregu

see https://github.com/libvips/php-vips/issues/105
2020-09-03 19:31:56 +01:00
Kleis Auke Wolthuizen 9246094033 Fix function pointer cast issues
It is undefined behavior in C and C++ to cast a function pointer
to another type and call it that way. This does work in most native
platforms, however, despite it being UB, but in WASM it can fail.

See:
https://emscripten.org/docs/porting/guidelines/function_pointer_issues.html
2020-06-30 13:35:41 +02:00
John Cupitt 981d5c4b16 revise autorot system
- deprecate vips_autorot_get_angle() since orientation is no longer a
simple rotate
- add vips_image_get_orientation() and vips_image_get_orientation_swap()
- revise tiff and jpeg loader autorotate to just call vips_autorot(),
but only if necessary
- revise thumbnail autorotate too
2020-06-06 17:25:46 +01:00
John Cupitt ffa10eb148 default JFIF res to 72dpi
We were 1ppm before. 72dpi is the EXIF default.
2020-05-13 14:34:59 +01:00
John Cupitt b9eddecca3 prevent /0 in jfif res decode 2020-05-06 20:08:36 +01:00
John Cupitt 77365a8a6f better handling of JFIF res unit 0
res unit 0 sets the aspect ratio, rather than being unitless

thanks angelmixu

see https://github.com/libvips/libvips/issues/1641
2020-05-05 11:47:31 +01:00
John Cupitt 1338def535 fix some autorot issues
and a problem with vipsthumbnail of tif

see https://github.com/libvips/libvips/issues/1515
2020-01-07 09:00:14 +00:00
John Cupitt 119dd2cb72 pytest passes again after stream -> source/target 2019-12-29 23:08:33 +00:00
John Cupitt 4c5873809f experiment with renaming stream
rename as VipsConnection, VipsSource, VipsTarget etc.

see https://github.com/libvips/libvips/issues/1494#issuecomment-569498619

renamed with this script:

```

set -e

edit() {
        sed -i -E "$1" rename
}

for i in $*; do
        cp $i rename

        edit s/VIPS_STREAMOU/VIPS_TARGET_CUSTOM/g
        edit s/VIPS_STREAMO/VIPS_TARGET/g
        edit s/VIPS_STREAMIU/VIPS_SOURCE_CUSTOM/g
        edit s/VIPS_STREAMI/VIPS_SOURCE/g
        edit s/VIPS_STREAM/VIPS_CONNECTION/g

        edit s/vips_streamou/vips_target_custom/g
        edit s/vips_streamo/vips_target/g
        edit s/vips_streamiu/vips_source_custom/g
        edit s/vips_streami/vips_source/g
        edit s/vips_stream/vips_connection/g

        edit s/VipsStreamou/VipsTargetCustom/g
        edit s/VipsStreamo/VipsTarget/g
        edit s/VipsStreamiu/VipsSourceCustom/g
        edit s/VipsStreami/VipsSource/g
        edit s/VipsStream/VipsConnection/g

        # eg. VIPS_TYPE_STREAM or VIPS_IS_STREAM
        edit "s/VIPS_([A-Z]+)_STREAMOU/VIPS_\1_TARGET_CUSTOM/g"
        edit "s/VIPS_([A-Z]+)_STREAMO/VIPS_\1_TARGET/g"
        edit "s/VIPS_([A-Z]+)_STREAMIU/VIPS_\1_SOURCE_CUSTOM/g"
        edit "s/VIPS_([A-Z]+)_STREAMI/VIPS_\1_SOURCE/g"
        edit "s/VIPS_([A-Z]+)_STREAM/VIPS_\1_CONNECTION/g"

        edit s/streamou/target_custom/g
        edit s/streamo/target/g
        edit s/streamiu/source_custom/g
        edit s/streami/source/g

        # various identifiers which also change
        edit s/is_a_stream/is_a_source/g
        edit s/find_load_stream/find_load_source/g
        edit s/find_save_stream/find_save_target/g
        edit s/new_from_stream/new_from_source/g
        edit s/write_to_stream/write_to_target/g
        edit s/vips_thumbnail_stream/vips_thumbnail_source/g

        # eg. vips_webpload_stream
        edit "s/vips_([a-z]+)load_stream/vips_\1load_source/g"

        # eg. vips_webpsave_stream
        edit "s/vips_([a-z]+)save_stream/vips_\1save_target/g"

        mv rename $i
done
```
2019-12-29 21:40:21 +00:00
John Cupitt f5a4f41edf rename VipsStream* variables
The convention is now:

	VipStreami *streami;

We had `input` in many places, a left-over from the old VipStreamInput
name.
2019-11-11 09:09:34 +00:00
John Cupitt 3d344b4b5f add Kleis's patches
and add minimise support to radiance load
2019-11-06 17:04:13 +00:00
John Cupitt ba0100eb13 revise decode/unminimise use 2019-10-28 05:04:04 +00:00
John Cupitt ee3270f8e9 more refactoring 2019-10-22 11:08:54 +01:00
John Cupitt 696ff2b24a fix up jpeg load
and revise descriptor test
2019-10-17 13:16:12 +01:00
John Cupitt 1bdadeed61 add png stream load 2019-10-14 18:03:45 +01:00
John Cupitt c01c3b9100 add minimise support to VipsStreamInput 2019-10-14 10:46:17 +01:00
John Cupitt 20cb0da247 test suite passes
with all jpegload coming via VipsStreamInput
2019-10-11 14:03:10 +01:00
John Cupitt 6c1d7db31b remove old jpeg load stuff
it's just stream now

works on buffer, but seems to fail on

	vipsheader йцук.jpg

curiously
2019-10-11 09:43:12 +01:00
John Cupitt ad822109d4 input works
this works now:

	cat k2.jpg | vips invert - x.jpg

output next
2019-10-11 07:51:43 +01:00
John Cupitt 442720a0a1 add magic "-" stdin filename
this almost works!

$ vips invert - x.jpg < k2.jpg
2019-10-11 05:38:58 +01:00
John Cupitt 387cafa738 add jpegload_stream 2019-10-10 20:42:39 +01:00
John Cupitt efcd31b498 add something to test the new restart system
do multiple renders from one seq iage, check fds are opened and closed
as expected

see https://github.com/libvips/libvips/issues/1370
2019-10-06 07:25:09 +01:00
John Cupitt c1921b0ad1 add a test for file descriptors
verify new loader behaviour with minimise
2019-10-04 17:44:25 +01:00
John Cupitt c328b089b1 jpegload restart after minimise
after minimise, we need to reopen the underlying file

passes pytest but a proper test is still to come

https://github.com/libvips/libvips/issues/1370
2019-10-03 16:40:52 +01:00
John Cupitt 5d19bcf955 Merge branch '8.8' 2019-08-30 11:03:24 +01:00
John Cupitt 6ea76f9632 improve data_length handling in jpg load
libjpeg uses unsigned ints for data length, so we must use size_t
everywhere.
2019-08-30 11:00:25 +01:00
John Cupitt 19a80e4efb Merge branch '8.8' 2019-08-21 17:37:16 +01:00
John Cupitt b5e8e99746 fix a read-one-byte-beyond issue in jpeg load
libvips could harmlessly read beyond the end of a string with a crafted jpg
file
2019-08-21 17:17:54 +01:00
John Cupitt 0e5447e537 final cleanup 2019-07-28 17:15:54 +01:00
John Cupitt 5ef14db544 put close-on-last-line back for jpg/tif/png
consider something like:

$ vips arrayjoin "$(echo *.jpg)" x.tif --across 10 --vips-progress

close on minimise won't close until the whole pipeline finishes, so
we'll need to keep every input file open

close on last line will shut down inputs as we are done with them, so we
save a lot of file descriptors

this patch puts close-on-last-line back for jpg/tif/png
2019-07-28 11:34:40 +01:00
John Cupitt 2c654060f9 experiment with a different early-close strategy
We close loaders early in order to save file handles, and on Windows to
make sure that files can be deleted as soon as possible.

Currently loaders do this by watching the Y coordinate of requests and
freeing the fd when the final line of the file is fetched. This is messy
and does not always work, since there are cases when the final line is
not fetched.

Instead, this patch gets loaders to listen for "minimise" on their
output and close on that. This signal is emitted on all upstream images
whenever a threadpool finishes a scan of an image and is usually used to
trim caches after computation.

See https://github.com/libvips/libvips/issues/1370
2019-07-20 16:31:30 +01:00
John Cupitt 120c3b62d9 more cmyk jpg tweaks
passes tes_formats.sh now
2019-04-27 13:27:18 +01:00
John Cupitt e081ae2d99 experiment with app14 decode 2019-04-15 10:50:42 +01:00
John Cupitt 37613c196d fix jpeg xmp read/write
it was not removing/reattaching the magic XMP URL

see https://github.com/libvips/libvips/issues/1229
2019-02-11 18:16:20 +00:00