Re: [PATCH] ieee1275 : Add a check for invalid partition number

Avnish Chouhan <[email protected]> Tue, 02 Dec 2025 14:04:00 +0530
Newsgroups org.gnu.grub-devel
Message-ID <[email protected]>
On 2025-12-02 04:01, Alec Brown wrote:
> On Mon, Dec 1, 2025 at 1:52 AM, Avnish Chouhan <[email protected]> 
> wrote:
>> Adding a check for invalid partition number. grub_strtoul() can fail
>> in several scenarios like invalid input, overflow, etc will result in
>> an invalid partition number which could lead to an undefined behavior.
>> 
>> Signed-off-by: Avnish Chouhan <[email protected]>
>> ---
>>  grub-core/kern/ieee1275/openfw.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>> 
>> diff --git a/grub-core/kern/ieee1275/openfw.c 
>> b/grub-core/kern/ieee1275/openfw.c
>> index 3b492dd..29bdb72 100644
>> --- a/grub-core/kern/ieee1275/openfw.c
>> +++ b/grub-core/kern/ieee1275/openfw.c
>> @@ -512,8 +512,18 @@ grub_ieee1275_encode_devname (const char *path)
>>      }
>>    if (partition && partition[0])
>>      {
>> +      grub_errno = GRUB_ERR_NONE;
>>        unsigned int partno = grub_strtoul (partition, 0, 0);
>> 
>> +      if (grub_errno != GRUB_ERR_NONE)
> 
> This check isn't reliable. Please see how grub_strtoul() is handled in 
> commit
> ac8a37dda (net/http: Allow use of non-standard TCP/IP ports). Even if 
> it is
> reverted, the code around grub_strtoul() is fully correct.
> 
> Alec Brown

Hi Alec,
Thank you so much!

I'll surly add something similar based on commit ac8a37dda.

Regards,
Avnish Chouhan


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel