Check return code of mmap (bug reported by Nick Bane)
authorDavid F. Skoll <dfs@roaringpenguin.com>
Mon, 24 Jun 2002 12:42:24 +0000 (12:42 +0000)
committerDavid F. Skoll <dfs@roaringpenguin.com>
Mon, 24 Jun 2002 12:42:24 +0000 (12:42 +0000)
pppd/tdb.c

index 7fd58291ec363c0f6eddda56b4d478d9bb0b788e..c6498d651418545e33c4fa0509e203c62e80ddfc 100644 (file)
@@ -210,6 +210,9 @@ static int tdb_oob(TDB_CONTEXT *tdb, tdb_off offset)
        tdb->map_ptr = (void *)mmap(NULL, tdb->map_size, 
                                    tdb->read_only?PROT_READ:PROT_READ|PROT_WRITE,
                                    MAP_SHARED | MAP_FILE, tdb->fd, 0);
+       if (tdb->map_ptr == MAP_FAILED) {
+           tdb->map_ptr = NULL;
+       }
 #endif 
        return 0;
 }
@@ -373,6 +376,9 @@ static int tdb_expand(TDB_CONTEXT *tdb, tdb_off length)
             tdb->map_ptr = (void *)mmap(NULL, tdb->map_size, 
                                         PROT_READ|PROT_WRITE,
                                         MAP_SHARED | MAP_FILE, tdb->fd, 0);
+           if (tdb->map_ptr == MAP_FAILED) {
+               tdb->map_ptr = NULL;
+           }
         }
 #endif
 
@@ -1180,6 +1186,9 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags,
             tdb.map_ptr = (void *)mmap(NULL, st.st_size, 
                                        tdb.read_only? PROT_READ : PROT_READ|PROT_WRITE,
                                        MAP_SHARED | MAP_FILE, tdb.fd, 0);
+           if (tdb.map_ptr == MAP_FAILED) {
+               tdb.map_ptr = NULL;
+           }
         }
 #endif