* Fix a crash when scanning images without read access. (SF bug #3395670)

This commit is contained in:
Justin Maggard 2011-08-22 18:24:19 +00:00
parent 546175743a
commit 1fc5f599f1
3 changed files with 18 additions and 15 deletions

View File

@ -482,7 +482,7 @@ image_new_from_jpeg(const char * path, int is_file, const char * buf, int size,
if(cinfo.output_components == 3) if(cinfo.output_components == 3)
{ {
ofs = 0; ofs = 0;
if((ptr = (unsigned char *)malloc(w * 3 * cinfo.rec_outbuf_height + 8)) == NULL) if((ptr = (unsigned char *)malloc(w * 3 * cinfo.rec_outbuf_height + 16)) == NULL)
{ {
DPRINTF(E_WARN, L_METADATA, "malloc failed\n"); DPRINTF(E_WARN, L_METADATA, "malloc failed\n");
image_free(vimage); image_free(vimage);

View File

@ -592,19 +592,22 @@ no_exifdata:
if( image_get_jpeg_resolution(path, &width, &height) != 0 || !width || !height ) if( image_get_jpeg_resolution(path, &width, &height) != 0 || !width || !height )
{ {
infile = fopen(path, "r"); infile = fopen(path, "r");
cinfo.err = jpeg_std_error(&jerr); if( infile )
jerr.error_exit = libjpeg_error_handler; {
jpeg_create_decompress(&cinfo); cinfo.err = jpeg_std_error(&jerr);
if( setjmp(setjmp_buffer) ) jerr.error_exit = libjpeg_error_handler;
goto error; jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile); if( setjmp(setjmp_buffer) )
jpeg_read_header(&cinfo, TRUE); goto error;
jpeg_start_decompress(&cinfo); jpeg_stdio_src(&cinfo, infile);
width = cinfo.output_width; jpeg_read_header(&cinfo, TRUE);
height = cinfo.output_height; jpeg_start_decompress(&cinfo);
error: width = cinfo.output_width;
jpeg_destroy_decompress(&cinfo); height = cinfo.output_height;
fclose(infile); error:
jpeg_destroy_decompress(&cinfo);
fclose(infile);
}
} }
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * resolution: %dx%d\n", width, height); //DEBUG DPRINTF(E_DEBUG, L_METADATA, " * resolution: %dx%d\n", width, height);

View File

@ -779,7 +779,7 @@ ScanDirectory(const char * dir, const char * parent, enum media_types dir_type)
sprintf(parent_id, "%s$%X", (parent ? parent:""), i+startID); sprintf(parent_id, "%s$%X", (parent ? parent:""), i+startID);
ScanDirectory(full_path, parent_id, dir_type); ScanDirectory(full_path, parent_id, dir_type);
} }
else if( type == TYPE_FILE ) else if( type == TYPE_FILE && (access(full_path, R_OK|X_OK) == 0) )
{ {
if( insert_file(name, full_path, (parent ? parent:""), i+startID) == 0 ) if( insert_file(name, full_path, (parent ? parent:""), i+startID) == 0 )
fileno++; fileno++;