From d2e2f5c5440355c92f6c5515abaeb2e8c3bb0a45 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 12 Nov 2003 17:10:48 +0000 Subject: [PATCH] * cpio.c (cpio_create_entry): Fix possible buffer underflow and memory leak. --- vfs/ChangeLog | 5 +++++ vfs/cpio.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index cbc04451e..24e931367 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,8 @@ +2003-11-12 Andrew V. Samoilov + + * cpio.c (cpio_create_entry): Fix possible buffer underflow + and memory leak. + 2003-11-08 Pavel Roskin * gc.c: Make getid(), nothingisopen() and free() methods diff --git a/vfs/cpio.c b/vfs/cpio.c index b64ab229c..e1b447cc8 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -436,8 +436,8 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, } } - while (name[strlen (name) - 1] == PATH_SEP) - name[strlen (name) - 1] = 0; + for (tn = name + strlen (name) - 1; tn >= name && *tn == PATH_SEP; tn--) + *tn = 0; if ((tn = strrchr (name, PATH_SEP))) { *tn = 0; root = vfs_s_find_inode (me, super, name, LINK_FOLLOW, FL_MKDIR); @@ -491,6 +491,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, if (mc_read (super->u.arch.fd, inode->linkname, stat->st_size) < stat->st_size) { inode->linkname[0] = 0; + g_free (name); return STATUS_EOF; } inode->linkname[stat->st_size] = 0; /* Linkname stored without terminating \0 !!! */