Re: Introducing a poweroff(8) command

From: Giorgos Keramidas (keramida_at_ceid.upatras.gr)
Date: 08/24/04

  • Next message: Giorgos Keramidas: "Re: Introducing a poweroff(8) command"
    Date: Tue, 24 Aug 2004 07:02:06 +0300
    To: John Baldwin <jhb@freebsd.org>
    
    

    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 :-)
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Giorgos Keramidas: "Re: Introducing a poweroff(8) command"

    Relevant Pages

    • Re: Introducing a poweroff(8) command
      ... > I think this is buggy in that p will point to the / character since you don't ... > modify it in the second case. ... To unsubscribe, ...
      (freebsd-arch)
    • Re: Introducing a poweroff(8) command
      ... On 23-Aug-2004 John Baldwin wrote: ... > I think this is buggy in that p will point to the / character since you don't ... > modify it in the second case. ...
      (freebsd-arch)
    • Re: Memory Manager DLL Validation
      ... > NOT modify any data beyond the last used character. ... safe. ... IMO reading past the end is fine, but writing is not acceptable. ...
      (borland.public.delphi.language.basm)
    • Re: How to change ALL comma in a CEdit into double byte comma?
      ... Then modify the strings to contain the characters you need before adding ... If you need to turn one character into two you could ... the user press the comma key or there is old data which has comma and needs ...
      (microsoft.public.vc.mfc)
    • Re: add a0 format to language to print trimmed character variables
      ... The i0 for integers doesn't modify the value printed out. ... For the character case, ... character variables produce an array in which each element could ... in an I/O list as otherwise an assignment would just get a new ...
      (comp.lang.fortran)