mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-16 14:15:58 -06:00
Fix 32bit multiply with overflow issue for images.
Fix multiply with overflow issue when image locations in the worksheet were greater than the u32 max value.
This commit is contained in:
parent
4aaca54c41
commit
31b331462d
8 changed files with 36 additions and 8 deletions
|
|
@ -45,8 +45,8 @@ typedef struct lxw_drawing_object {
|
|||
uint8_t anchor;
|
||||
struct lxw_drawing_coords from;
|
||||
struct lxw_drawing_coords to;
|
||||
uint32_t col_absolute;
|
||||
uint32_t row_absolute;
|
||||
uint64_t col_absolute;
|
||||
uint64_t row_absolute;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint8_t shape;
|
||||
|
|
|
|||
|
|
@ -1944,8 +1944,8 @@ typedef struct lxw_vml_obj {
|
|||
lxw_col_t start_col;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
uint32_t col_absolute;
|
||||
uint32_t row_absolute;
|
||||
uint64_t col_absolute;
|
||||
uint64_t row_absolute;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
double x_dpi;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ STAILQ_HEAD(xml_attribute_list, xml_attribute);
|
|||
/* Create a new attribute struct to add to a xml_attribute_list. */
|
||||
struct xml_attribute *lxw_new_attribute_str(const char *key,
|
||||
const char *value);
|
||||
struct xml_attribute *lxw_new_attribute_int(const char *key, uint32_t value);
|
||||
struct xml_attribute *lxw_new_attribute_int(const char *key, uint64_t value);
|
||||
struct xml_attribute *lxw_new_attribute_dbl(const char *key, double value);
|
||||
|
||||
/* Macro to initialize the xml_attribute_list pointers. */
|
||||
|
|
|
|||
|
|
@ -2993,7 +2993,6 @@ _worksheet_position_object_pixels(lxw_worksheet *self,
|
|||
drawing_object->to.row_offset = y2;
|
||||
drawing_object->col_absolute = x_abs;
|
||||
drawing_object->row_absolute = y_abs;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -425,12 +425,18 @@ lxw_new_attribute_str(const char *key, const char *value)
|
|||
|
||||
/* Create a new integer XML attribute. */
|
||||
struct xml_attribute *
|
||||
lxw_new_attribute_int(const char *key, uint32_t value)
|
||||
lxw_new_attribute_int(const char *key, uint64_t value)
|
||||
{
|
||||
struct xml_attribute *attribute = malloc(sizeof(struct xml_attribute));
|
||||
|
||||
LXW_ATTRIBUTE_COPY(attribute->key, key);
|
||||
lxw_snprintf(attribute->value, LXW_MAX_ATTRIBUTE_LENGTH, "%d", value);
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
lxw_snprintf(attribute->value, LXW_MAX_ATTRIBUTE_LENGTH, "%lld", value);
|
||||
#else
|
||||
lxw_snprintf(attribute->value, LXW_MAX_ATTRIBUTE_LENGTH, "%ld",
|
||||
(long) value);
|
||||
#endif
|
||||
|
||||
return attribute;
|
||||
}
|
||||
|
|
|
|||
20
test/functional/src/test_image58.c
Normal file
20
test/functional/src/test_image58.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2023, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = workbook_new("test_image58.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
|
||||
worksheet_insert_image(worksheet, CELL("A1048573"), "images/red.png");
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
|
|
@ -160,6 +160,9 @@ class TestCompareXLSXFiles(base_test_class.XLSXBaseTest):
|
|||
def test_image57(self):
|
||||
self.run_exe_test('test_image57')
|
||||
|
||||
def test_image58(self):
|
||||
self.run_exe_test('test_image58')
|
||||
|
||||
# Test in-memory image handling.
|
||||
def test_image81(self):
|
||||
self.run_exe_test('test_image81', 'image01.xlsx')
|
||||
|
|
|
|||
BIN
test/functional/xlsx_files/image58.xlsx
Normal file
BIN
test/functional/xlsx_files/image58.xlsx
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue