]> git.ipfire.org Git - thirdparty/linux.git/commit
rtla: Replace atoi() with a robust strtoi()
authorWander Lairson Costa <wander@redhat.com>
Tue, 6 Jan 2026 11:49:40 +0000 (08:49 -0300)
committerTomas Glozar <tglozar@redhat.com>
Wed, 7 Jan 2026 14:57:55 +0000 (15:57 +0100)
commit7e9dfccf8f11c26208211457c4597a466135b56a
tree12a7d6bd2cec16e848c4cc5829007d9737dda961
parent648634d17c813b35da775982662e56ea8ce750de
rtla: Replace atoi() with a robust strtoi()

The atoi() function does not perform error checking, which can lead to
undefined behavior when parsing invalid or out-of-range strings. This
can cause issues when parsing user-provided numerical inputs, such as
signal numbers, PIDs, or CPU lists.

To address this, introduce a new strtoi() helper function that safely
converts a string to an integer. This function validates the input and
checks for overflows, returning a negative value on  failure.

Replace all calls to atoi() with the new strtoi() function and add
proper error handling to make the parsing more robust and prevent
potential issues.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260106133655.249887-5-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
tools/tracing/rtla/src/actions.c
tools/tracing/rtla/src/utils.c
tools/tracing/rtla/src/utils.h