Safe to change argv?

Discussion in 'C Programming' started by Why Tea, Mar 25, 2011.

  1. Why Tea

    Why Tea Guest

    When a program receives its command line arguments,
    e.g. -abc some_value, is it safe to change "-abc"
    to "--abc"? In general, how safe is it to extend an
    argv to less than MAX_ARG_STRLEN?

    /Why Tea
     
    Why Tea, Mar 25, 2011
    #1
    1. Advertising

  2. On Fri, 25 Mar 2011 16:51:21 -0700 (PDT), Why Tea <>
    wrote:

    >When a program receives its command line arguments,
    >e.g. -abc some_value, is it safe to change "-abc"
    >to "--abc"? In general, how safe is it to extend an
    >argv to less than MAX_ARG_STRLEN?


    Paragraph 5.1.2.2.1-2 guarantees that you can change the value of the
    5 bytes in the string "-abc". It does not say anything about the
    memory that follows the string. It is entirely possible for the "6th
    byte" to be part of the next command line argument. It is also
    possible for the bytes that follow the string to hold system specific
    data needed when main returns to your host environment.

    All in all it sounds like a really bad idea (tm).

    --
    Remove del for email
     
    Barry Schwarz, Mar 26, 2011
    #2
    1. Advertising

  3. Why Tea <> writes:
    > When a program receives its command line arguments,
    > e.g. -abc some_value, is it safe to change "-abc"
    > to "--abc"? In general, how safe is it to extend an
    > argv to less than MAX_ARG_STRLEN?


    Why do you want to do this?

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 26, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    4,597
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    5,962
    Richard Heathfield
    Sep 15, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,646
    Old Wolf
    Jan 20, 2004
  4. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    909
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  5. Why Tea

    Re: Safe to change argv?

    Why Tea, Mar 26, 2011, in forum: C Programming
    Replies:
    3
    Views:
    522
    Seebs
    Mar 26, 2011
Loading...

Share This Page