diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2014-11-25 18:13:00 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2014-12-16 10:08:53 -0600 |
| commit | a64119e3963fcd358ba914c9e1a81a890666d15a (patch) | |
| tree | f81788b6b64bc56b84f59da979895078ec93b246 /src/util.c | |
| parent | 0d388adc86946f3c8cddc2493b470d47a653c4a5 (diff) | |
| download | libgit2-a64119e3963fcd358ba914c9e1a81a890666d15a.tar.gz | |
checkout: disallow bad paths on win32
Disallow:
1. paths with trailing dot
2. paths with trailing space
3. paths with trailing colon
4. paths that are 8.3 short names of .git folders ("GIT~1")
5. paths that are reserved path names (COM1, LPT1, etc).
6. paths with reserved DOS characters (colons, asterisks, etc)
These paths would (without \\?\ syntax) be elided to other paths - for
example, ".git." would be written as ".git". As a result, writing these
paths literally (using \\?\ syntax) makes them hard to operate with from
the shell, Windows Explorer or other tools. Disallow these.
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 5c305950f..6b0efbea5 100644 --- a/src/util.c +++ b/src/util.c @@ -250,6 +250,21 @@ int git__prefixcmp_icase(const char *str, const char *prefix) return strncasecmp(str, prefix, strlen(prefix)); } +int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix) +{ + int s, p; + + while(str_n--) { + s = (unsigned char)tolower(*str++); + p = (unsigned char)tolower(*prefix++); + + if (s != p) + return s - p; + } + + return (0 - *prefix); +} + int git__suffixcmp(const char *str, const char *suffix) { size_t a = strlen(str); |
