--- libaitrpc/src/cli.c 2013/08/21 22:34:18 1.16.8.1 +++ libaitrpc/src/cli.c 2013/08/22 08:56:15 1.16.8.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.16.8.1 2013/08/21 22:34:18 misho Exp $ +* $Id: cli.c,v 1.16.8.2 2013/08/22 08:56:15 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -172,14 +172,6 @@ rpc_cli_openClient(u_char InstID, int netBuf, const ch else netBuf = E_ALIGN(netBuf, 2); /* align netBuf length */ -#ifdef HAVE_SRANDOMDEV - srandomdev(); -#else - time_t tim; - - srandom((time(&tim) ^ getpid())); -#endif - cli = e_malloc(sizeof(rpc_cli_t)); if (!cli) { LOGERR; @@ -410,14 +402,19 @@ rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t array_t * __restrict vars, int noreply, int nocrc) { struct tagRPCCall *rpc; - int ret = 0, len = sizeof(struct tagRPCCall); + int ret = 0, estlen, len = sizeof(struct tagRPCCall); u_char *buf; if (!pkt || !sess) { rpc_SetErr(EINVAL, "Invalid argument(s)!"); return -1; - } else - buf = AIT_GET_BUF(pkt); + } + + /* calc estimated length */ + estlen = ait_resideVars(vars) + len; + if (estlen > AIT_LEN(pkt)) + AIT_RE_BUF(pkt, estlen); + buf = AIT_GET_BUF(pkt); /* prepare RPC call */ rpc = (struct tagRPCCall*) buf;