Re: Polipo on MingW

Gisle Vanem <[email protected]>
Newsgroups gmane.comp.web.polipo.user
Message-ID <[email protected]>
"Juliusz Chroboczek" <[email protected]> wrote:

>> +#ifdef WIN32  /* Require "x:/" */
>> +    if(!isalpha(root->string[0]) || root->string[1] != ':') {
>> +        return -2;
>> +    }
>> +#else
> 
> Hmm... I know nothing about Windows, but shouldn't you be checking for
> the third character being '/'?

Yes, that would be safer. Come to think of it, a syntax like
"\\server\share\path\file" could be accepted. E.g. put the
web-cache on another SMB/file-server :-)

> What name do you want me to commit your patch under (please use
> something suitable for a Git committer id, for exemple
> "Gisle Vanem <[email protected]>").

Okay.

New improved diff:

--- Git-latest\diskcache.c      Thu Mar 31 17:13:34 2011
+++ diskcache.c Mon Apr 04 21:44:59 2011
@@ -123,14 +123,22 @@
 checkRoot(AtomPtr root)
 {
     struct stat ss;
-    int rc;
+    int rc, okay;

     if(!root || root->length == 0)
         return 0;

+#ifdef WIN32  /* Require "x:/" or "x:\\" */
+    okay = isalpha(root->string[0]) && (root->string[1] == ':') &&
+           ((root->string[2] == '/') || (root->string[2] == '\\'));
+    if(!okay) {
+        return -2;
+    }
+#else
     if(root->string[0] != '/') {
         return -2;
     }
+#endif

     rc = stat(root->string, &ss);
     if(rc < 0)

--------------------

BTW. The above case handle DOS/Win slashes ('\\'), but many other places
in Polipo almost require forward Unix-slashes ('/') it seems.  All Win core APIs
handles '\\' and '/' equally well. But maybe we should *deny* the use of '\\' to
be consistent across Win/unix.  

--gv


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.