Skip to content

Commit

Permalink
Check for ui buffer size first
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Dec 9, 2024
1 parent b900594 commit 0d47c81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
18 changes: 9 additions & 9 deletions app/src/plan/output_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ parser_error_t output_getItem(const parser_context_t *ctx, const output_plan_t *
}


char bufferUI[OUTPUT_DISPLAY_MAX_LEN] = {0};
switch ( displayIdx ) {
case 0:
snprintf(outKey, outKeyLen, "Action");
CHECK_ERROR(output_printValue(ctx, output, bufferUI, sizeof(bufferUI)));
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);
break;
default:
return parser_no_data;
if (displayIdx != 0) {
return parser_no_data;
}

char bufferUI[OUTPUT_DISPLAY_MAX_LEN] = {0};

snprintf(outKey, outKeyLen, "Action");
CHECK_ERROR(output_printValue(ctx, output, bufferUI, sizeof(bufferUI)));
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);

return parser_ok;

}
Expand Down
16 changes: 9 additions & 7 deletions app/src/plan/spend_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,21 @@ parser_error_t spend_getItem(const parser_context_t *ctx, const spend_plan_t *sp
uint8_t *pageCount) {

parser_error_t err = parser_no_data;

if (spend == NULL || outKey == NULL || outVal == NULL || outKeyLen == 0 || outValLen == 0) {
return err;
}

if (displayIdx != 0) {
return err;
}


char bufferUI[SPEND_DISPLAY_MAX_LEN] = {0};
if (displayIdx == 0) {
snprintf(outKey, outKeyLen, "Action");
CHECK_ERROR(spend_printValue(ctx, spend, bufferUI, sizeof(bufferUI)));
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);

return parser_ok;
}
snprintf(outKey, outKeyLen, "Action");
CHECK_ERROR(spend_printValue(ctx, spend, bufferUI, sizeof(bufferUI)));
pageString(outVal, outValLen, bufferUI, pageIdx, pageCount);

return parser_no_data;
return parser_ok;
}

0 comments on commit 0d47c81

Please sign in to comment.