From: <da...@us...> - 2003-06-29 16:40:58
|
Update of /cvsroot/cerber/cerb-ng/kcerb In directory sc8-pr-cvs1:/tmp/cvs-serv22128 Modified Files: cerb_action.c cerb_addons.c cerb_ask.c cerb_fdesc.c cerb_malloc.c cerb_malloc.h cerb_math.c cerb_rules.c cerb_string.c cerb_thread.c cerb_trace.c cerb_tree.c cerb_urules.c cerb_usersysctl.c Log Message: - There is no need to put comment for fcb_malloc() function, allocation will be remembered with file and line number. - Default flags for CTLTYPE_NODE are CTLFLAG_RW. - Removed memory leak when flags for sysctls are bad. Index: cerb_action.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_action.c,v retrieving revision 1.118 retrieving revision 1.119 diff -u -d -r1.118 -r1.119 --- cerb_action.c 29 Jun 2003 14:42:59 -0000 1.118 +++ cerb_action.c 29 Jun 2003 16:40:53 -0000 1.119 @@ -409,8 +409,7 @@ if (nargs <= 0) args = NULL; else { - args = fcb_malloc("syscall arguments", - sizeof(register_t) * nargs); + args = fcb_malloc(sizeof(register_t) * nargs); for (i = 0; i < nargs; ++i) { fcb_argreg_set(th, &tmpv, v[i + 1], CB_USR_ZONE); args[i] = tmpv.v_register; @@ -541,7 +540,7 @@ return; } - retv->v_str = fcb_malloc(__func__, MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); sflag = v[0]->v_id == ECB_ARG_I ? UIO_USERSPACE : UIO_SYSSPACE; th->thd_errno = fcb_realpath(v[0]->v_str, th->thd_proc, retv->v_str, MAXPATHLEN, FOLLOW, sflag); @@ -777,7 +776,7 @@ th->thd_errno = EFAULT; goto failed; } - retv->v_str = fcb_malloc("setpname", sizeof(proc->p_comm)); + retv->v_str = fcb_malloc(sizeof(proc->p_comm)); fcb_mtemp_add(th, retv->v_str); strlcpy(retv->v_str, proc->p_comm, sizeof(proc->p_comm)); retv->v_size = strlen(retv->v_str) + 1; @@ -841,7 +840,7 @@ goto failed; } /* Get old file name. */ - retv->v_str = fcb_malloc("SETPFILE", MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(proc->p_textvp, proc, retv->v_str, MAXPATHLEN); if (error != 0) { @@ -928,7 +927,7 @@ th->thd_errno = EINVAL; goto failed; } - retv->v_str = fcb_malloc("setplogin", size); + retv->v_str = fcb_malloc(size); fcb_mtemp_add(th, retv->v_str); strlcpy(retv->v_str, proc->p_session->s_login, size); retv->v_size = strlen(retv->v_str) + 1; @@ -1080,7 +1079,7 @@ retv->v_uval = proc->p_session->s_sid; return; case CB_GETPFILE_O: - retv->v_str = fcb_malloc("GETPFILE", MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(proc->p_textvp, proc, retv->v_str, MAXPATHLEN); if (error != 0) { @@ -1233,7 +1232,7 @@ if (pr == NULL) goto failed; - retv->v_str = fcb_malloc("GETJAILDIR", MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(proc->p_fd->fd_jdir, proc, retv->v_str, MAXPATHLEN); if (error != 0) { @@ -1572,7 +1571,7 @@ th->thd_errno = error; goto failed; } - old = fcb_malloc(__func__, oldlen + 1); + old = fcb_malloc(oldlen + 1); /* kernel_sysctl() don't terminate string */ ((char *)old)[oldlen] = '\0'; @@ -1639,7 +1638,7 @@ retv->v_id = ECB_CONST_I; retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc(__func__, CB_MAXSYSCTLNAME_G); + retv->v_str = fcb_malloc(CB_MAXSYSCTLNAME_G); error = fcb_sysctlname(v[0]->v_uvalp, v[0]->v_size, retv->v_str, CB_MAXSYSCTLNAME_G); if (error != 0) { @@ -1973,7 +1972,7 @@ return; } - retv->v_ptr = fcb_malloc(__func__, elemsize * n); + retv->v_ptr = fcb_malloc(elemsize * n); fcb_mtemp_add(th, retv->v_ptr); retv->v_size = n; @@ -1999,7 +1998,7 @@ for (i = 0; i < n - 1; ++i) { MCB_ASSERT(strp[i] != NULL, "strp[%u] == NULL", i); strsize = strlen(strp[i]) + 1; - retv->v_strp[i] = fcb_malloc(__func__, strsize); + retv->v_strp[i] = fcb_malloc(strsize); fcb_mtemp_add(th, retv->v_strp[i]); strlcpy(retv->v_strp[i], strp[i], strsize); } @@ -2184,11 +2183,10 @@ if (after == val->v_size - 1) --after; - strp = retv->v_strp = fcb_malloc(__func__, - sizeof(char *) * retv->v_size); + strp = retv->v_strp = fcb_malloc(sizeof(char *) * retv->v_size); fcb_mtemp_add(th, strp); strsize = v[1]->v_size; - strp[after + 1] = fcb_malloc(__func__, strsize); + strp[after + 1] = fcb_malloc(strsize); fcb_mtemp_add(th, strp[after + 1]); strlcpy(strp[after + 1], v[1]->v_str, strsize); i = (after < 0) ? 1 : 0; @@ -2196,7 +2194,7 @@ MCB_ASSERT(val->v_strp[j] != NULL, "val->v_strp[%u] == NULL", j); strsize = strlen(val->v_strp[j]) + 1; - strp[i] = fcb_malloc(__func__, strsize); + strp[i] = fcb_malloc(strsize); fcb_mtemp_add(th, strp[i]); strlcpy(strp[i], val->v_strp[j], strsize); if (i == after) @@ -2208,7 +2206,7 @@ if (val->v_type == CB_DEFPTR_T || val->v_type == CB_UDEFPTR_T) #endif { - retv->v_valp = fcb_malloc(__func__, sizeof(int) * retv->v_size); + retv->v_valp = fcb_malloc(sizeof(int) * retv->v_size); fcb_mtemp_add(th, retv->v_valp); retv->v_valp[after + 1] = v[1]->v_val; i = (after < 0) ? 1 : 0; @@ -2287,8 +2285,7 @@ /* Can't remove terminating NULL from strings table. */ if (elem == val->v_size - 1) goto fail; - strp = retv->v_strp = fcb_malloc(__func__, - sizeof(char *) * retv->v_size); + strp = retv->v_strp = fcb_malloc(sizeof(char *) * retv->v_size); fcb_mtemp_add(th, strp); for (i = j = 0; j < val->v_size - 1; ++i, ++j) { MCB_ASSERT(val->v_strp[j] != NULL, @@ -2298,7 +2295,7 @@ continue; } strsize = strlen(val->v_strp[j]) + 1; - strp[i] = fcb_malloc(__func__, strsize); + strp[i] = fcb_malloc(strsize); fcb_mtemp_add(th, strp[i]); strlcpy(strp[i], val->v_strp[j], strsize); } @@ -2308,7 +2305,7 @@ if (val->v_type == CB_DEFPTR_T || val->v_type == CB_UDEFPTR_T) #endif { - retv->v_valp = fcb_malloc(__func__, sizeof(int) * retv->v_size); + retv->v_valp = fcb_malloc(sizeof(int) * retv->v_size); fcb_mtemp_add(th, retv->v_valp); for (i = j = 0; j < val->v_size; ++i, ++j) { if (j == elem) @@ -2349,7 +2346,7 @@ retv->v_size = 0; return; } - buf = fcb_malloc(__func__, CB_GENSTRSIZE_G); + buf = fcb_malloc(CB_GENSTRSIZE_G); fcb_mtemp_add(th, buf); fcb_vprintf(th, buf, CB_GENSTRSIZE_G, v[0]->v_str, v + 1, nvals - 1); retv->v_str = buf; @@ -2384,7 +2381,7 @@ retv->v_size = 0; return; } - buf = fcb_malloc(__func__, CB_LOGBUFSIZE_G); + buf = fcb_malloc(CB_LOGBUFSIZE_G); fcb_mtemp_add(th, buf); fcb_vprintf(th, buf, CB_LOGBUFSIZE_G, v[1]->v_str, v + 2, nvals - 2); log(v[0]->v_val, "%s\n", buf); @@ -2738,7 +2735,7 @@ retv->v_str = NULL; return; } - out = fcb_malloc(__func__, retv->v_size); + out = fcb_malloc(retv->v_size); fcb_mtemp_add(th, out); retv->v_str = out; s = v[0]->v_str; @@ -2774,7 +2771,7 @@ retv->v_ptr = NULL; return; } - out = fcb_malloc(__func__, sizeof(int) * retv->v_size); + out = fcb_malloc(sizeof(int) * retv->v_size); fcb_mtemp_add(th, out); retv->v_valp = out; t = v[0]->v_valp; @@ -2807,7 +2804,7 @@ retv->v_strp = NULL; return; } - out = fcb_malloc(__func__, sizeof(char *) * retv->v_size); + out = fcb_malloc(sizeof(char *) * retv->v_size); fcb_mtemp_add(th, out); retv->v_strp = out; if (retv->v_size == 1) { @@ -2829,7 +2826,7 @@ if (*p == NULL) *out = NULL; else { - *out = fcb_malloc(__func__, strlen(*p) + 1); + *out = fcb_malloc(strlen(*p) + 1); fcb_mtemp_add(th, *out); strcpy(*out, *p); } @@ -2958,7 +2955,7 @@ retv->v_id = ECB_CONST_I; retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc(__func__, size); + retv->v_str = fcb_malloc(size); if (fun == CB_BASENAME_O) { error = basename(v[0]->v_str, retv->v_str, size); } else @@ -3004,6 +3001,7 @@ } if (nvals == 1) { type = CTLTYPE_NODE; + flags = CTLFLAG_RW; valp = NULL; } else if (nvals == 2 || nvals == 3) { valp = &val; Index: cerb_addons.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_addons.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- cerb_addons.c 26 Jun 2003 22:34:42 -0000 1.31 +++ cerb_addons.c 29 Jun 2003 16:40:53 -0000 1.32 @@ -116,7 +116,7 @@ /* 'error' is already 0. */ goto errend3; } - bufpath = fcb_malloc("fcb_realpath: bufpath", len + 2); + bufpath = fcb_malloc(len + 2); strlcpy(bufpath, path, len + 2); len = bp - path; /* path+len = start of last component */ bp = bufpath + len; @@ -205,7 +205,7 @@ rdir = p->p_fd->fd_rdir; bufsiz = (bufsiz < MAXPATHLEN) ? bufsiz : MAXPATHLEN; - buf = fcb_malloc("fcb_realpathvn: buf", bufsiz); + buf = fcb_malloc(bufsiz); bp = buf + bufsiz - 1; *bp = '\0'; slash_prefixed = 0; @@ -314,7 +314,7 @@ register char *s; register u_int i; - s = fcb_malloc(__func__, CB_MAXIPV4CHARS_G); + s = fcb_malloc(CB_MAXIPV4CHARS_G); *s = '\0'; for (i = 0; i < 24; i += 8) { @@ -334,7 +334,7 @@ register char *s; register u_int i; - s = fcb_malloc(__func__, CB_MAXIPV6CHARS_G); + s = fcb_malloc(CB_MAXIPV6CHARS_G); *s = '\0'; for (i = 0; i < 15; ++i) { @@ -397,12 +397,12 @@ if (zone == CB_SYS_ZONE) { char **tmpstrp; - tmpstrp = lv->v_strp = fcb_malloc(__func__, size); + tmpstrp = lv->v_strp = fcb_malloc(size); for (i = 0; i < rv->v_size - 1; ++i) { MCB_ASSERT(strp[i] != NULL, "strp[%u] == NULL", i); locsize = strlen(strp[i]) + 1; - tmpstrp[i] = fcb_malloc(__func__, locsize); + tmpstrp[i] = fcb_malloc(locsize); bcopy(strp[i], tmpstrp[i], locsize); } tmpstrp[i] = NULL; @@ -478,7 +478,7 @@ } if (zone == CB_SYS_ZONE) { - lv->v_ptr = fcb_malloc(__func__, size); + lv->v_ptr = fcb_malloc(size); bcopy(rv->v_ptr, lv->v_ptr, size); } else #ifdef CB_INVARIANTS Index: cerb_ask.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_ask.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- cerb_ask.c 18 Jun 2003 17:34:55 -0000 1.4 +++ cerb_ask.c 29 Jun 2003 16:40:53 -0000 1.5 @@ -94,7 +94,7 @@ return (v[0]->v_ret); } - buf = fcb_malloc(__func__, CB_LOGBUFSIZE_G); + buf = fcb_malloc(CB_LOGBUFSIZE_G); id = fcb_ask_getid(); th->thd_suspendid = id; MCB_ASK_LOCK(); Index: cerb_fdesc.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_fdesc.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- cerb_fdesc.c 22 Jun 2003 12:09:09 -0000 1.13 +++ cerb_fdesc.c 29 Jun 2003 16:40:53 -0000 1.14 @@ -121,7 +121,7 @@ fdl = fd; } - fd = fcb_malloc("desc 1", sizeof(struct scb_fdesc)); + fd = fcb_malloc(sizeof(struct scb_fdesc)); fd->fd_fp = fp; fd->fd_name = fcb_fdesc_resolve(p, name, segflag); if (fd->fd_name == NULL) { @@ -341,7 +341,7 @@ last = act; } - act = fcb_malloc("fdesc:fdclose__get", sizeof(struct scb_fdclose)); + act = fcb_malloc(sizeof(struct scb_fdclose)); act->fdc_id = id; act->fdc_close = close; act->fdc_addr = addr; @@ -426,7 +426,7 @@ VOP_UNLOCK(ndp->ni_vp, 0, p); NDFREE(ndp, NDF_ONLY_PNBUF); vrele(ndp->ni_vp); - rname = fcb_malloc("rname", MAXPATHLEN); + rname = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(vp, p, rname, MAXPATHLEN); if (error != 0) { MCB_FREE(rname); Index: cerb_malloc.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_malloc.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- cerb_malloc.c 23 Jun 2003 15:11:34 -0000 1.26 +++ cerb_malloc.c 29 Jun 2003 16:40:53 -0000 1.27 @@ -65,8 +65,8 @@ while (tmp1 != NULL) { tmp2 = LIST_NEXT(tmp1, m_next); printf("fcb_malloc: !!MEMORY LEAK!! Clearing: address=%p, " - "size=%5lu, comment=%s\n", tmp1->m_addr, - (u_long)tmp1->m_size, tmp1->m_desc); + "size=%5lu [%s:%u]\n", tmp1->m_addr, + (u_long)tmp1->m_size, tmp1->m_file, tmp1->m_line); free(tmp1->m_addr, M_CERB); free(tmp1, M_CERB); tmp1 = tmp2; @@ -112,8 +112,8 @@ MCB_MALLOC_LOCK(); i = 0; LIST_FOREACH(tmp, &vcb_malloc_head, m_next) { - uprintf("Rule %3d: address=%p, size=%5lu, comment=%s\n", ++i, - tmp->m_addr, (u_long)tmp->m_size, tmp->m_desc); + uprintf("Rule %3d: address=%p, size=%5lu [%s:%u]\n", ++i, + tmp->m_addr, (u_long)tmp->m_size, tmp->m_file, tmp->m_line); } MCB_MALLOC_UNLOCK(); @@ -121,7 +121,7 @@ } void * -fcb_realloc(char *desc, void *addr, u_long size) +_fcb_realloc(void *addr, u_long size, const char *file, u_int line) { register struct scb_malloc *tmp; void *newptr; @@ -129,6 +129,7 @@ MCB_ASSERT(size > 0, "size == 0?"); newptr = realloc(addr, size, M_CERB, M_WAITOK); + MCB_ASSERT(newptr != NULL, "realloc() returned NULL?"); if (!ccb_mem_safe_malloc) return (newptr); @@ -140,7 +141,8 @@ MCB_ASSERT(tmp != NULL, "malloc() returned NULL?"); tmp->m_addr = newptr; tmp->m_size = size; - tmp->m_desc = desc; + tmp->m_file = file; + tmp->m_line = line; MCB_MALLOC_LOCK(); LIST_INSERT_HEAD(&vcb_malloc_head, tmp, m_next); @@ -155,7 +157,8 @@ 0xd0, size - tmp->m_size); } tmp->m_size = size; - tmp->m_desc = desc; + tmp->m_file = file; + tmp->m_line = line; break; } } @@ -216,7 +219,7 @@ { struct scb_mtemp *tmp; - tmp = fcb_malloc("fcb_mtemp_add()", sizeof(struct scb_mtemp)); + tmp = fcb_malloc(sizeof(struct scb_mtemp)); tmp->mt_addr = addr; LIST_INSERT_HEAD(&th->thd_mtemp_head, tmp, mt_next); Index: cerb_malloc.h =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_malloc.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- cerb_malloc.h 2 May 2003 09:40:16 -0000 1.22 +++ cerb_malloc.h 29 Jun 2003 16:40:53 -0000 1.23 @@ -35,9 +35,10 @@ struct scb_malloc { - char *m_desc; /* comment */ - void *m_addr; /* address of allocated memory */ - size_t m_size; /* size of allocated memory */ + void *m_addr; /* address of allocated memory */ + size_t m_size; /* size of allocated memory */ + const char *m_file; /* where malloc() was called: file name */ + u_int m_line; /* where malloc() was called: line in file */ LIST_ENTRY(scb_malloc) m_next; }; @@ -46,12 +47,13 @@ void fcb_malloc_clearlist(void); void fcb_malloc_show(void); -#define fcb_malloc(desc, size) fcb_realloc((desc), NULL, (size)) -void *fcb_realloc(char *desc, void *addr, u_long size); +#define fcb_malloc(size) _fcb_realloc(NULL, (size), __FILE__, __LINE__) +#define fcb_realloc(addr, size) _fcb_realloc((addr), (size), __FILE__, __LINE__) +void *_fcb_realloc(void *addr, u_long size, const char *file, u_int line); void fcb_free(register void *addr); #else /* !CERB_SAFEMALLOC */ -#define fcb_malloc(desc, size) malloc((size), M_CERB, M_WAITOK) -#define fcb_realloc(desc, addr, size) realloc((addr), (size), M_CERB, M_WAITOK) +#define fcb_malloc(size) malloc((size), M_CERB, M_WAITOK) +#define fcb_realloc(addr, size) realloc((addr), (size), M_CERB, M_WAITOK) #define fcb_free(addr) free((addr), M_CERB) #define MCB_FREE(addr) do { \ free((addr), M_CERB); \ Index: cerb_math.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_math.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- cerb_math.c 26 Jun 2003 22:34:42 -0000 1.6 +++ cerb_math.c 29 Jun 2003 16:40:53 -0000 1.7 @@ -113,7 +113,7 @@ } size++; - str = fcb_malloc(__func__, size); + str = fcb_malloc(size); fcb_mtemp_add(th, str); *str = 0; for (i = 0; i < nvals; ++i) { @@ -157,15 +157,15 @@ goto end; } - strp = fcb_malloc(__func__, sizeof(char *) * size); + strp = fcb_malloc(sizeof(char *) * size); fcb_mtemp_add(th, strp); for (i = j = 0; i < nvals; ++i) { if (v[i]->v_type == CB_STR_T) { if (v[i]->v_size == 0) strp[j] = NULL; else { - strp[j] = fcb_malloc(__func__, - sizeof(char) * v[i]->v_size); + strp[j] = fcb_malloc(sizeof(char) * + v[i]->v_size); fcb_mtemp_add(th, strp[j]); strcpy(strp[j], v[i]->v_str); } @@ -183,8 +183,8 @@ strp[j] = NULL; else { strsize = strlen(v[i]->v_strp[k]) + 1; - strp[j] = fcb_malloc(__func__, - sizeof(char) * strsize); + strp[j] = fcb_malloc(sizeof(char) * + strsize); fcb_mtemp_add(th, strp[j]); strcpy(strp[j], v[i]->v_strp[k]); } @@ -264,7 +264,7 @@ goto end; } - valp = fcb_malloc(__func__, sizeof(int) * size); + valp = fcb_malloc(sizeof(int) * size); fcb_mtemp_add(th, valp); for (i = j = 0; i < nvals; ++i) { if (MCB_ISVAL(v[i]->v_type)) { Index: cerb_rules.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_rules.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- cerb_rules.c 29 Jun 2003 14:42:59 -0000 1.66 +++ cerb_rules.c 29 Jun 2003 16:40:53 -0000 1.67 @@ -222,8 +222,7 @@ return; case ECB_CDIR_L: retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc("fcb_getval: current directory.", - MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(p->p_fd->fd_cdir, p, retv->v_str, MAXPATHLEN); th->thd_errno = error; @@ -240,8 +239,7 @@ return; case ECB_RDIR_L: retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc("fcb_getval: root directory.", - MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(p->p_fd->fd_rdir, p, retv->v_str, MAXPATHLEN); th->thd_errno = error; @@ -258,8 +256,7 @@ return; case ECB_JDIR_L: retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc("fcb_getval: jail root directory.", - MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(p->p_fd->fd_jdir, p, retv->v_str, MAXPATHLEN); th->thd_errno = error; @@ -284,8 +281,7 @@ return; case ECB_FNAME_L: retv->v_type = CB_STR_T; - retv->v_str = fcb_malloc("fcb_getval: process executable.", - MAXPATHLEN); + retv->v_str = fcb_malloc(MAXPATHLEN); error = fcb_realpathvn(p->p_textvp, p, retv->v_str, MAXPATHLEN); th->thd_errno = error; @@ -369,8 +365,7 @@ } else { MCB_ASSERT(rule->r_nargs > 0, "r_args != NULL, but r_nargs == " "%u.", rule->r_nargs); - vals = fcb_malloc("vals in fcb_rule_exec()", - sizeof(struct scb_val *) * rule->r_nargs); + vals = fcb_malloc(sizeof(struct scb_val *) * rule->r_nargs); MCB_ASSERT(vals != NULL, "vals == NULL"); fcb_mtemp_add(th, vals); larg = rule->r_nargs - 1; @@ -446,8 +441,7 @@ arg->v_id == ECB_FUN_I || arg->v_id == ECB_ARG_I, "Invalid argument's %u ID: %u.", i, arg->v_id); - vals[i] = fcb_malloc("Temporary allocated value.", - sizeof(struct scb_val)); + vals[i] = fcb_malloc(sizeof(struct scb_val)); fcb_mtemp_add(th, vals[i]); if (arg->v_id == ECB_LOCAL_I || arg->v_id == ECB_ARG_I) { Index: cerb_string.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_string.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- cerb_string.c 26 Jun 2003 22:34:42 -0000 1.30 +++ cerb_string.c 29 Jun 2003 16:40:53 -0000 1.31 @@ -709,17 +709,17 @@ nargs = MCB_NARGS(th->thd_syscall); - vals = fcb_malloc(__func__, sizeof(struct scb_val *) * nargs); + vals = fcb_malloc(sizeof(struct scb_val *) * nargs); /* * ", %T(...), %T(...), %T, %T, %T" (could be 9 bytes on every argument * and 1 for terminating '\0'). */ fmtsiz = 9 * nargs + 1; - fmt = fcb_malloc("format string", fmtsiz); + fmt = fcb_malloc(fmtsiz); *fmt = '\0'; for (i = 0; i < nargs; ++i) { type = tcb_argtype[th->thd_syscall][i]; - vals[i] = fcb_malloc(__func__, sizeof(struct scb_val)); + vals[i] = fcb_malloc(sizeof(struct scb_val)); vals[i]->v_id = ECB_CONST_I; vals[i]->v_type = type; switch (type) { @@ -800,8 +800,7 @@ j < CB_ELEMLIMIT_SCA; ++j) ; vals[i]->v_size = j; - vals[i]->v_strp = fcb_malloc("strings table", - sizeof(char *) * j); + vals[i]->v_strp = fcb_malloc(sizeof(char *) * j); for (j = 0; sca_strp[j] != NULL && j < CB_ELEMLIMIT_SCA; ++j) { if (!MCB_VALIDADDR(sca_strp[j])) Index: cerb_thread.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_thread.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- cerb_thread.c 23 Jun 2003 15:11:34 -0000 1.24 +++ cerb_thread.c 29 Jun 2003 16:40:53 -0000 1.25 @@ -58,7 +58,7 @@ /* * No free slot found, so we have to allocate one. */ - tmp = fcb_malloc("Memory for thread", sizeof(struct scb_thdata)); + tmp = fcb_malloc(sizeof(struct scb_thdata)); for (i = 0; i < CB_NREGS_G; ++i) { tmp->thd_regs[i].v_id = ECB_EMPTY_I; tmp->thd_regs[i].v_type = CB_EMPTY_T; Index: cerb_trace.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_trace.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- cerb_trace.c 4 Jun 2003 01:11:50 -0000 1.8 +++ cerb_trace.c 29 Jun 2003 16:40:53 -0000 1.9 @@ -32,7 +32,7 @@ { struct scb_trace *tr; - tr = fcb_malloc("trace", sizeof(struct scb_trace)); + tr = fcb_malloc(sizeof(struct scb_trace)); tr->tr_rule = rule; STAILQ_INSERT_TAIL(&th->thd_trace_head, tr, tr_next); } Index: cerb_tree.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_tree.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- cerb_tree.c 29 Jun 2003 14:42:59 -0000 1.34 +++ cerb_tree.c 29 Jun 2003 16:40:53 -0000 1.35 @@ -34,11 +34,11 @@ #ifdef _KERNEL #define MCB_PRINTF_L(args...) printf(args) -#define MCB_MALLOC_L(com, size) fcb_malloc(com, size) +#define MCB_MALLOC_L(size) fcb_malloc(size) #define MCB_FREE_L(addr) MCB_FREE(addr) #else #define MCB_PRINTF_L(args...) printf(args) -#define MCB_MALLOC_L(com, size) malloc(size) +#define MCB_MALLOC_L(size) malloc(size) #define MCB_FREE_L(addr) free(addr) #endif @@ -106,18 +106,17 @@ struct scb_label *tmpl; u_int i; - labels_head = MCB_MALLOC_L(__func__, sizeof(struct scb_labhead)); + labels_head = MCB_MALLOC_L(sizeof(struct scb_labhead)); SLIST_INIT(labels_head); for (i = 0; i < nrules; ++i) { if (rule[i].r_nfun != CB_GOTO_O) continue; - tmpl = MCB_MALLOC_L(__func__, sizeof(struct scb_label)); + tmpl = MCB_MALLOC_L(sizeof(struct scb_label)); if (rule[i].r_args == NULL || rule[i].r_args[0].v_str == NULL) tmpl->l_name = NULL; else { - tmpl->l_name = MCB_MALLOC_L(__func__, - rule[i].r_args[0].v_size); + tmpl->l_name = MCB_MALLOC_L(rule[i].r_args[0].v_size); strlcpy(tmpl->l_name, rule[i].r_args[0].v_str, rule[i].r_args[0].v_size); } Index: cerb_urules.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_urules.c,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- cerb_urules.c 28 Jun 2003 06:59:49 -0000 1.74 +++ cerb_urules.c 29 Jun 2003 16:40:53 -0000 1.75 @@ -48,11 +48,10 @@ SLIST_HEAD(, scb_aptr) vcb_aptrs_head = SLIST_HEAD_INITIALIZER(&vcb_aptrs_head); -#define MCB_MALLOC_L(com, size) fcb_malloc(com, size) +#define MCB_MALLOC_L(size) fcb_malloc(size) #define MCB_FREE_L(addr) MCB_FREE(addr) #define ADD_APTR(addr, tmp, type) do { \ - (tmp) = fcb_malloc("allocated pointer", \ - sizeof(struct scb_aptr)); \ + (tmp) = fcb_malloc(sizeof(struct scb_aptr)); \ (tmp)->ap_ptr = (addr); \ (tmp)->ap_type = (type); \ SLIST_INSERT_HEAD(&vcb_aptrs_head, (tmp), ap_next); \ @@ -61,7 +60,7 @@ #define ADD_APTR(addr, tmp, type) #define MCB_DEBUG(th, fmt, args...) \ printf("CerbLister:DEBUG:%s: " fmt "\n", __func__ , ## args) -#define MCB_MALLOC_L(com, size) malloc(size) +#define MCB_MALLOC_L(size) malloc(size) #define MCB_FREE_L(addr) free(addr) #define MCB_XERROR(fmt, args...) \ printf("CerbNG:ERROR:%s: " fmt "\n", __func__ , ## args) @@ -135,8 +134,7 @@ if (nscalls == 0) scalls = NULL; else { - scalls = MCB_MALLOC_L("Temporary syscalls table", - nscalls * sizeof(int)); + scalls = MCB_MALLOC_L(nscalls * sizeof(int)); if (scalls == NULL) { MCB_XERROR("Cannot allocate memory for temporary syscalls " "table."); @@ -164,8 +162,7 @@ goto fail; } - tab = MCB_MALLOC_L("Temporary urules table", - (nrules + 1) * sizeof(struct scb_urule)); + tab = MCB_MALLOC_L((nrules + 1) * sizeof(struct scb_urule)); if (tab == NULL) { MCB_XERROR("Cannot allocate memory for temporary urules " "table."); @@ -202,8 +199,7 @@ nrules = i; #endif - addr = MCB_MALLOC_L("Adresses of rules in kernel space", - nrules * sizeof(struct scb_rule)); + addr = MCB_MALLOC_L(nrules * sizeof(struct scb_rule)); if (addr == NULL) { MCB_XERROR("Can't allocate memory for rules pointers."); error = ENOMEM; @@ -349,8 +345,7 @@ args = rule->r_args = NULL; } else { #ifdef _KERNEL - args = MCB_MALLOC_L("Temporary arguments table", - nvals * sizeof(struct scb_val)); + args = MCB_MALLOC_L(nvals * sizeof(struct scb_val)); if (args == NULL) { MCB_XERROR("Cannot allocate memory for temporary urules " "table."); @@ -410,8 +405,7 @@ if (nvals == 0) return (0); - rule->r_args = MCB_MALLOC_L("urule_fill", - sizeof(struct scb_val) * nvals); + rule->r_args = MCB_MALLOC_L(sizeof(struct scb_val) * nvals); #ifndef _KERNEL if (rule->r_args == NULL) { MCB_XERROR("Can't allocate memory for arguments."); @@ -471,8 +465,7 @@ } copysize *= sizeof(int); } - valp->v_ptr = MCB_MALLOC_L("urule_fill: " - "allocation", copysize); + valp->v_ptr = MCB_MALLOC_L(copysize); #ifndef _KERNEL if (valp->v_ptr == NULL) { MCB_XERROR("Can't allocate memory for " @@ -520,8 +513,8 @@ (u_int)size, CB_MAXSTRPSIZE_G); return (EINVAL); } - valp->v_strp = MCB_MALLOC_L("urule_fill:strp " - "allocation", size * sizeof(char *)); + valp->v_strp = MCB_MALLOC_L(size * + sizeof(char *)); #ifndef _KERNEL if (valp->v_strp == NULL) { MCB_XERROR("Can't allocate memory for " @@ -564,8 +557,7 @@ CB_MAXSTRSIZE_G); return (EINVAL); } - valp->v_strp[j] = MCB_MALLOC_L("urule_" - "fill:str allocation", strsize); + valp->v_strp[j] = MCB_MALLOC_L(strsize); #ifndef _KERNEL if (valp->v_strp[j] == NULL) { MCB_XERROR("Can't allocate " @@ -606,8 +598,7 @@ size = sizeof(struct prison); else /* if (valpu->v_type == CB_ST_SOCKADDR_T) */ size = sizeof(struct sockaddr); - valp->v_prison = MCB_MALLOC_L("urule_fill: " - "allocation", size); + valp->v_prison = MCB_MALLOC_L(size); #ifndef _KERNEL if (valp->v_prison == NULL) { MCB_XERROR("Can't allocate memory for " Index: cerb_usersysctl.c =================================================================== RCS file: /cvsroot/cerber/cerb-ng/kcerb/cerb_usersysctl.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cerb_usersysctl.c 29 Jun 2003 14:42:59 -0000 1.2 +++ cerb_usersysctl.c 29 Jun 2003 16:40:53 -0000 1.3 @@ -89,7 +89,7 @@ if (error != 0) return (error); - scn = fcb_malloc("user sysctl scnode", sizeof(struct scb_scnode)); + scn = fcb_malloc(sizeof(struct scb_scnode)); sysctl_ctx_init(&scn->scn_list); oidp = SYSCTL_ADD_NODE(&scn->scn_list, SYSCTL_CHILDREN(oidp), OID_AUTO, @@ -122,11 +122,11 @@ if (strncmp(inname, "cerb.user.", 10 /* strlen("cerb.user.") */) == 0) { size = strlen(inname) + 1; - *name = fcb_malloc("user sysctl name", size); + *name = fcb_malloc(size); strlcpy(*name, inname, size); } else { size = strlen(inname) + 10 + 1; - *name = fcb_malloc("user sysctl name", size); + *name = fcb_malloc(size); strlcpy(*name, "cerb.user.", size); strlcat(*name, inname, size); } @@ -214,13 +214,14 @@ #endif if ((flags & ~ALLOWED_FLAGS) != 0) { + fcb_free(node); #ifdef CB_DEBUG_USERSYSCTL MCB_DEBUG("Failed (wrong flags)."); #endif return (EINVAL); } - tmpstr = fcb_malloc("tmp string", size); + tmpstr = fcb_malloc(size); strlcpy(tmpstr, node, size); if (fcb_name2oid(tmpstr, &oidp) == 0) { @@ -276,7 +277,7 @@ return (ENOENT); } - scn = fcb_malloc("user sysctl node", sizeof(struct scb_scnode)); + scn = fcb_malloc(sizeof(struct scb_scnode)); scn->scn_type = type; scn->scn_secure = (flags & CTLFLAG_SECURE) ? 1 : 0; @@ -300,7 +301,7 @@ size_t size; size = ccb_misc_usersysctl_size; - scn->scn_str = fcb_malloc("user sysctl string", size); + scn->scn_str = fcb_malloc(size); strlcpy(scn->scn_str, valp->v_str, size); oidp = SYSCTL_ADD_STRING(list, SYSCTL_CHILDREN(oidp), OID_AUTO, name, flags, scn->scn_str, size, "user sysctl string"); |