summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isofs/ChangeLog14
-rw-r--r--isofs/inode.c29
-rw-r--r--isofs/main.c2
-rw-r--r--isofs/pager.c5
-rw-r--r--isofs/rr.c5
5 files changed, 51 insertions, 4 deletions
diff --git a/isofs/ChangeLog b/isofs/ChangeLog
index c87053fc..35761f0f 100644
--- a/isofs/ChangeLog
+++ b/isofs/ChangeLog
@@ -1,3 +1,17 @@
+2000-12-21 Marcus Brinkmann <marcus@gnu.org>
+
+ * rr.c (rrip_work): Use strdup instead malloc and strcpy.
+ Assert that strdup and malloc (for rr->trans) succeeds.
+ * pager.c: Include <errno.h>.
+ (create_disk_pager): If malloc fails, exit with error.
+ * main.c (read_sblock): Fail if malloc does.
+ * inode.c (diskfs_cached_lookup): When allocating memory for dn or
+ np fails, release spinlock, rrip (and allocated memory) and return
+ ENOMEM.
+ (load_inode): Likewise (but no rrip). Also, if *npp is non-zero,
+ release diskfs_node_refcnt_lock before returning.
+ Reported by Igor Khavkine <i_khavki@alcor.concordia.ca>.
+
2000-11-27 Marcus Brinkmann <marcus@gnu.org>
The last two changes introduced two new inode overlaps
diff --git a/isofs/inode.c b/isofs/inode.c
index 2aa73a93..f3b04c7d 100644
--- a/isofs/inode.c
+++ b/isofs/inode.c
@@ -188,10 +188,23 @@ diskfs_cached_lookup (int id, struct node **npp)
assert (!(rr.valid & VALID_CL));
dn = malloc (sizeof (struct disknode));
+ if (!dn)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ release_rrip (&rr);
+ return ENOMEM;
+ }
dn->fileinfo = 0;
dn->dr = c->dr;
dn->file_start = c->file_start;
np = diskfs_make_node (dn);
+ if (!np)
+ {
+ free (dn);
+ spin_unlock (&diskfs_node_refcnt_lock);
+ release_rrip (&rr);
+ return ENOMEM;
+ }
np->cache_id = id + 1; /* see above for rationale for increment */
mutex_lock (&np->lock);
c->np = np;
@@ -327,15 +340,29 @@ load_inode (struct node **npp, struct dirrect *record,
inode_cache_find ((off_t) ((void *) record - (void *) disk_image), npp);
if (*npp)
- return 0;
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return 0;
+ }
/* Create a new node */
dn = malloc (sizeof (struct disknode));
+ if (!dn)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return ENOMEM;
+ }
dn->fileinfo = 0;
dn->dr = record;
dn->file_start = file_start;
np = diskfs_make_node (dn);
+ if (!np)
+ {
+ free (dn);
+ spin_unlock (&diskfs_node_refcnt_lock);
+ return ENOMEM;
+ }
mutex_lock (&np->lock);
diff --git a/isofs/main.c b/isofs/main.c
index beca281d..37f8a007 100644
--- a/isofs/main.c
+++ b/isofs/main.c
@@ -101,6 +101,8 @@ read_sblock ()
error (1, 0, "Could not find valid superblock");
sblock = malloc (sizeof (struct sblock));
+ if (!sblock)
+ error (1, errno, "Could not allocate memory for superblock");
bcopy (sb, sblock, sizeof (struct sblock));
diskfs_end_catch_exception ();
diff --git a/isofs/pager.c b/isofs/pager.c
index 7e12ebc0..5142cbc8 100644
--- a/isofs/pager.c
+++ b/isofs/pager.c
@@ -18,6 +18,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+#include <error.h>
#include <string.h>
#include "isofs.h"
@@ -130,7 +131,9 @@ void
create_disk_pager (void)
{
struct user_pager_info *upi = malloc (sizeof (struct user_pager_info));
-
+
+ if (!upi)
+ error (1, errno, "Could not create disk pager");
upi->type = DISK;
upi->np = 0;
pager_bucket = ports_create_bucket ();
diff --git a/isofs/rr.c b/isofs/rr.c
index b069a831..58e8fa98 100644
--- a/isofs/rr.c
+++ b/isofs/rr.c
@@ -301,8 +301,8 @@ rrip_work (struct dirrect *dr, struct rrip_lookup *rr,
rr->valid |= VALID_NM;
if (name != nmbuf)
{
- rr->name = malloc (namelen + 1);
- strcpy (rr->name, name);
+ rr->name = strdup (name);
+ assert (rr->name);
}
else
{
@@ -567,6 +567,7 @@ rrip_work (struct dirrect *dr, struct rrip_lookup *rr,
rr->translen = tr->len;
rr->trans = malloc (rr->translen);
+ assert (rr->trans);
memcpy (tr->data, rr->trans, rr->translen);
rr->valid |= VALID_TR;