]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CLI: Fix memory leak in cli_listen (fixes #285)
authorVojtech Vilimek <vojtech.vilimek@nic.cz>
Tue, 17 Jun 2025 13:22:58 +0000 (15:22 +0200)
committerVojtech Vilimek <vojtech.vilimek@nic.cz>
Tue, 17 Jun 2025 13:22:58 +0000 (15:22 +0200)
sysdep/unix/main.c

index 85acc21864b0a26fd5d8d4d3f475f0629e253d0b..deb108c30370b4fe282f9e07c0333e497a971690 100644 (file)
@@ -582,25 +582,30 @@ cli_listen(struct cli_config *cf)
   if (sk_open_unix(s, cf->name) < 0)
   {
     log(L_ERR "Cannot create control socket %s: %m", cf->name);
-    return NULL;
+    goto err;
   }
 
   if (cf->uid || cf->gid)
     if (chown(cf->name, cf->uid, cf->gid) < 0)
     {
       log(L_ERR "Cannot chown control socket %s: %m", cf->name);
-      return NULL;
+      goto err;
     }
 
   if (chmod(cf->name, cf->mode) < 0)
   {
     log(L_ERR "Cannot chmod control socket %s: %m", cf->name);
-    return NULL;
+    goto err;
   }
 
   cli_listener_add_tail(&cli_listeners, l);
 
   return l;
+
+err:
+  rfree(s);
+  mb_free(l);
+  return NULL;
 }
 
 static void