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

Warnint util 4516 v5 #7006

Closed
wants to merge 14 commits into from
Closed

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/4516

Describe changes:

  • Fix integer warnings -Wimplicit-int-conversion in all files

Extends #6792 : complete with CI check...

Replaces #6820 with CIFuzz fix for defrag

Thoughts about the commit history ?
This PR can be split into smaller PRs as some points need a careful review (detect-content.c for instance)

@catenacyber catenacyber requested review from victorjulien and a team as code owners February 15, 2022 17:11
@victorjulien victorjulien marked this pull request as draft February 15, 2022 19:01
@victorjulien
Copy link
Member

Converted to draft due to "fixup" commit.

@catenacyber
Copy link
Contributor Author

Converted to draft due to "fixup" commit.

Ah I had indeed forgotten to fix it up in its real commit

@@ -286,7 +286,9 @@ int PrefilterAppendTxEngine(DetectEngineCtx *de_ctx, SigGroupHead *sgh,
e->PrefilterTx = PrefilterTxFunc;
e->pectx = pectx;
e->alproto = alproto;
e->tx_min_progress = tx_min_progress;
// TODO change function prototype ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be good, but lets do that separately. So ticket?

@@ -449,17 +448,15 @@ static void
PrefilterPacketFlowSet(PrefilterPacketHeaderValue *v, void *smctx)
{
const DetectFlowData *fb = smctx;
v->u8[0] = fb->flags;
v->u8[1] = fb->match_cnt;
v->u16[0] = fb->flags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a real bug that would need a ticket and backports

@@ -156,8 +156,7 @@ static DetectIsdataatData *DetectIsdataatParse (DetectEngineCtx *de_ctx, const c
if (*offset == NULL)
goto error;
} else {
if (StringParseUint16(&idad->dataat, 10,
strlen(args[0]), args[0]) < 0 ) {
if (StringParseUint16(&idad->dataat, 10, (uint16_t)strlen(args[0]), args[0]) < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid these casts somehow? The uint16_t seems a bit arbitrary, the max accepted value is 23 so turning it into uint8_t might make sense but then again I think size_t might make even more sense to we can just pass strlen() directly into it.

@@ -86,7 +86,9 @@ static bool BufferUrlDecode(const uint8_t *input, const uint32_t input_len, uint
if (i + 2 < input_len) {
if ((isxdigit(input[i+1])) && (isxdigit(input[i+2]))) {
// Decode %HH encoding.
*oi = (input[i+1] >= 'A' ? ((input[i+1] & 0xdf) - 'A') + 10 : (input[i+1] - '0')) << 4;
*oi = (uint8_t)((input[i + 1] >= 'A' ? ((input[i + 1] & 0xdf) - 'A') + 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow clang-format... really? Can't say this improves things. Might even opt for a clang-format exception here

@@ -580,7 +580,7 @@ int FlowGetPacketDirection(const Flow *, const Packet *);

void FlowCleanupAppLayer(Flow *);

void FlowUpdateState(Flow *f, enum FlowState s);
void FlowUpdateState(Flow *f, const FlowStateType s);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the FlowStateType is the more compact version, but in function args I prefer a real enum to the compiler can check cases and such. Can we keep that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you expect from the compiler ?

With current code (ie enum FlowState s)
FlowUpdateState(p->flow, 123456); gets no warning on my setup

(And I do not get more warnings with this change, like clang is ok to pass 123456 to an uint16_t )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried something here #7120

@@ -686,7 +686,11 @@ static uint8_t * GetFullValue(DataValue *dv, uint32_t *len)
static inline uint8_t * FindBuffer(const uint8_t *src, uint32_t len, const uint8_t *find, uint32_t find_len)
{
/* Use utility search function */
return BasicSearchNocase(src, len, find, find_len);
if (find_len > UINT16_MAX) {
// TODO rewrite all this to have app-layer events
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ticket

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this
I did #7074
I managed to get rid of this check at this level (like find_len is always small enough) so I do not think we need a ticket for this

@suricata-qa
Copy link

ERROR:

ERROR: QA failed on build_asan.

Pipeline 6404

@catenacyber
Copy link
Contributor Author

Status : splitting this in multiple PRs

Waiting to rebase on what gets merged
Keeping this open with the rest of the code changes to get, and comments to take into account

This was referenced Mar 4, 2022
This was referenced Apr 8, 2022
@suricata-qa suricata-qa added the needs rebase Needs rebase to master label Apr 25, 2022
@catenacyber
Copy link
Contributor Author

Finally replaced by #7470

@catenacyber catenacyber closed this Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase Needs rebase to master
Development

Successfully merging this pull request may close these issues.

3 participants