[PATCH 1/1] efi_loader: compliance Simple Text Input Ex Protocol

We cannot expect the buffers passed to the input protocols to be zero filled. If only modifier keys are pressed, we have to return EFI_NOT_READY but we still have to fill the key structure.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3164fd484e..1fcaabe1c4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -987,6 +987,7 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke_ex( efi_cin_check();
if (!key_available) { + memset(key_data, 0, sizeof(struct efi_key_data)); ret = EFI_NOT_READY; goto out; }

On Thu, 1 Sept 2022 at 16:07, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
We cannot expect the buffers passed to the input protocols to be zero filled. If only modifier keys are pressed, we have to return EFI_NOT_READY but we still have to fill the key structure.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3164fd484e..1fcaabe1c4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -987,6 +987,7 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke_ex( efi_cin_check();
if (!key_available) {
memset(key_data, 0, sizeof(struct efi_key_data));
'\0'
ret = EFI_NOT_READY; goto out; }
-- 2.37.2

On 9/2/22 01:52, Simon Glass wrote:
On Thu, 1 Sept 2022 at 16:07, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
We cannot expect the buffers passed to the input protocols to be zero filled. If only modifier keys are pressed, we have to return EFI_NOT_READY but we still have to fill the key structure.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3164fd484e..1fcaabe1c4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -987,6 +987,7 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke_ex( efi_cin_check();
if (!key_available) {
memset(key_data, 0, sizeof(struct efi_key_data));
'\0'
memset() wants int here not char. (Yes, the compiler would add the missing conversion for '\0'.)
Best regards
Heinrich
ret = EFI_NOT_READY; goto out; }
-- 2.37.2

On Fri, 2 Sept 2022 at 03:35, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
On 9/2/22 01:52, Simon Glass wrote:
On Thu, 1 Sept 2022 at 16:07, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
We cannot expect the buffers passed to the input protocols to be zero filled. If only modifier keys are pressed, we have to return EFI_NOT_READY but we still have to fill the key structure.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3164fd484e..1fcaabe1c4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -987,6 +987,7 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke_ex( efi_cin_check();
if (!key_available) {
memset(key_data, 0, sizeof(struct efi_key_data));
'\0'
memset() wants int here not char. (Yes, the compiler would add the missing conversion for '\0'.)
Best regards
Heinrich
ret = EFI_NOT_READY; goto out; }
-- 2.37.2
Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org

Hi Heinrich,
On Thu, 1 Sept 2022 at 18:36, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
On 9/2/22 01:52, Simon Glass wrote:
On Thu, 1 Sept 2022 at 16:07, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
We cannot expect the buffers passed to the input protocols to be zero filled. If only modifier keys are pressed, we have to return EFI_NOT_READY but we still have to fill the key structure.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/efi_loader/efi_console.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3164fd484e..1fcaabe1c4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -987,6 +987,7 @@ static efi_status_t EFIAPI efi_cin_read_key_stroke_ex( efi_cin_check();
if (!key_available) {
memset(key_data, 0, sizeof(struct efi_key_data));
'\0'
memset() wants int here not char. (Yes, the compiler would add the missing conversion for '\0'.)
Sure, but it is actually a char, right? It is not good practice to have function arguments be non-natural types due to the masking the compiler must then do (increases code size and lower performance). So that is why memset() uses a natural type.
Regards, Simon
participants (3)
-
Heinrich Schuchardt
-
Ilias Apalodimas
-
Simon Glass