Safe to change argv?

W

Why Tea

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
 
B

Barry Schwarz

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).
 
K

Keith Thompson

Why Tea said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top