[PATCH] Bugfix: env_api_fat.c: Return correct buffer size

6 views
Skip to first unread message

Andreas J. Reichel

unread,
Oct 19, 2017, 9:57:04 AM10/19/17
to efibootg...@googlegroups.com, Andreas Reichel
From: Andreas Reichel <andreas.r...@siemens.com>

Buffer size must include 0-termination for strings.

Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
---
env/env_api_fat.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/env/env_api_fat.c b/env/env_api_fat.c
index 354d7f8..0635024 100644
--- a/env/env_api_fat.c
+++ b/env/env_api_fat.c
@@ -475,7 +475,7 @@ int bgenv_get(BGENV *env, char *key, char *type, void *data, uint32_t maxlen)
case EBGENV_KERNELFILE:
str16to8(buffer, env->data->kernelfile);
if (!data) {
- return strlen(buffer);
+ return strlen(buffer)+1;
}
strncpy(data, buffer, strlen(buffer)+1);
if (type) {
@@ -485,7 +485,7 @@ int bgenv_get(BGENV *env, char *key, char *type, void *data, uint32_t maxlen)
case EBGENV_KERNELPARAMS:
str16to8(buffer, env->data->kernelparams);
if (!data) {
- return strlen(buffer);
+ return strlen(buffer)+1;
}
strncpy(data, buffer, strlen(buffer)+1);
if (type) {
@@ -495,7 +495,7 @@ int bgenv_get(BGENV *env, char *key, char *type, void *data, uint32_t maxlen)
case EBGENV_WATCHDOG_TIMEOUT_SEC:
sprintf(buffer, "%u", env->data->watchdog_timeout_sec);
if (!data) {
- return strlen(buffer);
+ return strlen(buffer)+1;
}
strncpy(data, buffer, strlen(buffer)+1);
if (type) {
@@ -505,7 +505,7 @@ int bgenv_get(BGENV *env, char *key, char *type, void *data, uint32_t maxlen)
case EBGENV_REVISION:
sprintf(buffer, "%u", env->data->revision);
if (!data) {
- return strlen(buffer);
+ return strlen(buffer)+1;
}
strncpy(data, buffer, strlen(buffer)+1);
if (type) {
@@ -515,7 +515,7 @@ int bgenv_get(BGENV *env, char *key, char *type, void *data, uint32_t maxlen)
case EBGENV_USTATE:
sprintf(buffer, "%u", env->data->ustate);
if (!data) {
- return strlen(buffer);
+ return strlen(buffer)+1;
}
strncpy(data, buffer, strlen(buffer)+1);
if (type) {
--
2.14.2

Andreas Reichel

unread,
Nov 2, 2017, 7:53:47 AM11/2/17
to efibootg...@googlegroups.com, jan.k...@siemens.com
On Thu, Oct 19, 2017 at 03:56:02PM +0200, Andreas J. Reichel wrote:
Can we please apply this patch now? [ This is 1/3 ]
--
Andreas Reichel
Dipl.-Phys. (Univ.)
Software Consultant

Andreas...@tngtech.com, +49-174-3180074
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring
Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller
Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082

Jan Kiszka

unread,
Nov 2, 2017, 8:37:39 AM11/2/17
to Andreas Reichel, efibootg...@googlegroups.com
On 2017-11-02 12:53, Andreas Reichel wrote:
> On Thu, Oct 19, 2017 at 03:56:02PM +0200, Andreas J. Reichel wrote:
> Can we please apply this patch now? [ This is 1/3 ]

Travel-related delay... Applied.

[ But this was not marked as "1/3"... ]

Jan
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages