apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From M Joonas Pihlaja <jpihl...@cc.helsinki.fi>
Subject RE: problem appending to a file
Date Fri, 06 Jan 2006 02:49:03 GMT


On Thu, 5 Jan 2006 Alex.Krumm-Heller@csiro.au wrote:

> Whoops, I forgot to mention that this is occurring under windows,
> whereas it works fine under linux.
>

Hi Alex & APR-dev,

I came across this a few weeks ago as well, but forgot to mail
the apr-dev list about is.  The problem is in
file_io/win32/seek.c:apr_file_seek(), where there's a slight
thinko in the case for files opened with APR_XTHREAD.  The patch
below fixes it for me[1].

Regarding apr_file_seek() in general, it's not clear from the
docs what should happen when the caller specifies an out of
bounds seek, and certainly the code isn't too picky about them.

Best Regards,

Jooonas


[1] Hope this comes out correctly out of word-wrap:

8<----------8<----------------
*** seek.c      2005-09-09 00:47:13.000000000 +0300
--- patched-seek.c      2006-01-06 04:39:49.050970293 +0200
***************
*** 105,112 ****

              case APR_END:
                  rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile);
!                 if (rc == APR_SUCCESS && finfo.size - *offset < 0)
                      thefile->filePtr = finfo.size - *offset;
                  break;

              default:
--- 105,120 ----

              case APR_END:
                  rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile);
!                 if (rc == APR_SUCCESS) {
!                     if (finfo.size - *offset < 0) {
!                         thefile->filePtr = 0;
!                     }
!                     else if (finfo.size - *offset > finfo.size) {
!                         thefile->filePtr = finfo.size;
!                     } else {
                          thefile->filePtr = finfo.size - *offset;
+                     }
+                 }
                  break;

              default:
8<----------8<----------------

Mime
View raw message