[PATCH] Autogenerated DFS parser

Jeremy Allison jra at samba.org
Sun Oct 9 18:49:20 GMT 2005


On Sun, Oct 09, 2005 at 01:27:13PM +0200, Jelmer Vernooij wrote:
> Thanks.
> 
> The parser generator should work for all IDL files, with the following
> exceptions:
> 
> - - [string] attributes don't work yet, but I'll be adding these shortly
> - - [subcontext] attributes, I'll wait a bit for [subcontext] to be replaced
> - - DATA_BLOB is not yet supported
> 
> If you hit any bugs, please let me know.

Ok, I found a bug when valgrinding :-).

You're missing an idiom in the auto-generated rpc_server/srv_dfs.c
code. You produce (for example) :

static BOOL api_dfs_Enum(pipes_struct *p)
{
        NETDFS_Q_DFS_ENUM q_u;
        NETDFS_R_DFS_ENUM r_u;
        prs_struct *data = &p->in_data.data;
        prs_struct *rdata = &p->out_data.rdata;

        if (!netdfs_io_q_dfs_Enum("", &q_u, data, 0))
                return False;

        r_u.status = _dfs_Enum(p, &q_u, &r_u);

        if (!netdfs_io_r_dfs_Enum("", &r_u, rdata, 0))
                return False;

        return True;
}

You're missing a ZERO_STRUCT on the q_u and r_u
parameters. The generated code needs to look like :

static BOOL api_dfs_Enum(pipes_struct *p)
{
        NETDFS_Q_DFS_ENUM q_u;
        NETDFS_R_DFS_ENUM r_u;
        prs_struct *data = &p->in_data.data;
        prs_struct *rdata = &p->out_data.rdata;

	ZERO_STRUCT(q_u);
	ZERO_STRUCT(r_u);

        if (!netdfs_io_q_dfs_Enum("", &q_u, data, 0))
                return False;

        r_u.status = _dfs_Enum(p, &q_u, &r_u);

        if (!netdfs_io_r_dfs_Enum("", &r_u, rdata, 0))
                return False;

        return True;
}

I think a lot of the Samba3 code assumes the r_u is zero'ed
before calling the "create reply" function. Admittedly, not
having this initialization helped find the uninitialized
variable (via valgrind) in a rpcclient dfsenum request, I'm
still trying to track down where the underlying initialization
failure is.

Jeremy.


More information about the samba-technical mailing list