Skip to content

Fix NO_CAST.INTEGER_OVERFLOW in libev ev.c array_nextsize#515

Open
mikhailnov wants to merge 1 commit intolinux-audit:masterfrom
mikhailnov:svace11
Open

Fix NO_CAST.INTEGER_OVERFLOW in libev ev.c array_nextsize#515
mikhailnov wants to merge 1 commit intolinux-audit:masterfrom
mikhailnov:svace11

Conversation

@mikhailnov
Copy link
Contributor

Add explicit casts to size_t in arithmetic expressions to prevent potential integer overflow when calculating array sizes.

Overflows are not very realistic, but improve code robustness and make analyzers happy.

Svace reports:

  1. The value of 'elem * ncur' may overflow (ev.c:2259)
  2. The value of 'ncur + elem + (MALLOC_ROUND - 1)' may overflow (ev.c:2262)
  3. The value of 'elem * *cur' may overflow (ev.c:2275)
    (CWE190, CWE197)

Add explicit casts to size_t in arithmetic expressions to prevent
potential integer overflow when calculating array sizes.

Overflows are not very realistic, but improve code robustness and make analyzers happy.

Svace reports:
  1) The value of 'elem * ncur' may overflow (ev.c:2259)
  2) The value of 'ncur + elem + (MALLOC_ROUND - 1)' may overflow (ev.c:2262)
  3) The value of 'elem * *cur' may overflow (ev.c:2275)
  (CWE190, CWE197)

Co-authored-by: Z.AI GLM-5
@stevegrubb
Copy link
Contributor

Thanks for looking at this. But I really don't like changing libev much. The reason why is it has it's own upstream. Every libev release requires remembering everything that needs patching. Maybe libev upstream would like the patch? They don't use git. You'd have to submit it to their mail list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants