]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Only free sgent if it was initialized 417/head
authorMichael Vetter <jubalh@iodoru.org>
Mon, 20 Sep 2021 09:04:50 +0000 (11:04 +0200)
committerMichael Vetter <jubalh@iodoru.org>
Mon, 20 Sep 2021 09:04:50 +0000 (11:04 +0200)
`sgent` is only initialized in `get_group()` if `is_shadowgrp` is true.
So we should also only attempt to free it if this is actually the case.

Can otherwise lead to:
```
free() double free detected in tcache 2 (gpasswd)
```

src/gpasswd.c

index a43d9a590a12501bc741b196666c4ece75e6014e..04bed83d6bbd95b08fb48b03354238ccbd5b1f28 100644 (file)
@@ -1207,11 +1207,13 @@ int main (int argc, char **argv)
        sssd_flush_cache (SSSD_DB_GROUP);
 
 #ifdef SHADOWGRP
-       if (sgent.sg_adm) {
-               xfree(sgent.sg_adm);
-       }
-       if (sgent.sg_mem) {
-               xfree(sgent.sg_mem);
+       if (is_shadowgrp) {
+               if (sgent.sg_adm) {
+                       xfree(sgent.sg_adm);
+               }
+               if (sgent.sg_mem) {
+                       xfree(sgent.sg_mem);
+               }
        }
 #endif
        if (grent.gr_mem) {