Skip to content

Instantly share code, notes, and snippets.

@fvandepitte
Last active November 7, 2016 15:24
Show Gist options
  • Save fvandepitte/ec28f4321a48061808d0095853af7bd7 to your computer and use it in GitHub Desktop.
Save fvandepitte/ec28f4321a48061808d0095853af7bd7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main ()
{
char* path = "/Users/user/test/tëst/test"; //Sent by the system
char* wp = "/Users/user/test/tëst"; //Some path we claim to be ours
size_t wp_len = strlen(wp);
if (strncmp (wp,path,wp_len) == 0) //Check is path is a subpath
{
printf ("matched %s\n", path);
}else {
printf ("could not match\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment