login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
openbsd-tech
»
2010
»
August
»
25
Re: ufs_open: don't leak f_buf
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [author]
[view in full thread]
From: Martynas Venckus
Subject:
Re: ufs_open: don't leak f_buf
Date: Wednesday, August 25, 2010 - 1:40 pm
On 8/24/10, Miod Vallat <miod@online.fr> wrote:
quoted text
>> the little operating system we wrote eventually panic'd (overflowed >> heap); standalone ufs.c implementation we've used leaks f_buf >> everytime ufs_open fails > > This is correct, but you may be leaking fp->f_blk[] as well. What about > this instead?
yup i think it's better ok and thx
quoted text
> Index: ufs.c > =================================================================== > RCS file: /cvs/src/sys/lib/libsa/ufs.c,v > retrieving revision 1.19 > diff -u -p -r1.19 ufs.c > --- ufs.c 6 Jan 2008 11:17:18 -0000 1.19 > +++ ufs.c 23 Aug 2010 22:03:12 -0000 > @@ -98,6 +98,7 @@ static int read_inode(ino_t, struct open > static int block_map(struct open_file *, daddr_t, daddr_t *); > static int buf_read_file(struct open_file *, char **, size_t *); > static int search_directory(char *, struct open_file *, ino_t *); > +static int ufs_close_internal(struct file *); > #ifdef COMPAT_UFS > static void ffs_oldfscompat(struct fs *); > #endif > @@ -526,10 +527,9 @@ ufs_open(char *path, struct open_file *f > out: > if (buf) > free(buf, fs->fs_bsize); > - if (rc) { > - free(fp->f_fs, SBSIZE); > - free(fp, sizeof(struct file)); > - } > + if (rc) > + (void)ufs_close_internal(fp); > + > return (rc); > } > > @@ -537,11 +537,18 @@ int > ufs_close(struct open_file *f) > { > struct file *fp = (struct file *)f->f_fsdata; > - int level; > > f->f_fsdata = (void *)0; > if (fp == (struct file *)0) > return (0); > + > + return (ufs_close_internal(fp)); > +} > + > +static void > +ufs_close_internal(struct file *fp) > +{ > + int level; > > for (level = 0; level < NIADDR; level++) { > if (fp->f_blk[level])
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [author]
Messages in current thread:
ufs_open: don't leak f_buf
, Martynas Venckus
, (Sat Aug 21, 11:33 am)
Re: ufs_open: don't leak f_buf
, Miod Vallat
, (Mon Aug 23, 3:03 pm)
Re: ufs_open: don't leak f_buf
, Martynas Venckus
, (Wed Aug 25, 1:40 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg KH
Og dreams of kernels
Jens Axboe
[PATCH 31/33] Fusion: sg chaining support
Arnd Bergmann
Re: finding your own dead "CONFIG_" variables
Mark Brown
[PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset
Tony Breeds
[LGUEST] Look in object dir for .config
git
:
Brian Downing
Re: Git in a Nutshell guide
John Benes
Re: master has some toys
Matthias Lederhofer
[PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree
Alexander Sulfrian
[RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set
Junio C Hamano
Re: Rss produced by git is not valid xml?
git-commits-head
:
Linux Kernel Mailing List
iSeries: fix section mismatch in iseries_veth
Linux Kernel Mailing List
ixbge: remove TX lock and redo TX accounting.
Linux Kernel Mailing List
ixgbe: fix several counter register errata
Linux Kernel Mailing List
b43: fix build with CONFIG_SSB_PCIHOST=n
Linux Kernel Mailing List
9p: block-based virtio client
linux-netdev
:
Michael Breuer
Re: [PATCH] af_packet: Don't use skb after dev_queue_xmit()
Michael Breuer