apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: [PATCH] apr_stat - fix getting APR_FINFO_NAME on WIN32
Date Fri, 10 Jan 2003 19:43:23 GMT
Actually, calling APR_FINFO_NAME without APR_FINFO_LINK
is an entirely *different* question, since you are asking for the name
of the TARGET of any symlink, not the source.

I agree this should be an error case, perhaps APR_EINVAL.

As far as your observation of 

>    finfo->fname = thefile->fname;

Don't forget this is a bad idea, since thefile may go out of scope before
the finfo, causing a segfault that the user doesn't control.  We have to
keep it in the same scope, and if that means an apr_pstrdup, then we
are wasting a bit of memory to do so.


At 11:53 AM 1/10/2003, Mladen Turk wrote:
>Don't know if someone noticed but the apr_finfo_t.name is filled out
>only in rare cases, when one explicitly sets the (APR_FINFO_NAME |
>APR_FINFO_LINK) to the wanted param of apr_stat.
>For example apr_stat(&info, "some.file", APR_FINFO_NAME, p) never fills
>the info.name member.
>The patch fixes that by returning APR_INCOMPLETE from the
>apr_file_info_get. The current version returns APR_SUCCESS no mater what
>the wanted params was. 
>Using the patch call to resolve_idnet doesn't returns if the
>APR_FINFO_NAME flag was specified).
>The other problem is that info.fname is never resolved too. For example
>the unix apr_file_info_get always sets the fname from apr_file_t.
>This can be easily achieved simply using
>    finfo->fname = thefile->fname;
>before the function returns. 
>Index: filestat.c
>RCS file: /home/cvspublic/apr/file_io/win32/filestat.c,v
>retrieving revision 1.77
>diff -u -r1.77 filestat.c
>--- filestat.c  7 Jan 2003 00:52:53 -0000       1.77
>+++ filestat.c  10 Jan 2003 17:30:28 -0000
>@@ -449,11 +449,12 @@
>     /* If we still want something more (besides the name) go get it! 
>      */
>-    if ((wanted &= ~finfo->valid) & ~APR_FINFO_NAME) {
>-        return more_finfo(finfo, thefile->filehand, wanted,
>+    if ((wanted & ~finfo->valid) & ~APR_FINFO_NAME) {
>+        return more_finfo(finfo, thefile->filehand, 
>+                          wanted & ~finfo->valid, MORE_OF_HANDLE);
>     }
>-    return APR_SUCCESS;
>+    return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS;
> }
> APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname,

View raw message