Sign consistency for parser steps; removed stale comment
What changed, and why it matters
This commit only changes the declared type of three array-length constants from signed int to unsigned size_t, and removes two stale comments about a 10,000-byte limit. There is no change to program logic, memory allocation, bounds checking, or parsing behavior. It is a code-style/cleanup change with no security relevance visible in the diff.
No security action required. Treat as normal maintenance cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch converts const int n_parse_rawtxinput_steps, n_parse_rawtxoutput_steps, n_parse_rawtx_steps (and the test fixture n_ABC_STEPS) to const size_t. It also deletes the inline comments // max 10_000 bytes on scriptsig_size and scriptpubkey_size. The values are still computed with the same sizeof(array)/sizeof(array[0]) expression, and the counters remain unsigned int. No functional code paths are altered.
Changed components
src/handler/lib/psbt_parse_rawtx.cunit-tests/test_parser.cInspect captured patch +7 / −7
diff --git a/src/handler/lib/psbt_parse_rawtx.c b/src/handler/lib/psbt_parse_rawtx.c
index 9a2d114..46a0816 100644
--- a/src/handler/lib/psbt_parse_rawtx.c
+++ b/src/handler/lib/psbt_parse_rawtx.c
@@ -21,13 +21,13 @@ struct parse_rawtx_state_s; // forward declaration
typedef struct {
struct parse_rawtx_state_s *parent_state; // subparsers can access parent's state
- unsigned int scriptsig_size; // max 10_000 bytes
- unsigned int scriptsig_counter; // counter of scriptsig bytes already received
+ unsigned int scriptsig_size;
+ unsigned int scriptsig_counter; // counter of scriptsig bytes already received
} parse_rawtxinput_state_t;
typedef struct {
struct parse_rawtx_state_s *parent_state;
- unsigned int scriptpubkey_size; // max 10_000 bytes
+ unsigned int scriptpubkey_size;
unsigned int scriptpubkey_counter; // counter of scriptpubkey bytes already received
} parse_rawtxoutput_state_t;
@@ -165,7 +165,7 @@ static const parsing_step_t parse_rawtxinput_steps[] = {
(parsing_step_t) parse_rawtxinput_sequence,
};
-const int n_parse_rawtxinput_steps =
+const size_t n_parse_rawtxinput_steps =
sizeof(parse_rawtxinput_steps) / sizeof(parse_rawtxinput_steps[0]);
/* PARSER FOR A RAWTX OUTPUT */
@@ -283,7 +283,7 @@ static const parsing_step_t parse_rawtxoutput_steps[] = {
(parsing_step_t) parse_rawtxoutput_scriptpubkey,
};
-const int n_parse_rawtxoutput_steps =
+const size_t n_parse_rawtxoutput_steps =
sizeof(parse_rawtxoutput_steps) / sizeof(parse_rawtxoutput_steps[0]);
/* PARSER FOR A FULL RAWTX */
@@ -510,7 +510,7 @@ static const parsing_step_t parse_rawtx_steps[] = {(parsing_step_t) parse_rawtx_
(parsing_step_t) parse_rawtx_witnesses,
(parsing_step_t) parse_rawtx_locktime};
-const int n_parse_rawtx_steps = sizeof(parse_rawtx_steps) / sizeof(parse_rawtx_steps[0]);
+const size_t n_parse_rawtx_steps = sizeof(parse_rawtx_steps) / sizeof(parse_rawtx_steps[0]);
static void cb_process_data(buffer_t *data, void *cb_state) {
psbt_parse_rawtx_state_t *state = (psbt_parse_rawtx_state_t *) cb_state;
diff --git a/unit-tests/test_parser.c b/unit-tests/test_parser.c
index b199be2..d24a553 100644
--- a/unit-tests/test_parser.c
+++ b/unit-tests/test_parser.c
@@ -35,7 +35,7 @@ const parsing_step_t parse_ABC_steps[] = {(parsing_step_t) parse_A,
(parsing_step_t) parse_B,
(parsing_step_t) parse_C};
-const int n_ABC_STEPS = sizeof(parse_ABC_steps) / sizeof(parse_ABC_steps[0]);
+const size_t n_ABC_STEPS = sizeof(parse_ABC_steps) / sizeof(parse_ABC_steps[0]);
// A function that simulates a parsing error while parsing B
static int parse_B_error(parse_ABC_state_t *state, buffer_t *buffers[2]) {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.