mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
r9749@danube: weasel | 2006-09-14 06:53:12 +0200
Do not graciously increase the size to be mmaped if the current size already is at a page_size boundary. This is important since if a file has a size of zero and we mmap() it with length > 0, then accessing the mmaped memory area causes a bus error. However, if we pass a length of 0 to mmap() it will return with -1 and things work from there. svn:r8387
This commit is contained in:
parent
984e8f6efb
commit
28cac25d7e
@ -130,7 +130,7 @@ tor_mmap_file(const char *filename)
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
/* ensure page alignment */
|
||||
page_size = getpagesize();
|
||||
size += (page_size + (page_size-(size%page_size)));
|
||||
size += (size%page_size) ? page_size-(size%page_size) : 0;
|
||||
|
||||
string = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (string == MAP_FAILED) {
|
||||
|
Loading…
Reference in New Issue
Block a user