Beispiel #1
0
int	main(void)
{
  char		*cmd;
  t_node	*tree;

  init_global();
  while (!global.status)
    {
      tree = NULL;
      global.prompt = edit_prompt(global.config, global.env);
      if ((cmd = edit_cmd(&global, global.prompt)) == NULL && !global.status)
	global.status = !global.status;
      if (my_strlen(cmd) >= MAX_LINE_NUMBER)
	fprintf(stderr, "%s: File name too long\n", cmd);
      else if (!global.status)
	if (is_singlestr(' ', cmd) && (tree = parsing_func(cmd, &global, 0)))
	  if ((exec_course_tree(tree, global.env, &global)) == EXIT_CHILD)
	    {
	      sh_free(&global, tree, cmd);
	      (global.prompt) ? free(global.prompt) : (global.prompt = NULL);
	      return (global.exit);
	    }
      sh_free(NULL, tree, cmd);
      (global.prompt) ? free(global.prompt) : (global.prompt = NULL);
    }
  sh_free(&global, NULL, NULL);
  return (global.exit);
}
Beispiel #2
0
void CRYPTO_secure_clear_free(void *ptr, size_t num,
                              const char *file, int line)
{
#ifdef IMPLEMENTED
    size_t actual_size;

    if (ptr == NULL)
        return;
    if (!CRYPTO_secure_allocated(ptr)) {
        OPENSSL_cleanse(ptr, num);
        CRYPTO_free(ptr, file, line);
        return;
    }
    CRYPTO_THREAD_write_lock(sec_malloc_lock);
    actual_size = sh_actual_size(ptr);
    CLEAR(ptr, actual_size);
    secure_mem_used -= actual_size;
    sh_free(ptr);
    CRYPTO_THREAD_unlock(sec_malloc_lock);
#else
    if (ptr == NULL)
        return;
    OPENSSL_cleanse(ptr, num);
    CRYPTO_free(ptr, file, line);
#endif /* IMPLEMENTED */
}
Beispiel #3
0
static int
lsendraw(lua_State *L) {
    int session = luaL_checkinteger(L, 1);
    int source = luaL_checkinteger(L, 2);
    int dest = luaL_checkinteger(L, 3);
    int type = luaL_checkinteger(L, 4);
    luaL_checktype(L, 5, LUA_TLIGHTUSERDATA);
    void *msg = lua_touserdata(L, 5);
    int sz = luaL_checkinteger(L, 6);
    if (sh_handle_call(session, source, dest, type, msg, sz)) {
        sh_free(msg);
        return luaL_error(L, "send %d ~ %d, session:%d, type:%d", source, dest, session, type);
    } else {
        sh_free(msg);
        return 0;
    }
}
Beispiel #4
0
static int
lsend(lua_State *L) {
    struct module *ctx = lua_touserdata(L, lua_upvalueindex(1));
    assert(ctx);
    int session = luaL_checkinteger(L, 1);
    int dest = luaL_checkinteger(L, 2);
    int type = luaL_checkinteger(L, 3);
    luaL_checktype(L, 4, LUA_TLIGHTUSERDATA);
    void *msg = lua_touserdata(L, 4);
    int sz = luaL_checkinteger(L, 5);
    if (sh_handle_call(session, ctx->moduleid, dest, type, msg, sz)) {
        sh_free(msg);
        return luaL_error(L, "send %d ~ %d, session:%d, type:%d", ctx->moduleid, dest, session, type);
    } else {
        sh_free(msg);
        return 0;
    }
}
Beispiel #5
0
Datei: args.c Projekt: 8l/FUZIX
DOLPTR freeargs(DOLPTR blk)
{
	register char **argp;
	register DOLPTR argr = 0;
	register DOLPTR argblk;

	if (argblk = blk) {
		argr = argblk->dolnxt;
		if ((--argblk->doluse) == 0) {
			for (argp = (char **) argblk->dolarg;
			     ((intptr_t)(*argp)) != ENDARGS; argp++) {
				sh_free(*argp);
			}
			sh_free(argblk);
		}
	}
	return (argr);
}
Beispiel #6
0
static int
lbroadcast(lua_State *L) {
    struct module *ctx = lua_touserdata(L, lua_upvalueindex(1));
    assert(ctx);
    int dest = luaL_checkinteger(L, 1);
    int type = luaL_checkinteger(L, 2);
    luaL_checktype(L, 3, LUA_TLIGHTUSERDATA);
    void *msg = lua_touserdata(L, 3);
    int sz = luaL_checkinteger(L, 4);
    int n = sh_handle_broadcast(ctx->moduleid, dest, type, msg, sz);
    lua_pushinteger(L, n);
    sh_free(msg);
    return 1;
}
Beispiel #7
0
void CRYPTO_secure_free(void *ptr, const char *file, int line)
{
#ifdef OPENSSL_SECURE_MEMORY
    size_t actual_size;

    if (ptr == NULL)
        return;
    if (!CRYPTO_secure_allocated(ptr)) {
        CRYPTO_free(ptr, file, line);
        return;
    }
    CRYPTO_THREAD_write_lock(sec_malloc_lock);
    actual_size = sh_actual_size(ptr);
    CLEAR(ptr, actual_size);
    secure_mem_used -= actual_size;
    sh_free(ptr);
    CRYPTO_THREAD_unlock(sec_malloc_lock);
#else
    CRYPTO_free(ptr, file, line);
#endif /* OPENSSL_SECURE_MEMORY */
}
Beispiel #8
0
void CRYPTO_secure_free(void *ptr)
{
#ifdef IMPLEMENTED
    size_t actual_size;

    if (ptr == NULL)
        return;
    if (!secure_mem_initialized) {
        CRYPTO_free(ptr);
        return;
    }
    LOCK();
    actual_size = sh_actual_size(ptr);
    CLEAR(ptr, actual_size);
    secure_mem_used -= actual_size;
    sh_free(ptr);
    UNLOCK();
#else
    CRYPTO_free(ptr);
#endif /* IMPLEMENTED */
}
Beispiel #9
0
void
check_sharetab()
{
	FILE *f;
	struct stat st;
	static timestruc_t last_sharetab_time;
	timestruc_t prev_sharetab_time;
	struct share *sh;
	struct sh_list *shp, *shp_prev;
	int res, c = 0;

	/*
	 *  read in /etc/dfs/sharetab if it has changed
	 */

	if (stat(SHARETAB, &st) != 0) {
		syslog(LOG_ERR, "Cannot stat %s: %m", SHARETAB);
		return;
	}

	if (st.st_mtim.tv_sec == last_sharetab_time.tv_sec &&
	    st.st_mtim.tv_nsec == last_sharetab_time.tv_nsec) {
		/*
		 * No change.
		 */
		return;
	}

	/*
	 * Remember the mod time, then after getting the
	 * write lock check again.  If another thread
	 * already did the update, then there's no
	 * work to do.
	 */
	prev_sharetab_time = last_sharetab_time;

	(void) rw_wrlock(&sharetab_lock);

	if (prev_sharetab_time.tv_sec != last_sharetab_time.tv_sec ||
	    prev_sharetab_time.tv_nsec != last_sharetab_time.tv_nsec) {
		(void) rw_unlock(&sharetab_lock);
		return;
	}

	f = fopen(SHARETAB, "r+");
	if (f == NULL) {
		syslog(LOG_ERR, "Cannot open %s: %m", SHARETAB);
		(void) rw_unlock(&sharetab_lock);
		return;
	}

	/*
	 * Lock the file so that unshare can't
	 * truncate it while we're reading
	 */
	if (lockf(fileno(f), F_LOCK, 0L) < 0) {
		syslog(LOG_ERR, "Cannot lock %s: %m", SHARETAB);
		(void) rw_unlock(&sharetab_lock);
		(void) fclose(f);
		return;
	}

	/*
	 * Once we are sure /etc/dfs/sharetab has been
	 * modified, flush netgroup cache entries.
	 */
	netgrp_cache_flush();

	sh_free(share_list);			/* free old list */
	share_list = NULL;

	while ((res = getshare(f, &sh)) > 0) {
		c++;
		if (strcmp(sh->sh_fstype, "nfs") != 0)
			continue;

		shp = malloc(sizeof (*shp));
		if (shp == NULL)
			goto alloc_failed;
		if (share_list == NULL)
			share_list = shp;
		else
			/* LINTED not used before set */
			shp_prev->shl_next = shp;
		shp_prev = shp;
		shp->shl_next = NULL;
		shp->shl_sh = sharedup(sh);
		if (shp->shl_sh == NULL)
			goto alloc_failed;
	}
	if (res < 0)
		syslog(LOG_ERR, "%s: invalid at line %d\n",
			SHARETAB, c + 1);

	if (stat(SHARETAB, &st) != 0) {
		syslog(LOG_ERR, "Cannot stat %s: %m", SHARETAB);
		(void) rw_unlock(&sharetab_lock);
		return;
	}
	last_sharetab_time = st.st_mtim;
	(void) fclose(f);
	(void) rw_unlock(&sharetab_lock);
	return;

alloc_failed:
	syslog(LOG_ERR, "check_sharetab: no memory");
	sh_free(share_list);
	share_list = NULL;
	(void) fclose(f);
	(void) rw_unlock(&sharetab_lock);
}
Beispiel #10
0
void free_hash_node(sh_ptr_t<sh_hash_node_t> pNode)
{
	sh_free(pNode->pValue);
	sh_free(pNode);
}