In a C program I'm writing I need to check if a file is contained inside a directory.
This is because the file path is provided by the user and I don't want him to be able to access files he's not supposed to by providing paths such as "../../whatever" or "~/.bashrc".
Is there any way to do that with ANSI C and POSIX only (I'm trying to avoid third party libraries)?
Or should I check the path string instead? That was my first idea but it sounds a bit complicated (e.g.: paths containing "." are ok but paths containing ".." are not).
Thanks