Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

long file names(continued)

raanazraanaz Posts: 8Member
I am checking argc because the first argument is fixed. The console aplication is called by another application. The calling application checks that there should be two parameters being passed to the console application. argv[1] is a fixed parameter and argv[2] is the filepath. If this is not the case then the calling application does not call the executable. That is why i am checking argc and i cant control the input argument to be in qoutes.

Thanks

In reply to tsagld who wrote:

Realize that your code only works if the path is the last argument in the list. Besides that, you have to allocate space for cdrpath before you know how much space is needed. That's vulnerable to buffer overflows.
As I stated before, it is better to pass the path between double quotes. Stober gave an example.

Comments

  • tsagldtsagld Posts: 621Member
    : I am checking argc because the first argument is fixed. The console aplication is called by another application. The calling application checks that there should be two parameters being passed to the console application. argv[1] is a fixed parameter and argv[2] is the filepath. If this is not the case then the calling application does not call the executable. That is why i am checking argc and i cant control the input argument to be in qoutes.
    :
    : Thanks
    :
    : In reply to tsagld who wrote:
    :
    : Realize that your code only works if the path is the last argument in the list. Besides that, you have to allocate space for cdrpath before you know how much space is needed. That's vulnerable to buffer overflows.
    : As I stated before, it is better to pass the path between double quotes. Stober gave an example.


    In that case, the other application should pass the filepath within quotes. You should contact the programmer about that, if possible. Your solution is bad, but probably the best you can do if the other application cannot be adjusted.


    Greets,
    Eric Goldstein
    http://www.gvh-maatwerk.nl


  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2006-7-25 4:46:16[/red][/b][hr]
    :
    :Besides that, you have to allocate space for cdrpath before you know how much space is needed. That's vulnerable to buffer overflows.

    not really, unless the path is not valid. just make a buffer of size _MAX_PATH (assumeing MS-Windows os). I think *nix has a similar maximum.

Sign In or Register to comment.