summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2001-09-09 17:32:03 +0000
committerMarcus Brinkmann <marcus@gnu.org>2001-09-09 17:32:03 +0000
commitc33495ca9cf1bb12ac5bc3263458fdf3331c1f89 (patch)
treef5575875f366c78f59c4d59f5ea24c80e77a5cc0
parentcd07eece45992a52e4c6c9ad1d7ae47b0f82fbe9 (diff)
2001-08-31 Marcus Brinkmann <marcus@gnu.org>
* file-get-translator.c (netfs_S_file_get_translator): If asprintf() fails, set ERR to errno. * dir-lookup.c (netfs_S_dir_lookup): Catch if asprintf() fails and return ENOMEM. If netfs_make_protid() fails, set ERROR to errno, not ENOMEM. Do this before freeing USER. * dir-mkfile.c (netfs_S_dir_mkfile): If netfs_make_protid() fails, set ERROR to errno and free USER. * file-exec.c (netfs_S_file_exec): Likewise. Reported by Igor Khavkine <i_khavki@alcor.concordia.ca>.
-rw-r--r--libnetfs/ChangeLog12
-rw-r--r--libnetfs/dir-lookup.c23
-rw-r--r--libnetfs/dir-mkfile.c14
-rw-r--r--libnetfs/file-exec.c29
-rw-r--r--libnetfs/file-get-translator.c21
5 files changed, 71 insertions, 28 deletions
diff --git a/libnetfs/ChangeLog b/libnetfs/ChangeLog
index 752eacee..c2b7c7a3 100644
--- a/libnetfs/ChangeLog
+++ b/libnetfs/ChangeLog
@@ -1,3 +1,15 @@
+2001-08-31 Marcus Brinkmann <marcus@gnu.org>
+
+ * file-get-translator.c (netfs_S_file_get_translator): If
+ asprintf() fails, set ERR to errno.
+ * dir-lookup.c (netfs_S_dir_lookup): Catch if asprintf() fails and
+ return ENOMEM. If netfs_make_protid() fails, set ERROR to errno,
+ not ENOMEM. Do this before freeing USER.
+ * dir-mkfile.c (netfs_S_dir_mkfile): If netfs_make_protid() fails,
+ set ERROR to errno and free USER.
+ * file-exec.c (netfs_S_file_exec): Likewise.
+ Reported by Igor Khavkine <i_khavki@alcor.concordia.ca>.
+
2001-06-21 Neal H Walfield <neal@cs.uml.edu>
* file-getcontrol.c (netfs_S_file_getcontrol): When checking if
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 6911f5ae..bf81a17b 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -209,17 +209,19 @@ netfs_S_dir_lookup (struct protid *diruser,
{
case S_IFCHR:
case S_IFBLK:
- asprintf (argz, "%s%c%d%c%d",
- (S_ISCHR (np->nn_stat.st_mode)
- ? _HURD_CHRDEV : _HURD_BLKDEV),
- 0, major (np->nn_stat.st_rdev),
- 0, minor (np->nn_stat.st_rdev));
+ if (asprintf (argz, "%s%c%d%c%d",
+ (S_ISCHR (np->nn_stat.st_mode)
+ ? _HURD_CHRDEV : _HURD_BLKDEV),
+ 0, major (np->nn_stat.st_rdev),
+ 0, minor (np->nn_stat.st_rdev)) < 0)
+ return ENOMEM;
*argz_len = strlen (*argz) + 1;
*argz_len += strlen (*argz + *argz_len) + 1;
*argz_len += strlen (*argz + *argz_len) + 1;
break;
case S_IFIFO:
- asprintf (argz, "%s", _HURD_FIFO);
+ if (asprintf (argz, "%s", _HURD_FIFO) < 0)
+ return ENOMEM;
*argz_len = strlen (*argz) + 1;
break;
default:
@@ -242,8 +244,8 @@ netfs_S_dir_lookup (struct protid *diruser,
user);
if (! newpi)
{
+ error = errno;
iohelp_free_iouser (user);
- error = ENOMEM;
}
}
@@ -381,6 +383,13 @@ netfs_S_dir_lookup (struct protid *diruser,
newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
user);
+ if (! newpi)
+ {
+ iohelp_free_iouser (user);
+ error = errno;
+ goto out;
+ }
+
*retry_port = ports_get_right (newpi);
ports_port_deref (newpi);
diff --git a/libnetfs/dir-mkfile.c b/libnetfs/dir-mkfile.c
index 16c5dd77..7d388737 100644
--- a/libnetfs/dir-mkfile.c
+++ b/libnetfs/dir-mkfile.c
@@ -44,9 +44,17 @@ netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode,
newpi = netfs_make_protid (netfs_make_peropen (np, flags,
diruser->po),
user);
- *newfile = ports_get_right (newpi);
- *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
- ports_port_deref (newpi);
+ if (newpi)
+ {
+ *newfile = ports_get_right (newpi);
+ *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ }
+ else
+ {
+ err = errno;
+ iohelp_free_iouser (user);
+ }
}
netfs_nput (np);
}
diff --git a/libnetfs/file-exec.c b/libnetfs/file-exec.c
index 4f9e5034..9839c694 100644
--- a/libnetfs/file-exec.c
+++ b/libnetfs/file-exec.c
@@ -130,16 +130,25 @@ netfs_S_file_exec (struct protid *cred,
{
newpi = netfs_make_protid (netfs_make_peropen (np, O_READ, cred->po),
user);
- right = ports_get_send_right (newpi);
- err = exec_exec (_netfs_exec,
- right, MACH_MSG_TYPE_COPY_SEND,
- task, flags, argv, argvlen, envp, envplen,
- fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
- portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
- intarray, intarraylen, deallocnames, deallocnameslen,
- destroynames, destroynameslen);
- mach_port_deallocate (mach_task_self (), right);
- ports_port_deref (newpi);
+ if (newpi)
+ {
+ right = ports_get_send_right (newpi);
+ err = exec_exec (_netfs_exec,
+ right, MACH_MSG_TYPE_COPY_SEND,
+ task, flags, argv, argvlen, envp, envplen,
+ fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
+ portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
+ intarray, intarraylen,
+ deallocnames, deallocnameslen,
+ destroynames, destroynameslen);
+ mach_port_deallocate (mach_task_self (), right);
+ ports_port_deref (newpi);
+ }
+ else
+ {
+ err = errno;
+ iohelp_free_iouser (user);
+ }
}
}
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))
{