[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Safe to change argv?

Why Tea

3/25/2011 11:51:00 PM

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
2 Answers

Barry Schwarz

3/26/2011 12:07:00 AM

0

On Fri, 25 Mar 2011 16:51:21 -0700 (PDT), Why Tea <ytlim1@gmail.com>
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

Keith Thompson

3/26/2011 12:30:00 AM

0

Why Tea <ytlim1@gmail.com> 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) kst-u@mib.org <http://www.ghoti.ne...
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"