ehlo,

@see commit message in attached trivial patch.

LS
>From ad7c4215e765cf98092a06cb5ae18d82b8b42b5e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <[email protected]>
Date: Wed, 13 Apr 2016 17:43:13 +0200
Subject: [PATCH 2/3] IDMAP: Fix warning: Assigned value is garbage or
 undefined

The function get_range could return IDMAP_SUCCESS
withunitialized range if function generate_slice returns
IDMAP_OUT_OF_MEMORY

Error: UNINIT (CWE-457): [#def5]
sssd-1.13.4/src/lib/idmap/sss_idmap.c:864:
    var_decl: Declaring variable "range" without initializer.
sssd-1.13.4/src/lib/idmap/sss_idmap.c:879:
    uninit_use: Using uninitialized value "range".
 #  877|       }
 #  878|
 #  879|->     *_range = range;
 #  880|       return IDMAP_SUCCESS;
 #  881|   }
---
 src/lib/idmap/sss_idmap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/lib/idmap/sss_idmap.c b/src/lib/idmap/sss_idmap.c
index 
e3e9972b802748770a5f7440fa8ddc8ba75d3362..19cefb7f745a647ecb8ade487e91f8e7f7a5dda0
 100644
--- a/src/lib/idmap/sss_idmap.c
+++ b/src/lib/idmap/sss_idmap.c
@@ -858,7 +858,7 @@ get_range(struct sss_idmap_ctx *ctx,
           long long rid,
           struct idmap_range_params **_range)
 {
-    char *secondary_name;
+    char *secondary_name = NULL;
     enum idmap_error_code err;
     int first_rid;
     struct idmap_range_params *range;
@@ -871,8 +871,10 @@ get_range(struct sss_idmap_ctx *ctx,
     }
 
     err = generate_slice(ctx, secondary_name, first_rid, &range);
-    if (err == IDMAP_OUT_OF_SLICES) {
-        ctx->free_func(secondary_name, ctx->alloc_pvt);
+    if (err != IDMAP_SUCCESS) {
+        if (secondary_name != NULL) {
+            ctx->free_func(secondary_name, ctx->alloc_pvt);
+        }
         return err;
     }
 
-- 
2.7.3

_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to