mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
tdb: Fix CID 1034841 Resource leak
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org>
This commit is contained in:
parent
a8c1ad55b5
commit
1b8c07ac7d
@ -28,15 +28,17 @@ static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const ch
|
||||
static unsigned int hdr_rwlocks(const char *fname)
|
||||
{
|
||||
struct tdb_header hdr;
|
||||
ssize_t nread;
|
||||
|
||||
int fd = open(fname, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
|
||||
return -1;
|
||||
|
||||
nread = read(fd, &hdr, sizeof(hdr));
|
||||
close(fd);
|
||||
if (nread != sizeof(hdr)) {
|
||||
return -1;
|
||||
}
|
||||
return hdr.rwlocks;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user