Thanks to Michael Halcrow for finding them.
*/
char *dotdot;
struct stat stb, pstb;
+ int rv;
dotdot = malloc(strlen(path)+4);
+ if (!dotdot)
+ return 0;
strcat(strcpy(dotdot, path), "/..");
if (lstat(path, &stb) != 0 ||
lstat(dotdot, &pstb) != 0)
- return 0;
-
- if (stb.st_dev != pstb.st_dev
- || stb.st_ino == pstb.st_ino)
- return 1;
- return 0;
+ rv = 0;
+ else
+ if (stb.st_dev != pstb.st_dev ||
+ stb.st_ino == pstb.st_ino)
+ rv = 1;
+ else
+ rv = 0;
+ free(dotdot);
+ return rv;
}
"nfsd.export",
NULL
};
- stb.st_mtime = time(0);
- if (!force)
- stat(_PATH_ETAB, &stb);
+ if (force ||
+ stat(_PATH_ETAB, &stb) != 0)
+ stb.st_mtime = time(0);
sprintf(stime, "%ld\n", stb.st_mtime);
for (c=0; cachelist[c]; c++) {
socklen_t len = sizeof (struct sockaddr_in);
char rpcdata [1024], servdata [1024];
struct rpcent rpcbuf, *rpcp;
- struct servent servbuf, *servp;
+ struct servent servbuf, *servp = NULL;
int sock, ret;
const char *proto = protocol == IPPROTO_TCP ? "tcp" : "udp";
def_const(defp);
break;
case TOK_EOF:
+ free(defp);
return (NULL);
default:
error("definition keyword expected");
declaration dec;
case_list *cases;
case_list **tailp;
- int flag;
defp->def_kind = DEF_UNION;
scan(TOK_IDENT, &tok);
cases->case_name = tok.str;
scan(TOK_COLON, &tok);
/* now peek at next token */
- flag=0;
if(peekscan(TOK_CASE,&tok))
{
}while(peekscan(TOK_CASE,&tok));
}
- else
- if(flag)
- {
-
- *tailp = cases;
- tailp = &cases->next;
- cases = ALLOC(case_list);
- };
get_declaration(&dec, DEF_UNION);
cases->case_decl = dec;
*p = 0;
if (*file == 0) {
*fname = NULL;
+ free(file);
} else {
*fname = file;
}
if (!node)
goto cleanup;
node->field = strdup (field);
- if (!node->field)
+ if (!node->field) {
+ free(node);
goto cleanup;
+ }
TAILQ_INSERT_TAIL (&list->fields, node, link);
}
free (liststr);
if (!node)
goto cleanup;
node->field = strdup (cb->tag);
- if (!node->field)
+ if (!node->field) {
+ free(node);
goto cleanup;
+ }
TAILQ_INSERT_TAIL (&list->fields, node, link);
}
return list;
return 0;
fail:
- if (node->section)
+ if (node && node->section)
free (node->section);
if (node)
free (node);
if (noclose == 0) {
tempfd = open("/dev/null", O_RDWR);
- dup2(tempfd, 0);
- dup2(tempfd, 1);
- dup2(tempfd, 2);
+ if (tempfd >= 0) {
+ dup2(tempfd, 0);
+ dup2(tempfd, 1);
+ dup2(tempfd, 2);
+ }
closeall(3);
}
free(qfpathname);
continue;
}
- free(qfpathname);
lseek(fd, (long) dqoff(id), L_SET);
switch (read(fd, &dq_dqb, sizeof(struct dqblk))) {
case 0:/* EOF */
break;
default: /* ERROR */
close(fd);
+ free(qfpathname);
continue;
}
close(fd);
dqb.dqb_btime = dq_dqb.dqb_btime;
dqb.dqb_itime = dq_dqb.dqb_itime;
}
+ free(qfpathname);
endmntent(fp);
if (err && (flags & ACTIVE)) {
NL_TIMES(new) = MAX_TRIES;
NL_STATE(new) = state;
if (!(NL_MY_NAME(new) = xstrdup(my_name))
- || !(NL_MON_NAME(new) = xstrdup(mon_name)))
+ || !(NL_MON_NAME(new) = xstrdup(mon_name))) {
+ if (NL_MY_NAME(new))
+ free(NL_MY_NAME(new));
+ free(new);
return NULL;
+ }
return new;
}