[Openais] SaNameT to char* implementation.

Manikandan Pattabiraman mail2manikandan at gmail.com
Tue Aug 22 07:24:57 PDT 2006


Hello,

> Thank you for the notification.  The attached patch is the correct
> solution for the problem.

Thanks for the quick fix.
In the fix, there is a static buffer that is returned from the method.
That buffer will be overwritten in the subsequent calls to getSaNameT
and if the returned pointer is stored and used, it will cause
confusions, also in threaded contexts non-reentrant methods are always
a problem.

we can allocate a new buffer and return but it is the callers
responsibility to free the memory. This will work perfectly but will
involve lots of code change and testing too.

please correct me if am wrong.

Thanks
Mani.,


>
> Regards
> -steve
>
> On Mon, 2006-08-21 at 23:26 +0530, Manikandan Pattabiraman wrote:
> > All,
> >
> > While I was browsing through openais sources, came across this piece of code.
> >
> > " return ((char *)name->value)" will return a string, which may not be
> > null terminated (if len is 256),
> > causing many problems.
> >
> >
> > Any suggestions/comments?
> >
> > Thanks
> > Mani.
> >
> >
> > ================================
> > char *getSaNameT (SaNameT *name)
> > {
> > #if 0
> >       static char ret_name[300];
> >
> >       memset (ret_name, 0, sizeof (ret_name));
> >
> >       if (name->length > 299) {
> >               memcpy (ret_name, name->value, 299);
> >       } else {
> >
> >               memcpy (ret_name, name->value, name->length);
> >       }
> >       return (ret_name);
> > #endif
> > // TODO
> >       return ((char *)name->value);
> >
> > }
> > ===============================
> > _______________________________________________
> > Openais mailing list
> > Openais at lists.osdl.org
> > https://lists.osdl.org/mailman/listinfo/openais
>
>
>



More information about the Openais mailing list