mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
bsp: renesas: Fix RA pin name digit checks
Validate the second and third digits of RA PXXX pin names against their own characters. The previous checks used name[1] for those upper bounds, so non-digit suffixes could pass validation. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
This commit is contained in:
@@ -374,8 +374,8 @@ static rt_base_t ra_pin_get(const char *name)
|
||||
if ((rt_strlen(name) == 4) &&
|
||||
(name[0] == 'P' || name[0] == 'p') &&
|
||||
(name[1] >= '0' && name[1] <= '9') &&
|
||||
(name[2] >= '0' && name[1] <= '9') &&
|
||||
(name[3] >= '0' && name[1] <= '9'))
|
||||
(name[2] >= '0' && name[2] <= '9') &&
|
||||
(name[3] >= '0' && name[3] <= '9'))
|
||||
{
|
||||
return (name[1] - '0') * 0x100 + (name[2] - '0') * 10 + (name[3] - '0');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user