diff options
Diffstat (limited to 'libnetfs/file-get-translator.c')
-rw-r--r-- | libnetfs/file-get-translator.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c index 44caa91c..3108acd7 100644 --- a/libnetfs/file-get-translator.c +++ b/libnetfs/file-get-translator.c @@ -73,14 +73,19 @@ netfs_S_file_get_translator (struct protid *user, : _HURD_BLKDEV), '\0', (np->nn_stat.st_rdev >> 8) & 0377, '\0', (np->nn_stat.st_rdev) & 0377); - buflen++; /* terminating nul */ - - if (buflen > *translen) - *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); - memcpy (*trans, buf, buflen); - free (buf); - *translen = buflen; - err = 0; + if (buflen < 0) + err = ENOMEM; + else + { + buflen++; /* terminating nul */ + + if (buflen > *translen) + *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); + memcpy (*trans, buf, buflen); + free (buf); + *translen = buflen; + err = 0; + } } else if (S_ISFIFO (np->nn_stat.st_mode)) { |