Introducing a poweroff(8) command
Giorgos Keramidas
keramida at ceid.upatras.gr
Mon Aug 23 21:03:35 PDT 2004
On 2004-08-23 11:41, John Baldwin <jhb at 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 :-)
More information about the freebsd-arch
mailing list