Validate pathnames before using them