9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] auth_getkey: Fix a memory leak
@ 2022-11-14 18:09 Josiah Frentsos
  2022-11-14 21:45 ` Alex Musolino
  0 siblings, 1 reply; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-14 18:09 UTC (permalink / raw)
  To: 9front

diff 0e9c5f30eabbf213023658efb863dbaf6a608a51 uncommitted
--- a/sys/src/libauth/auth_getkey.c
+++ b/sys/src/libauth/auth_getkey.c
@@ -25,6 +25,7 @@
 		werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
 		return -1;
 	}
+	free(d);
 	switch(pid = fork()){
 	case -1:
 		werrstr("can't fork for %s: %r", name);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-14 18:09 [9front] auth_getkey: Fix a memory leak Josiah Frentsos
@ 2022-11-14 21:45 ` Alex Musolino
  2022-11-14 22:17   ` Josiah Frentsos
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Musolino @ 2022-11-14 21:45 UTC (permalink / raw)
  To: 9front


> diff 0e9c5f30eabbf213023658efb863dbaf6a608a51 uncommitted
> --- a/sys/src/libauth/auth_getkey.c
> +++ b/sys/src/libauth/auth_getkey.c
> @@ -25,6 +25,7 @@
>        werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
>        return -1;
>    }
> +    free(d);
>    switch(pid = fork()){
>    case -1:
>        werrstr("can't fork for %s: %r", name);

Good find, but we need to free the Dir in the “/factotum may be bad” case too. Just latch the type and free the Dir unconditionally before checking the type.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-14 21:45 ` Alex Musolino
@ 2022-11-14 22:17   ` Josiah Frentsos
  2022-11-15  9:44     ` Alex Musolino
  0 siblings, 1 reply; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-14 22:17 UTC (permalink / raw)
  To: 9front

On Mon, Nov 14, 2022 at 10:45:48PM +0100, Alex Musolino wrote:
> > diff 0e9c5f30eabbf213023658efb863dbaf6a608a51 uncommitted
> > --- a/sys/src/libauth/auth_getkey.c
> > +++ b/sys/src/libauth/auth_getkey.c
> > @@ -25,6 +25,7 @@
> >        werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
> >        return -1;
> >    }
> > +    free(d);
> >    switch(pid = fork()){
> >    case -1:
> >        werrstr("can't fork for %s: %r", name);
> 
> Good find, but we need to free the Dir in the ???/factotum may be bad??? case too. Just latch the type and free the Dir unconditionally before checking the type.

if(0)	if(d->type != '/'){
^^^^^
		werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
		return -1;
	}

Should that part be removed?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-14 22:17   ` Josiah Frentsos
@ 2022-11-15  9:44     ` Alex Musolino
  2022-11-15 22:33       ` Josiah Frentsos
  2022-11-19 14:06       ` Josiah Frentsos
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Musolino @ 2022-11-15  9:44 UTC (permalink / raw)
  To: 9front

> if(0)    if(d->type != '/'){
> ^^^^^
>        werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
>        return -1;
>    }
> 
> Should that part be removed?

Oh, I didn’t even notice the if(0) way over there. Perhaps we can just remove the dead code?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-15  9:44     ` Alex Musolino
@ 2022-11-15 22:33       ` Josiah Frentsos
  2022-11-19 14:06       ` Josiah Frentsos
  1 sibling, 0 replies; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-15 22:33 UTC (permalink / raw)
  To: 9front

On Tue, Nov 15, 2022 at 10:44:07AM +0100, Alex Musolino wrote:
> > if(0)    if(d->type != '/'){
> > ^^^^^
> >        werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
> >        return -1;
> >    }
> > 
> > Should that part be removed?
> 
> Oh, I didn???t even notice the if(0) way over there. Perhaps we can just remove the dead code?

Can we?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-15  9:44     ` Alex Musolino
  2022-11-15 22:33       ` Josiah Frentsos
@ 2022-11-19 14:06       ` Josiah Frentsos
  2022-11-19 14:10         ` Josiah Frentsos
  2022-11-30 15:01         ` Josiah Frentsos
  1 sibling, 2 replies; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-19 14:06 UTC (permalink / raw)
  To: 9front

diff 30c5296f32b87d83529d772732726891e1261c9c ca030712ba270e6b74a10ff8bf914235283e7471
--- a/sys/src/libauth/auth_getkey.c
+++ b/sys/src/libauth/auth_getkey.c
@@ -21,10 +21,6 @@
 		werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
 		return -1;
 	}
-if(0)	if(d->type != '/'){
-		werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
-		return -1;
-	}
 	switch(pid = fork()){
 	case -1:
 		werrstr("can't fork for %s: %r", name);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-19 14:06       ` Josiah Frentsos
@ 2022-11-19 14:10         ` Josiah Frentsos
  2022-11-30 15:01           ` Josiah Frentsos
  2022-11-30 15:01         ` Josiah Frentsos
  1 sibling, 1 reply; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-19 14:10 UTC (permalink / raw)
  To: 9front

diff ca030712ba270e6b74a10ff8bf914235283e7471 1e6748e7df4f757b489f82c85e2a7d8a9558d0b8
--- a/sys/src/libauth/auth_getkey.c
+++ b/sys/src/libauth/auth_getkey.c
@@ -21,6 +21,7 @@
 		werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
 		return -1;
 	}
+	free(d);
 	switch(pid = fork()){
 	case -1:
 		werrstr("can't fork for %s: %r", name);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-19 14:06       ` Josiah Frentsos
  2022-11-19 14:10         ` Josiah Frentsos
@ 2022-11-30 15:01         ` Josiah Frentsos
  1 sibling, 0 replies; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-30 15:01 UTC (permalink / raw)
  To: 9front

Ping.

diff 30c5296f32b87d83529d772732726891e1261c9c ca030712ba270e6b74a10ff8bf914235283e7471
--- a/sys/src/libauth/auth_getkey.c
+++ b/sys/src/libauth/auth_getkey.c
@@ -21,10 +21,6 @@
 		werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
 		return -1;
 	}
-if(0)	if(d->type != '/'){
-		werrstr("auth_getkey: /factotum may be bad: didn't get key %s", params);
-		return -1;
-	}
 	switch(pid = fork()){
 	case -1:
 		werrstr("can't fork for %s: %r", name);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] auth_getkey: Fix a memory leak
  2022-11-19 14:10         ` Josiah Frentsos
@ 2022-11-30 15:01           ` Josiah Frentsos
  0 siblings, 0 replies; 9+ messages in thread
From: Josiah Frentsos @ 2022-11-30 15:01 UTC (permalink / raw)
  To: 9front

Ping.

diff ca030712ba270e6b74a10ff8bf914235283e7471 1e6748e7df4f757b489f82c85e2a7d8a9558d0b8
--- a/sys/src/libauth/auth_getkey.c
+++ b/sys/src/libauth/auth_getkey.c
@@ -21,6 +21,7 @@
 		werrstr("auth_getkey: no /factotum or /boot/factotum: didn't get key %s", params);
 		return -1;
 	}
+	free(d);
 	switch(pid = fork()){
 	case -1:
 		werrstr("can't fork for %s: %r", name);

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-30 15:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 18:09 [9front] auth_getkey: Fix a memory leak Josiah Frentsos
2022-11-14 21:45 ` Alex Musolino
2022-11-14 22:17   ` Josiah Frentsos
2022-11-15  9:44     ` Alex Musolino
2022-11-15 22:33       ` Josiah Frentsos
2022-11-19 14:06       ` Josiah Frentsos
2022-11-19 14:10         ` Josiah Frentsos
2022-11-30 15:01           ` Josiah Frentsos
2022-11-30 15:01         ` Josiah Frentsos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).