Better tun the use of open_memstream to safe versions of glibc

This commit is contained in:
Steve Underwood 2013-08-19 22:49:03 +08:00
parent f284746703
commit d434bfa86f
3 changed files with 21 additions and 6 deletions

View File

@ -2589,7 +2589,7 @@ static int start_sending_document(t30_state_t *s)
t30_set_status(s, T30_ERR_NORESSUPPORT);
break;
default:
span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image format\n");
span_log(&s->logging, SPAN_LOG_WARNING, "Cannot negotiate an image mode\n");
t30_set_status(s, T30_ERR_BADTIFF);
break;
}

View File

@ -72,6 +72,11 @@
#include "spandsp/private/t85.h"
#include "spandsp/private/t42.h"
/* The open_memstream() and fmemopen() in older versions of glibc seems quirky */
#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12))
#undef OPEN_MEMSTREAM
#endif
#define T42_USE_LUTS
#include "t42_t43_local.h"
@ -1209,7 +1214,7 @@ SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status)
{
if (t42_itulab_jpeg_to_srgb(s))
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to convert from ITULAB.\n");
s->end_of_data = 1;
s->end_of_data = true;
}
break;
default:
@ -1229,7 +1234,7 @@ SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], si
{
if (t42_itulab_jpeg_to_srgb(s))
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to convert from ITULAB.\n");
s->end_of_data = 1;
s->end_of_data = true;
}
return T4_DECODE_OK;
}
@ -1319,7 +1324,7 @@ set_lab_illuminant(&s->lab, 95.047f, 100.000f, 108.883f);
set_lab_gamut(&s->lab, 0, 100, -85, 85, -75, 125, false);
}
s->end_of_data = 0;
s->end_of_data = false;
s->compressed_image_size = 0;
s->error_message[0] = '\0';

View File

@ -1863,7 +1863,7 @@ SPAN_DECLARE(int) t4_tx_set_tx_image_format(t4_tx_state_t *s,
s->metadata.image_type = T4_IMAGE_TYPE_BILEVEL;
}
/* Squashing to a bi-level image is possible */
span_log(&s->logging, SPAN_LOG_FLOW, "The image will be flattened to %d\n", s->metadata.image_type);
span_log(&s->logging, SPAN_LOG_FLOW, "The image may be flattened to %d\n", s->metadata.image_type);
}
}
@ -2022,8 +2022,18 @@ SPAN_DECLARE(int) t4_tx_set_tx_image_format(t4_tx_state_t *s,
if (s->metadata.image_type != s->tiff.image_type || s->metadata.image_width != s->tiff.image_width)
{
if (image_translate_init(&s->translator, s->metadata.image_type, s->metadata.image_width, -1, s->tiff.image_type, s->tiff.image_width, s->tiff.image_length, translate_row_read2, s) == NULL)
if (image_translate_init(&s->translator,
s->metadata.image_type,
s->metadata.image_width,
-1,
s->tiff.image_type,
s->tiff.image_width,
s->tiff.image_length,
translate_row_read2,
s) == NULL)
{
return T4_IMAGE_FORMAT_INCOMPATIBLE;
}
s->metadata.image_length = image_translate_get_output_length(&s->translator);
}