[issue2755] Windows reserved filenames must not be fed into file access API functions

Adrian Buehlmann bugs at mercurial.selenic.com
Wed Apr 6 18:53:28 UTC 2011


New submission from Adrian Buehlmann <adrian at cadifra.com>:

Create a repo on a posix OS with a changeset that adds a file 'con.xml'.
Then hg serve that repo and try cloning it onto Windows.

  $ hg clone http://kermit:8000/ weird
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  updating to branch default
  abort: No usable temporary filename found

Again, with more details:

  $ hg clone --traceback --debug http://kermit:8000/ weird
  using http://kermit:8000/
  sending capabilities command
  sending heads command
  requesting all changes
  sending changegroup command
  adding changesets
  changesets: 1 chunks
  add changeset cb93c76d053f
  adding manifests
  manifests: 1/1 chunks (100.00%)
  adding file changes
  adding con.xml revisions
  files: 1/1 chunks (100.00%)
  added 1 changesets with 1 changes to 1 files
  updating the branch cache
  updating to branch default
  resolving manifests
   overwrite False partial False
   ancestor 000000000000 local 000000000000+ remote cb93c76d053f
   con.xml: remote created -> g
  updating: con.xml 1/1 files (100.00%)
  getting con.xml
  Traceback (most recent call last):
    File "mercurial\dispatch.pyo", line 58, in _runcatch
    File "mercurial\dispatch.pyo", line 601, in _dispatch
    File "mercurial\dispatch.pyo", line 406, in runcommand
    File "mercurial\extensions.pyo", line 178, in wrap
    File "hgext\color.pyo", line 224, in colorcmd
    File "mercurial\dispatch.pyo", line 655, in _runcommand
    File "mercurial\dispatch.pyo", line 609, in checkargs
    File "mercurial\dispatch.pyo", line 598, in <lambda>
    File "mercurial\util.pyo", line 433, in check
    File "mercurial\commands.pyo", line 851, in clone
    File "mercurial\hg.pyo", line 357, in clone
    File "mercurial\hg.pyo", line 386, in update
    File "mercurial\merge.pyo", line 550, in update
    File "mercurial\merge.pyo", line 349, in applyupdates
    File "mercurial\localrepo.pyo", line 665, in wwrite
    File "mercurial\util.pyo", line 889, in __call__
    File "mercurial\win32.pyo", line 353, in unlink
  IOError: [Errno 17] No usable temporary filename found
  abort: No usable temporary filename found
  $ hg version -q
  Mercurial Distributed SCM (version 1.8.2+36-1aea86673dee)

As documented on http://msdn.microsoft.com/en-
us/library/aa365247(v=vs.85).aspx
CON is a reserved filename on Windows.

A chat with python reveals:

  $ python
  Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit 
(AMD64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>> f = open('con.xml', 'w')
  >>> f.write('bla')
  >>> f.close()
  bla>>>

File access seems to work without raising any exception, but thanks to the 
reserved
file name, weird things are done: the text is written to the console.

Since we can get filenames in repos coming from posix OS' that may trigger 
such weird
behavior on Windows, we must catch reserved names in filenames before they 
get a chance
to hit the file access APIs on Windows.

The store is fine thanks to the fncache repo format introduced in Mercurial 
1.1, but we
need to carefully check the filenames when e.g. writing the working dir.

(initiated by http://www.selenic.com/pipermail/mercurial/2011-
April/037856.html )

----------
assignedto: abuehl
messages: 15984
nosy: abuehl
priority: bug
status: unread
title: Windows reserved filenames must not be fed into file access API functions

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue2755>
____________________________________________________


More information about the Mercurial-devel mailing list