[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 13/87: Fix buffer allocation on io_read
From: |
Samuel Thibault |
Subject: |
[hurd] 13/87: Fix buffer allocation on io_read |
Date: |
Sun, 09 Nov 2014 11:04:59 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 2e94e61f1c6263adfcbca641b74f9a07ea8298a0
Author: Samuel Thibault <address@hidden>
Date: Fri May 30 20:21:54 2014 +0200
Fix buffer allocation on io_read
* random.c (trivfs_S_io_read): Catch buffer allocation error, and
truncate allocation when we return less data than requested.
---
random.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/random.c b/random.c
index 0ae31f5..666a371 100644
--- a/random.c
+++ b/random.c
@@ -152,6 +152,7 @@ trivfs_S_io_read (struct trivfs_protid *cred,
if (amount > 0)
{
+ mach_msg_type_number_t new_amount;
while (readable_pool (amount, level) == 0)
{
if (cred->po->openmodes & O_NONBLOCK)
@@ -170,10 +171,22 @@ trivfs_S_io_read (struct trivfs_protid *cred,
/* Possibly allocate a new buffer. */
if (*data_len < amount)
- *data = mmap (0, amount, PROT_READ|PROT_WRITE,
- MAP_ANON, 0, 0);
-
- amount = read_pool ((byte *) *data, amount, level);
+ {
+ *data = mmap (0, amount, PROT_READ|PROT_WRITE,
+ MAP_ANON, 0, 0);
+ if (*data == MAP_FAILED)
+ {
+ pthread_mutex_unlock (&global_lock);
+ return errno;
+ }
+ }
+
+ new_amount = read_pool ((byte *) *data, amount, level);
+
+ if (new_amount < amount)
+ munmap (*data + round_page (new_amount),
+ round_page(amount) - round_page (new_amount));
+ amount = new_amount;
}
*data_len = amount;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 71/87: procfs: reorganize rootdir.c, (continued)
- [hurd] 71/87: procfs: reorganize rootdir.c, Samuel Thibault, 2014/11/09
- [hurd] 78/87: Fix proc_getprocinfo calls, Samuel Thibault, 2014/11/09
- [hurd] 80/87: Fix actual procinfo_t type, Samuel Thibault, 2014/11/09
- [hurd] 83/87: Use a mere weak attribute instead of a weak alias, Samuel Thibault, 2014/11/09
- [hurd] 17/87: include: use unsigned literal in combination with binary not, Samuel Thibault, 2014/11/09
- [hurd] 79/87: Fix proc_getprocinfo calls, Samuel Thibault, 2014/11/09
- [hurd] 20/87: libdiskfs: avoid implicit integer conversion, Samuel Thibault, 2014/11/09
- [hurd] 67/87: procfs: implement /proc/N/maps, Samuel Thibault, 2014/11/09
- [hurd] 69/87: procfs: do not test whether /hurd/mtab exists, Samuel Thibault, 2014/11/09
- [hurd] 16/87: libnetfs: fix memory leak, Samuel Thibault, 2014/11/09
- [hurd] 13/87: Fix buffer allocation on io_read,
Samuel Thibault <=
- [hurd] 77/87: pfinet: fix path in comment, Samuel Thibault, 2014/11/09
- [hurd] 76/87: libports: lock-less reference counting for port_info objects, Samuel Thibault, 2014/11/09
- [hurd] 81/87: Fix unlocking translator list, Samuel Thibault, 2014/11/09
- [hurd] 63/87: Update NEWS file, Samuel Thibault, 2014/11/09
- [hurd] 09/87: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/11/09
- [hurd] 85/87: mach-defpager: use protected payloads for object lookups, Samuel Thibault, 2014/11/09
- [hurd] 87/87: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2014/11/09
- [hurd] 12/87: build: Remove checks for 'getgrouplist' and 'uselocale'., Samuel Thibault, 2014/11/09
- [hurd] 10/87: libstore: provide function declaration until available upstream, Samuel Thibault, 2014/11/09
- [hurd] 01/87: Do not include the terminating zero in /proc/slabinfo, Samuel Thibault, 2014/11/09