static int psd_skip_color_mode(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery) { psd_image_data_size_max=(buffer[buffer_size/2+12]<<8 | buffer[buffer_size/2+13]) * (buffer[buffer_size/2+14]<<24 | buffer[buffer_size/2+15] <<16 | buffer[buffer_size/2+16]<<8 | buffer[buffer_size/2+17]) * (buffer[buffer_size/2+18]<<24 | buffer[buffer_size/2+19] <<16 | buffer[buffer_size/2+20]<<8 | buffer[buffer_size/2+21]) * buffer[buffer_size/2+23] / 8; #ifdef DEBUG_PSD log_info("psd_image_data_size_max %lu\n", (long unsigned)psd_image_data_size_max); #endif while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size && file_recovery->calculated_file_size + 16 < file_recovery->file_size + buffer_size/2) { const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2; const unsigned int l=get_be32(buffer, i)+4; #ifdef DEBUG_PSD log_info("Color mode at 0x%lx\n", (long unsigned)(l + file_recovery->calculated_file_size)); #endif if(l<4) return 2; file_recovery->calculated_file_size+=l; file_recovery->data_check=&psd_skip_image_resources; return psd_skip_image_resources(buffer, buffer_size, file_recovery); } return 1; }
static data_check_t psd_skip_color_mode(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery) { const struct psd_file_header *psd=(const struct psd_file_header *)&buffer[buffer_size/2]; psd_image_data_size_max=(uint64_t)le16(psd->channels) * le32(psd->height) * le32(psd->width) * le16(psd->depth) / 8; #ifdef DEBUG_PSD log_info("psd_image_data_size_max %lu\n", (long unsigned)psd_image_data_size_max); #endif while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size && file_recovery->calculated_file_size + 16 < file_recovery->file_size + buffer_size/2) { const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2; const unsigned int l=get_be32(buffer, i)+4; #ifdef DEBUG_PSD log_info("Color mode at 0x%lx\n", (long unsigned)(l + file_recovery->calculated_file_size)); #endif if(l<4) return DC_STOP; file_recovery->calculated_file_size+=l; file_recovery->data_check=&psd_skip_image_resources; return psd_skip_image_resources(buffer, buffer_size, file_recovery); } return DC_CONTINUE; }