Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add format string length verification in get_formatter #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/xlsx_drone.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,10 @@ static xlsx_cell_category get_related_category(const char *format_code, int form
* - current_analyzed_index: the index pointing to a specific char of *format_code*.
*/
static xlsx_formatter get_formatter(const char *format_code, int current_analyzed_index) {
int length_format_code = (int)strlen(format_code);
if (current_analyzed_index >= length_format_code)
return XLSX_FORMATTER_UNKNOWN;

switch(format_code[current_analyzed_index]) {
case 'm': case 'h': case 's': case 'y': case 'd': {
// "[Red]" case
Expand Down Expand Up @@ -829,6 +833,9 @@ static xlsx_formatter get_formatter(const char *format_code, int current_analyze
if((++i == current_analyzed_index) && (!quotes_open)) {
break;
}
if(i >= length_format_code) {
return XLSX_FORMATTER_UNKNOWN;
}
}
}

Expand Down