Hi David --

Thanks for looking into this.  I'll try to give it a look over tomorrow or the
next day.  I'm dubious that bypassing the mmap on a zero-length file is going
to be without consequences, but if used only for reading it needs to be
wrapped in length guards anyway and might work out.


Devin

On Wed, Oct 05, 2005 at 11:09:56AM +0200, David Purdy wrote:
> Hi. I made a fix which appears to work (I ran some tests with my updated  
> build on a 2.6.12 kernel, vs the original debian build (on a pre-2.6.12  
> kernel) and the output (screen & files) appear to be the same.  
>   
> But I don't know the Quelcom logic well enough to ensure this fix won't  
> break something else. Please check this. 
>  
> David.
> 

> diff -aruN quelcom-0.4.0-orig/lib/qfile.cc quelcom-0.4.0/lib/qfile.cc
> --- quelcom-0.4.0-orig/lib/qfile.cc   2001-02-23 14:29:12.000000000 +0200
> +++ quelcom-0.4.0/lib/qfile.cc        2005-10-05 09:18:51.000000000 +0200
> @@ -62,9 +62,13 @@
>   
>    size = stat.st_size;
>  
> -  if 
> ((map=(caddr_t)mmap((caddr_t)0,size,mapflags,MAP_SHARED,fd,0))==MAP_FAILED) {
> -    close(fd);
> -    throw qexception(__PRETTY_FUNCTION__,strerror(errno));
> +  // Since Linux kernel 2.6.12, 0-length mmaps fail:
> +  map=NULL; // map will remain NULL if the size is 0
> +  if (size>0) {
> +    if 
> ((map=(caddr_t)mmap((caddr_t)0,size,mapflags,MAP_SHARED,fd,0))==MAP_FAILED) {
> +      close(fd);
> +      throw qexception(__PRETTY_FUNCTION__,strerror(errno));
> +    }
>    }
>  
>  #ifdef QVERBOSE


-- 
Devin  \ aqua(at)devin.com, IRC:Requiem; http://www.devin.com
Carraway \ 1024D/E9ABFCD2: 13E7 199E DD1E 65F0 8905 2E43 5395 CA0D E9AB FCD2

Attachment: signature.asc
Description: Digital signature

Reply via email to