Date: Tue, 24 Aug 2004 07:02:06 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-arch@freebsd.org Subject: Re: Introducing a poweroff(8) command Message-ID: <20040824040206.GA28962@gothmog.gr> In-Reply-To: <200408231141.25077.jhb@FreeBSD.org> References: <20040821191659.GA94336@gothmog.gr> <20040821202252.GB94336@gothmog.gr> <200408231141.25077.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-08-23 11:41, John Baldwin <jhb@freebsd.org> wrote: > On Saturday 21 August 2004 04:22 pm, Giorgos Keramidas wrote: > > --- reboot.c 9 Apr 2004 19:58:35 -0000 1.20 > > +++ reboot.c 17 Aug 2004 21:55:57 -0000 > > @@ -70,9 +70,13 @@ > > char *kernel, *p; > > const char *user; > > > > - if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) { > > + p = rindex(*argv, '/') ? p + 1 : *argv; > > + if (strcmp(p, "halt") == 0) { > > I think this is buggy in that p will point to the / character since you don't > modify it in the second case. I.e. what you wrote is basically this: > > p = rindex(*argv, '/'); > if (p != NULL) > p + 1; /* does nothing */ > else > *argv; /* also does nothing */ True. I think I'll have to write this as this: > p = rindex(argv[0], '/'); > if (p != NULL) > p++; > else > p = argv[0]; Thanks for spotting this :-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040824040206.GA28962>