diff -ru hurd.orig/boot/ChangeLog hurd/boot/ChangeLog --- hurd.orig/boot/ChangeLog Wed Apr 25 13:36:47 2001 +++ hurd/boot/ChangeLog Tue Jul 31 00:46:18 2001 @@ -1,3 +1,11 @@ +2001-07-30 Igor Khavkine + + * ux.c (__mig_put_reply_port,mig_put_reply_port): Change + function interface to return error when malloc() returns + NULL. Since these functions are not used anywhere, and ux.c + is not included in the standard build at all, there are + no repercussions from the interface change. + 2001-02-25 Roland McGrath * Makefile (ourdevice.defs): Loosen up regexp since some whitespace in diff -ru hurd.orig/ext2fs/ChangeLog hurd/ext2fs/ChangeLog --- hurd.orig/ext2fs/ChangeLog Wed Jul 25 01:49:59 2001 +++ hurd/ext2fs/ChangeLog Tue Jul 31 01:03:20 2001 @@ -1,3 +1,8 @@ +2001-07-31 Igor Khavkine + + * dir.c: Added checks for validity of malloc'ed memory. + * pager.c: Same as above. + 2001-06-09 Mark Kettenis * inode.c (diskfs_set_statfs): If number of free blocks is less diff -ru hurd.orig/boot/ux.c hurd/boot/ux.c --- hurd.orig/boot/ux.c Sun Apr 28 23:54:24 1996 +++ hurd/boot/ux.c Tue Jul 31 00:43:47 2001 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ux.h" @@ -78,18 +79,23 @@ { return __mig_get_reply_port (); } -void __mig_put_reply_port (mach_port_t port) +error_t __mig_put_reply_port (mach_port_t port) { struct free_reply_port *frp = malloc (sizeof (struct free_reply_port)); + if (! frp) + return ENOMEM; + frp->port = port; spin_lock (&free_reply_ports_lock); frp->next = free_reply_ports; free_reply_ports = frp; spin_unlock (&free_reply_ports_lock); + + return 0; } -void mig_put_reply_port (mach_port_t port) +error_t mig_put_reply_port (mach_port_t port) { - __mig_put_reply_port (port); + return __mig_put_reply_port (port); } void __mig_dealloc_reply_port (mach_port_t port) { diff -ru hurd.orig/ext2fs/dir.c hurd/ext2fs/dir.c --- hurd.orig/ext2fs/dir.c Wed Apr 25 13:36:48 2001 +++ hurd/ext2fs/dir.c Tue Jul 31 00:57:34 2001 @@ -485,8 +485,13 @@ down how many entries there were. */ if (!dp->dn->dirents) { - dp->dn->dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ) + void *new_dirents; + new_dirents = malloc ((dp->dn_stat.st_size / DIRBLKSIZ) * sizeof (int)); + if (!new_dirents) + return ENOMEM; + else + dp->dn->dirents = new_dirents; for (i = 0; i < dp->dn_stat.st_size/DIRBLKSIZ; i++) dp->dn->dirents[i] = -1; } @@ -665,9 +670,14 @@ anything at all. */ if (dp->dn->dirents) { - dp->dn->dirents = realloc (dp->dn->dirents, + void *new_dirents; + new_dirents = realloc (dp->dn->dirents, (dp->dn_stat.st_size / DIRBLKSIZ * sizeof (int))); + if (!new_dirents) + return ENOMEM; + else + dp->dn->dirents = new_dirents; for (i = oldsize / DIRBLKSIZ; i < dp->dn_stat.st_size / DIRBLKSIZ; i++) @@ -884,6 +894,8 @@ if (!dp->dn->dirents) { dp->dn->dirents = malloc (nblks * sizeof (int)); + if (!dp->dn->dirents) + return ENOMEM; for (i = 0; i < nblks; i++) dp->dn->dirents[i] = -1; } diff -ru hurd.orig/ext2fs/pager.c hurd/ext2fs/pager.c --- hurd.orig/ext2fs/pager.c Wed Apr 25 13:36:48 2001 +++ hurd/ext2fs/pager.c Tue Jul 31 01:00:58 2001 @@ -812,6 +812,10 @@ { struct user_pager_info *upi = malloc (sizeof (struct user_pager_info)); + if (!upi) { + spin_unlock (&node_to_page_lock); + return MACH_PORT_NULL; + } upi->type = FILE_DATA; upi->node = node; upi->max_prot = 0;