Adding strlcpy and strlcat replacements to libradius

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
I think we may perhaps add an autoconf test to detect whether the
system provides the srtlcpy and strlcat functions from OpenBSD.
If they're not present, we'd compile a replacement in libradius.

These functions provide a consistent, unambiguous API described in
this paper:
http://www.usenix.org/events/usenix99/full_papers/millert/millert_html/index.html

I know that our home-made strNcpy already ensures NUL-terminaison,
but it has some weakness:
- it seems it's wrong when N <= 0
- it's not easy to check if truncation has occurred

I don't plan to change the code everywhere, but I'd like to have the
functions available when writing new code.

If I get approbation, I suggest to bring the following files in
libradius. As to my understanding their licence allows us to do that:
ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c
ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c

--
Nicolas Baradakis
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Alan DeKok
Nicolas Baradakis <[hidden email]> wrote:
> I know that our home-made strNcpy already ensures NUL-terminaison,
> but it has some weakness:
> - it seems it's wrong when N <= 0
> - it's not easy to check if truncation has occurred

  I agree.

> I don't plan to change the code everywhere, but I'd like to have the
> functions available when writing new code.

  strNcpy should be deleted, and all calls to it replaced with strlcpy.

> If I get approbation, I suggest to bring the following files in
> libradius. As to my understanding their licence allows us to do that:
> ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c
> ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcat.c

  Yes.

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Frank Cusack
In reply to this post by Nicolas Baradakis
On September 20, 2005 2:29:22 AM +0200 Nicolas Baradakis <[hidden email]> wrote:
> I think we may perhaps add an autoconf test to detect whether the
> system provides the srtlcpy and strlcat functions from OpenBSD.
> If they're not present, we'd compile a replacement in libradius.

please!
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
In reply to this post by Alan DeKok
> I think we may perhaps add an autoconf test to detect whether the
> system provides the srtlcpy and strlcat functions from OpenBSD.
> If they're not present, we'd compile a replacement in libradius.

Where should I put the prototypes of strlcpy and strlcat ?

I'm a little lost in the files in src/include. Sometimes replacement
functions are declared in libradius.h, sometimes in missing.h. There
are many things in missing.h not related to things in missing.c.

--
Nicolas Baradakis

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Alan DeKok
Nicolas Baradakis <[hidden email]> wrote:
> Where should I put the prototypes of strlcpy and strlcat ?

  missing.h.

> I'm a little lost in the files in src/include. Sometimes replacement
> functions are declared in libradius.h, sometimes in missing.h. There
> are many things in missing.h not related to things in missing.c.

  Yeah, it's a mess.

  The idea is that libradius.h should be usable by external programs,
after the server has been installed.

  Alan DeKok.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Guy Fraser
On Tue, 2005-20-09 at 13:46 -0400, Alan DeKok wrote:

> Nicolas Baradakis <[hidden email]> wrote:
> > Where should I put the prototypes of strlcpy and strlcat ?
>
>   missing.h.
>
> > I'm a little lost in the files in src/include. Sometimes replacement
> > functions are declared in libradius.h, sometimes in missing.h. There
> > are many things in missing.h not related to things in missing.c.
>
>   Yeah, it's a mess.
>
>   The idea is that libradius.h should be usable by external programs,
> after the server has been installed.
>
>   Alan DeKok.
How about openbsdstrings.h, safestrings.h, theo.h or strl.h ?


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
In reply to this post by Alan DeKok
Alan DeKok wrote:

> > Where should I put the prototypes of strlcpy and strlcat ?
>
>   missing.h.

Done.

> > I'm a little lost in the files in src/include. Sometimes replacement
> > functions are declared in libradius.h, sometimes in missing.h. There
> > are many things in missing.h not related to things in missing.c.
>
>   Yeah, it's a mess.
>
>   The idea is that libradius.h should be usable by external programs,
> after the server has been installed.

That'd be very nice. In that case we could install the libradius
headers in /usr/include/freeradius, too.

--
Nicolas Baradakis

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Peter Nixon-2
On Wednesday 21 September 2005 20:10, Nicolas Baradakis wrote:

> Alan DeKok wrote:
> > > Where should I put the prototypes of strlcpy and strlcat ?
> >
> >   missing.h.
>
> Done.
>
> > > I'm a little lost in the files in src/include. Sometimes replacement
> > > functions are declared in libradius.h, sometimes in missing.h. There
> > > are many things in missing.h not related to things in missing.c.
> >
> >   Yeah, it's a mess.
> >
> >   The idea is that libradius.h should be usable by external programs,
> > after the server has been installed.
>
> That'd be very nice. In that case we could install the libradius
> headers in /usr/include/freeradius, too.

Yes. And make -devel binary packages..

--

Peter Nixon
http://www.peternixon.net/
PGP Key: http://www.peternixon.net/public.asc
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Paul "TBBle" Hampson
On Tue, Oct 04, 2005 at 11:17:23AM +0300, Peter Nixon wrote:
> On Wednesday 21 September 2005 20:10, Nicolas Baradakis wrote:
>> Alan DeKok wrote:
> > >> Where should I put the prototypes of strlcpy and strlcat ?

> >>   missing.h.

>> Done.

> > >> I'm a little lost in the files in src/include. Sometimes replacement
> > >> functions are declared in libradius.h, sometimes in missing.h. There
> > >> are many things in missing.h not related to things in missing.c.

> >>   Yeah, it's a mess.

> >>   The idea is that libradius.h should be usable by external programs,
> >> after the server has been installed.

>> That'd be very nice. In that case we could install the libradius
>> headers in /usr/include/freeradius, too.

> Yes. And make -devel binary packages..

And people could build modules outside the tree without needing the
whole source... ^_^

I'm starting to think we should skip 2.0 and go straight to 3.0...

--
-----------------------------------------------------------
Paul "TBBle" Hampson, MCSE
8th year CompSci/Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
[hidden email]

Of course Pacman didn't influence us as kids. If it did,
we'd be running around in darkened rooms, popping pills and
listening to repetitive music.
 -- Kristian Wilson, Nintendo, Inc, 1989

License: http://creativecommons.org/licenses/by/2.1/au/
-----------------------------------------------------------

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Alan DeKok
Paul TBBle Hampson <[hidden email]> wrote:
> > Yes. And make -devel binary packages..
>
> And people could build modules outside the tree without needing the
> whole source... ^_^

  That would involve fixing the headers to avoid things like #ifdef
HAVE_FOO.  I don't want to make the same mistake the net-snmp people did.

> I'm starting to think we should skip 2.0 and go straight to 3.0...

  I'd like to go to 2.0 first.  The proxy code needs fixing, and the
realms need updating.  I'm still waiting for the patch from
Earthlink...

  I think we should release 2.0 before Christmas, and target 3.0 for
next summer.  Maybe this time we can have a schedule we can stick to.

  Alan DeKok.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
Alan DeKok wrote:

>   That would involve fixing the headers to avoid things like #ifdef
> HAVE_FOO.  I don't want to make the same mistake the net-snmp people did.

For now libradius.h includes autoconf.h, which is annoying for the
people who want to use the libradius in an external program. And it
seems it's not needed: for me the server compiles successfully with
the #include "autoconf.h" removed from src/include/*.h.

--
Nicolas Baradakis

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Alan DeKok
Nicolas Baradakis <[hidden email]> wrote:
> For now libradius.h includes autoconf.h, which is annoying for the
> people who want to use the libradius in an external program. And it
> seems it's not needed: for me the server compiles successfully with
> the #include "autoconf.h" removed from src/include/*.h.

  Wonderful.  Let's nuke it from those files, then.

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
In reply to this post by Alan DeKok
Alan DeKok wrote:

>   I'd like to go to 2.0 first.  The proxy code needs fixing, and the
> realms need updating.  I'm still waiting for the patch from
> Earthlink...

Maybe we could start a TODO list with the changes and bugfixes we'd
want in release 2.0. The bugzilla is one of the possible places to
do this.

--
Nicolas Baradakis

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Alan DeKok
Nicolas Baradakis <[hidden email]> wrote:
> Maybe we could start a TODO list with the changes and bugfixes we'd
> want in release 2.0. The bugzilla is one of the possible places to
> do this.

  There are feature requests in bugzilla.  I'll see if I can add a
"2.0" target.

  Alan DeKok.

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Reply | Threaded
Open this post in threaded view
|

Re: Adding strlcpy and strlcat replacements to libradius

Nicolas Baradakis
Alan DeKok wrote:

> > Maybe we could start a TODO list with the changes and bugfixes we'd
> > want in release 2.0. The bugzilla is one of the possible places to
> > do this.
>
>   There are feature requests in bugzilla.  I'll see if I can add a
> "2.0" target.

It'd be easy to open a bug "Release 2.0" and have it depends on the
feature requests we wish for 2.0.

Something like that was done for version 1.0.
http://bugs.freeradius.org/show_bug.cgi?id=26

--
Nicolas Baradakis

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html