ubi-utils: Fix file descriptor leaks in libubi
PATCH 1/1 ubi-utils: Fix file descriptor leaks in libubi
Signed-off-by Daniel van Gerpen <[email protected]>
--- ubi-utils/libubi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
ubi-utils/libubi.c +10 -0
@@ -419,6 +419,11 @@ static int vol_node2nums(struct libubi *lib, const char *node, int *dev_num, errno =ENODEV ;return -1 ; } + +if (close (fd)) { +sys_errmsg ("close failed on \"%s\"" , file); +return -1 ; + } *dev_num = i; *vol_id = minor -1 ;
@@ -910,6 +915,11 @@ int ubi_probe_node(libubi_t desc, const char *node) fd =open (file,O_RDONLY );if (fd ==-1 ) goto out_not_ubi; + +if (close (fd)) { +sys_errmsg ("close failed on \"%s\"" , file); +return -1 ; + }return 2 ;
Signature · 1 line
1.8.3.2
Quoted 1 line · Daniel van Gerpen
Signed-off-by Daniel van Gerpen <[email protected]>
Tweaked a bit and pushed to mtd-utils, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy