From: Andreas Reichel <[email protected]>

Buffer size must include 0-termination for strings.

Signed-off-by: Andreas Reichel <[email protected]>
---
 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

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20171019135602.7484-1-andreas.reichel.ext%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to