[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] i386/i386/user_ldt.c: check ldt
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 1/2] i386/i386/user_ldt.c: check ldt |
Date: |
Sun, 17 Nov 2013 12:58:25 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Marin Ramesa, le Sun 17 Nov 2013 07:01:25 +0100, a écrit :
> When ldt equals zero, and default branch is taken from the switch
> statement, and sel is not equal to zero, comparison results in
> a dereference of a null pointer. Avoid this.
>
> * i386/i386/user_ldt.c (ldt): Check if it equals zero.
There is actually already a test above in the function. The compiler
however doesn't know the test returns in all cases because it doesn't
know that the "switch covers all cases (S_CODE, S_STACK, S_DATA);. One
way to fix it is to put a default: assert(0); case, to document that
it's not supposed to happen, and catch if it does. Another way is to
use an enum instead.
Eventually, another way to fix it is to just remove the code :) The
function is not called anywhere, and I don't think it will be easy to
re-use for further code. I have thus dropped it.
Thanks,
Samuel