TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Git for Windows accidentally creates NTFS alternate data streams

349 pointsby latkinalmost 9 years ago

13 comments

smhendersonalmost 9 years ago
<i>The root cause of all this is a relatively obscure NTFS feature called alternate data streams.</i><p>Obscure indeed, I&#x27;ve never seen them used for anything other than hiding malicious content. Curious, I read about them on Wikipedia[1] and it turns out they were originally created to support resource forks in Services for Macintosh. Browsers also use them to flag files downloaded from the internet.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;NTFS#Alternate_data_streams_.28ADS.29" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;NTFS#Alternate_data_streams_.2...</a>
评论 #12130766 未加载
评论 #12130912 未加载
评论 #12130501 未加载
评论 #12132403 未加载
评论 #12139691 未加载
评论 #12132670 未加载
评论 #12130489 未加载
评论 #12130624 未加载
评论 #12139501 未加载
评论 #12131444 未加载
评论 #12130564 未加载
评论 #12131737 未加载
评论 #12131243 未加载
评论 #12131354 未加载
评论 #12130686 未加载
kazinatoralmost 9 years ago
The colon has been special since the dawn of DOS. For instance, you cannot use &quot;con:&quot; as a file name. (In fact, in a fit of extreme stupidity, DOS also claimed some devices with no Colon suffix, like &quot;con&quot; and &quot;prn&quot;, effectively making these into globally reserved names in any directory.)<p>Stock Cygwin does something special with the colon character, so the Cygwin git shouldn&#x27;t have this problem. A path like &quot;C:foo.txt&quot; is not understood by stock Cygwin as a relative reference in the current directory of drive C; the colon is mapped to some other character and then this is just a regular one-component pathname.<p>In the Cygnal project (Cygwin Native Appplication Library), paths passed to library are considered native. So that certain useful virtual filesystem areas remain available, I remapped Cygwin&#x27;s &quot;&#x2F;dev&quot; and &quot;&#x2F;proc&quot; to &quot;dev:&#x2F;&quot; and &quot;proc:&#x2F;&quot;, taking advantage of the special status of the colon to take this liberty. You can list these directories (opendir, readdir, ...) and of course open the entries inside them; but chdir is not allowed into these locations. (Unlike under stock Cygwin, where you can chdir to &#x2F;dev). chdir is not allowed because then that would render the library&#x27;s current working directory out of sync with the Win32 process current working directory, which would not be &quot;native&quot; behavior.
评论 #12132174 未加载
评论 #12132154 未加载
评论 #12131411 未加载
Someonealmost 9 years ago
It&#x27;s not alone. In MS SQL Server, you can name a database &quot;foo:bar&quot;. If you give a database such a name when you restore it from disk, you&#x27;ll find that the database takes zero bytes on disk (at least, that&#x27;s what Explorer claims) Your disk space is gone, though.
评论 #12131430 未加载
duncansalmost 9 years ago
Related to this bug: used to be a vulnerability in IIS back in the late 90s where you could append ::$DATA to a file name (e.g Foo.asp::$DATA) and download a server-side script&#x27;s source code.
评论 #12131925 未加载
Grue3almost 9 years ago
I had a related problem with Dropbox. Some files uploaded from my Linux machine were not synced to my Windows machine. Later I narrowed down this problem to images being saved from Twitter, which have URLs ending with &quot;:orig&quot;. On Linux, Firefox happily saves such images as &quot;blahblah:orig.jpg&quot;, whereas on Windows it uses space instead of a colon. And of course Dropbox on Windows would completely ignore filenames that contain colons and tell that the directories are synced, when they obviously aren&#x27;t.
评论 #12130478 未加载
artifaxxalmost 9 years ago
That is quite the obscure and interesting issue to run into! Who puts colons in their filenames though? I haven&#x27;t ever seen that used...
评论 #12130263 未加载
评论 #12130718 未加载
评论 #12130388 未加载
评论 #12130258 未加载
评论 #12130241 未加载
评论 #12130625 未加载
评论 #12131102 未加载
评论 #12130391 未加载
评论 #12132806 未加载
评论 #12131282 未加载
评论 #12130682 未加载
mcculleyalmost 9 years ago
This is interesting. I was just recently working on an app where I wanted to ensure the UI wouldn&#x27;t accept problematic characters in filenames. Obviously, Unix has problems with &#x27;&#x2F;&#x27;. I&#x27;ll add &#x27;:&#x27; to the list. That&#x27;s unfortunate. What else should portable apps avoid?
评论 #12130554 未加载
评论 #12131195 未加载
评论 #12130654 未加载
评论 #12130570 未加载
AWildDHHAppearsalmost 9 years ago
MacOs (i.e., Os9 and before) had special meaning for colons, too. I wonder what would happen for git on those platforms.<p>Edit: Apparently colon is _still_ a special character on Mac! <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;13298434&#x2F;colon-appears-as-forward-slash-when-creating-file-name" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;13298434&#x2F;colon-appears-as...</a>
评论 #12131923 未加载
评论 #12132555 未加载
jorangreefalmost 9 years ago
The flip-side of this:<p>I was running a fuzz test on a backup tool, which verified that file data and metadata (including timestamps) as reflected by Windows were exactly as produced by the fuzz test.<p>I noticed that for some &quot;.eml&quot; files this was not the case. The mtime of these files was being modified by something else after the initial create by the application. At last, it came down to a Windows process which was automatically indexing &quot;.eml&quot; files and creating an ADS for each of them, thereby touching the mtime.<p>This was intentional on the part of Windows, but I never saw it coming.
xg15almost 9 years ago
The problem should be addressed, but the proposed workaround seems strange. So git should refuse to write the file to disk? How am I supposed to use a git repo that contains such problematic files on Windows then?
评论 #12130591 未加载
评论 #12130551 未加载
评论 #12130948 未加载
评论 #12130602 未加载
评论 #12131931 未加载
sickbeardalmost 9 years ago
putting colons in your filenames are almost as weird as alternate data streams.
评论 #12130438 未加载
评论 #12130468 未加载
评论 #12132152 未加载
评论 #12130451 未加载
fowl2almost 9 years ago
&quot;McAfee Web Gateway&quot; thinks this is porn, great.
评论 #12134223 未加载
评论 #12134120 未加载
ragsagaralmost 9 years ago
Wonder why this site is blocked in UAE! :|