summaryrefslogtreecommitdiff
path: root/pfinet
diff options
context:
space:
mode:
authorOlaf Buddenhagen <antrik@users.sf.net>2010-07-18 02:33:40 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-01 19:14:50 +0200
commitf57d72dee53c79d5d527336bfbd9455c5262e963 (patch)
treeb5adff4329423ae7c5ae83cc0d45a52165b1abc1 /pfinet
parentc39ede0f06da0e49db48ff3a1641dc135c8ca18e (diff)
pfinet: check return value of mmap() in S_io_read() and S_socket_recv()
* pfinet/io-ops.c (S_io_read): Check return value. * pfinet/socket-ops.c (S_socket_recv): Likewise.
Diffstat (limited to 'pfinet')
-rw-r--r--pfinet/io-ops.c5
-rw-r--r--pfinet/socket-ops.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/pfinet/io-ops.c b/pfinet/io-ops.c
index bee1c19a..ef8d8513 100644
--- a/pfinet/io-ops.c
+++ b/pfinet/io-ops.c
@@ -87,6 +87,11 @@ S_io_read (struct sock_user *user,
if (amount > *datalen)
{
*data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ if (*data == MAP_FAILED)
+ /* Should check whether errno is indeed ENOMEM --
+ but this can't be done in a straightforward way,
+ because the glue headers #undef errno. */
+ return ENOMEM;
alloced = 1;
}
diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c
index baeaad30..b9ce6c72 100644
--- a/pfinet/socket-ops.c
+++ b/pfinet/socket-ops.c
@@ -499,6 +499,11 @@ S_socket_recv (struct sock_user *user,
if (amount > *datalen)
{
*data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ if (*data == MAP_FAILED)
+ /* Should check whether errno is indeed ENOMEM --
+ but this can't be done in a straightforward way,
+ because the glue headers #undef errno. */
+ return ENOMEM;
alloced = 1;
}