Fossil SCM

off-by-24 error in handling of long directory names (>MAX_PATH-12) on Windows

jan.nijtmans 2015-12-04 14:57 trunk
Commit 2900c25d1a3032772f6d8aa9a0bb5225579079f4
1 file changed +2 -2
+2 -2
--- src/utf8.c
+++ src/utf8.c
@@ -217,11 +217,11 @@
217217
** prefixed with the extended path prefix. See:
218218
** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath>
219219
**/
220220
if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':'
221221
&& (zUtf8[2]=='\\' || zUtf8[2]=='/') ){
222
- if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH){
222
+ if( wUnicode==zUnicode && (nChar+nReserved)>MAX_PATH){
223223
memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t));
224224
memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t));
225225
wUnicode += 4;
226226
}
227227
/*
@@ -228,11 +228,11 @@
228228
** If (remainder of) path starts with "<drive>:/" or "<drive>:\",
229229
** leave the ':' intact but translate the backslash to a slash.
230230
*/
231231
wUnicode[2] = '\\';
232232
wUnicode += 3;
233
- }else if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH
233
+ }else if( wUnicode==zUnicode && (nChar+nReserved)>MAX_PATH
234234
&& (zUtf8[0]=='\\' || zUtf8[0]=='/')
235235
&& (zUtf8[1]=='\\' || zUtf8[1]=='/') && zUtf8[2]!='?'){
236236
memmove(wUnicode+6, wUnicode, nChar*sizeof(wchar_t));
237237
memcpy(wUnicode, L"\\\\?\\UNC", 7*sizeof(wchar_t));
238238
wUnicode += 7;
239239
--- src/utf8.c
+++ src/utf8.c
@@ -217,11 +217,11 @@
217 ** prefixed with the extended path prefix. See:
218 ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath>
219 **/
220 if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':'
221 && (zUtf8[2]=='\\' || zUtf8[2]=='/') ){
222 if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH){
223 memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t));
224 memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t));
225 wUnicode += 4;
226 }
227 /*
@@ -228,11 +228,11 @@
228 ** If (remainder of) path starts with "<drive>:/" or "<drive>:\",
229 ** leave the ':' intact but translate the backslash to a slash.
230 */
231 wUnicode[2] = '\\';
232 wUnicode += 3;
233 }else if( wUnicode==zUnicode && (nChar-nReserved)>MAX_PATH
234 && (zUtf8[0]=='\\' || zUtf8[0]=='/')
235 && (zUtf8[1]=='\\' || zUtf8[1]=='/') && zUtf8[2]!='?'){
236 memmove(wUnicode+6, wUnicode, nChar*sizeof(wchar_t));
237 memcpy(wUnicode, L"\\\\?\\UNC", 7*sizeof(wchar_t));
238 wUnicode += 7;
239
--- src/utf8.c
+++ src/utf8.c
@@ -217,11 +217,11 @@
217 ** prefixed with the extended path prefix. See:
218 ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath>
219 **/
220 if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':'
221 && (zUtf8[2]=='\\' || zUtf8[2]=='/') ){
222 if( wUnicode==zUnicode && (nChar+nReserved)>MAX_PATH){
223 memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t));
224 memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t));
225 wUnicode += 4;
226 }
227 /*
@@ -228,11 +228,11 @@
228 ** If (remainder of) path starts with "<drive>:/" or "<drive>:\",
229 ** leave the ':' intact but translate the backslash to a slash.
230 */
231 wUnicode[2] = '\\';
232 wUnicode += 3;
233 }else if( wUnicode==zUnicode && (nChar+nReserved)>MAX_PATH
234 && (zUtf8[0]=='\\' || zUtf8[0]=='/')
235 && (zUtf8[1]=='\\' || zUtf8[1]=='/') && zUtf8[2]!='?'){
236 memmove(wUnicode+6, wUnicode, nChar*sizeof(wchar_t));
237 memcpy(wUnicode, L"\\\\?\\UNC", 7*sizeof(wchar_t));
238 wUnicode += 7;
239

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button