pike.git / src / modules / Pipe / pipe.c

version» Context lines:

pike.git/src/modules/Pipe/pipe.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pipe.c,v 1.52 2002/10/21 17:06:22 marcus Exp $ + || $Id: pipe.c,v 1.53 2003/10/07 16:27:25 mast Exp $   */      #include "global.h"   #include "config.h"   #include "machine.h"   #include "module.h"      #include <sys/types.h>   #include <sys/stat.h>   
pike.git/src/modules/Pipe/pipe.c:31:   #endif   #endif   #endif      #ifdef HAVE_SYS_ID_H   #include <sys/id.h>   #endif /* HAVE_SYS_ID_H */      #include <fcntl.h>    - RCSID("$Id: pipe.c,v 1.52 2002/10/21 17:06:22 marcus Exp $"); + RCSID("$Id: pipe.c,v 1.53 2003/10/07 16:27:25 mast Exp $");      #include "threads.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_error.h"   #include "builtin_functions.h"
pike.git/src/modules/Pipe/pipe.c:719: Inside #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
   {    char *m;    struct stat s;       apply(obj, "query_fd", 0);    if(sp[-1].type == T_INT) fd=sp[-1].u.integer;    pop_stack();       if (fd != -1 && fstat(fd,&s)==0)    { -  int filep=fd_lseek(fd, 0L, SEEK_CUR); /* keep the file pointer */ +  off_t filep=fd_lseek(fd, 0L, SEEK_CUR); /* keep the file pointer */ +  size_t len = s.st_size - filep;    if(S_ISREG(s.st_mode) /* regular file */ -  && ((long)(m=(char *)mmap(0,s.st_size - filep,PROT_READ, +  && ((long)(m=(char *)mmap(0, len, PROT_READ,    MAP_FILE|MAP_SHARED,fd,filep))!=-1))    {   #ifdef HAVE_GETEUID    int ou = 0;   #endif -  mmapped += s.st_size; +  mmapped += len;       i->type=I_MMAP; -  i->len=s.st_size; +  i->len = len;    i->u.mmap=m;   #if defined(HAVE_MADVISE) && defined(MADV_SEQUENTIAL)    /* Mark the pages as sequential read only access... */       /* NOTE:    *    * Potential race-condition with other threads    */      #ifdef HAVE_GETEUID    if((ou=geteuid()) && !getuid()) {   #ifdef HAVE_SETEUID    seteuid(0);   #else /* ! HAVE_SETEUID */   #ifdef HAVE_SETRESUID    setresuid(-1, 0, -1);   #endif /* HAVE_SETRESUID */   #endif /* HAVE_SETEUID */    }   #endif -  madvise(m, s.st_size, MADV_SEQUENTIAL); +  madvise(m, len, MADV_SEQUENTIAL);   #ifdef HAVE_GETEUID    if(ou) {   #ifdef HAVE_SETEUID    seteuid(ou);   #else /* ! HAVE_SETEUID */   #ifdef HAVE_SETRESUID    setresuid(-1, ou, -1);   #endif /* HAVE_SETRESUID */   #endif /* HAVE_SETEUID */    }