Thread: Directory traversal problem

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    11

    Directory traversal problem

    Thanks!
    Last edited by phlook; 03-16-2009 at 12:30 AM. Reason: completed

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    But return_dir is not initialized. Trying to write there is undefined, and can cause real problems.

    Once you fix that, I'm not sure what precisely your program is trying to do. But there's an issue with this:
    Code:
    dir_path = strcat(dir,"/");
    dir_path = strcat(dir_path,dp->d_name);
    Here you are modifying the string contained in dir. This means you are modifying the original string as passed to the function. An easy way around this is something like:
    Code:
    ff_gather(data, dp->d_name);
    chdir("..");
    and nothing else inside your if block.

    Whether this works depends on your needs.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    11
    you are a saviour. why didn't i think of that sooner?!

    thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Directory traversal issue
    By Mostly Harmless in forum Windows Programming
    Replies: 5
    Last Post: 12-21-2007, 12:44 PM
  2. C/C++ String Problem.
    By Jaken Veina in forum C++ Programming
    Replies: 7
    Last Post: 07-09-2005, 10:11 PM
  3. Replies: 6
    Last Post: 07-30-2003, 03:08 AM
  4. Need Help
    By GSLR in forum C Programming
    Replies: 1
    Last Post: 02-05-2002, 12:20 PM
  5. The Site Directory
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-22-2002, 08:19 PM