damian-m-g / xlsx_drone

Fast Microsoft Excel's *.xlsx reader
MIT License
13 stars 3 forks source link

crash with strange format on xlsx file #12

Open gvollant opened 1 month ago

gvollant commented 1 month ago

I received and xlsx file with this strange format

mini5.xlsx

#,##0\ "gche";[Red]\-#,##0\ "gche"

xlsx_drone crash when xlsx_open is called (in get_formetted function, called by get_related_category)

I'll subit a PR with a string length verification

gvollant commented 1 month ago

@damian-m-g

gvollant commented 1 month ago

@damian-m-g what do you think?

damian-m-g commented 4 days ago

Hi Gilles, thanks for reporting the problem. I checked the XLSX, not in depth, but at least I found that cell category (aka format code):

image

I couldn't yet debug the lib to reproduce the error, but I've tried to follow the problem by bare eye. I see no way, in which the length of the cell category could cause a problem. So get_related_category() which in time calls get_formatter(), gets passed the length of the cell category:

image

And then on get_related_category(), the code never pass an index out of the bounds of the cell category length:

image

So your first check according to this analysis could be in vain. About your second check, I followed this specific case and it should work fine (without the fix). In conclusion, I need to set up my machine to debug this code, as it got formatted recently. This could even be a problem of the third hand libraries we are using (perhaps SXMLC), or something else. When I have some time available I'll do it.