summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-13 19:47:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:26 -0500
commitca9be7c92b33c9b5de46f7b85754ef5f3c46f47c (patch)
treef2162fe88220724217d491e90948633eb8a51a3a /source3
parentabafc0d88723d0fa86305375295fed9e7c896c96 (diff)
downloadsamba-ca9be7c92b33c9b5de46f7b85754ef5f3c46f47c.tar.gz
samba-ca9be7c92b33c9b5de46f7b85754ef5f3c46f47c.tar.bz2
samba-ca9be7c92b33c9b5de46f7b85754ef5f3c46f47c.zip
r14342: Fix coverity #68, resource leak on error path.
Jeremy. (This used to be commit 7520a8d2a10c72d330099c6502848afca60f56ff)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/sysquotas.c76
1 files changed, 54 insertions, 22 deletions
diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c
index c1ab6ef8cf..62714cf4d5 100644
--- a/source3/lib/sysquotas.c
+++ b/source3/lib/sysquotas.c
@@ -184,12 +184,12 @@ static struct {
static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp)
{
const char *get_quota_command;
+ char **lines = NULL;
get_quota_command = lp_get_quota_command();
if (get_quota_command && *get_quota_command) {
const char *p;
char *p2;
- char **lines;
pstring syscmd;
int _id = -1;
@@ -223,49 +223,79 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
dp->qflags = (enum SMB_QUOTA_TYPE)strtoul(line, &p2, 10);
p = p2;
- while (p && *p && isspace(*p))
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->curblocks = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->softlimit = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->hardlimit = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->curinodes = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->isoftlimit = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->ihardlimit = STR_TO_SMB_BIG_UINT(p, &p);
- else
+ } else {
goto invalid_param;
- while (p && *p && isspace(*p))
+ }
+
+ while (p && *p && isspace(*p)) {
p++;
- if (p && *p)
+ }
+
+ if (p && *p) {
dp->bsize = STR_TO_SMB_BIG_UINT(p, NULL);
- else
+ } else {
dp->bsize = 1024;
+ }
+
file_lines_free(lines);
+ lines = NULL;
+
DEBUG (3, ("Parsed output of get_quota, ...\n"));
#ifdef LARGE_SMB_OFF_T
@@ -298,6 +328,8 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
return -1;
invalid_param:
+
+ file_lines_free(lines);
DEBUG(0,("The output of get_quota_command is invalid!\n"));
return -1;
}