This is a discussion on Directory traversal problem within the C Programming forums, part of the General Programming Boards category; Thanks!...
Last edited by phlook; 03-16-2009 at 12:30 AM. Reason: completed
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:
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:dir_path = strcat(dir,"/"); dir_path = strcat(dir_path,dp->d_name);
and nothing else inside your if block.Code:ff_gather(data, dp->d_name); chdir("..");
Whether this works depends on your needs.
you are a saviour. why didn't i think of that sooner?!