Re: [Cpu-users] [patch] segfault on records with no gecos
Brought to you by:
matheny
|
From: Blake M. <ma...@db...> - 2002-05-31 17:15:57
|
cpu has been grossly neglected over the last couple of months. I've
been busy with several research projects, and have not done any
maintenance. On the roadmap is a rewrite of cpu, any help is
appreciated. The bulk of cpu was written in a few hours. Reasonable
patches will always be accepted, and cpu will be rewritten sometime
over the summer (hopefully). Thanks for the patch.
-Blake
Whatchu talkin' 'bout, Willis?
> I just recently grabbed CPU and after fighting to get it to build, it
> segfaulted on "cpu cat". It turns out that the code makes quite a few
> assumptions that aren't always true.
>
> In this case, if the gecos field isn't part of the user's entry, the
> random value from memory is derefernced and an oops will most likely
> occur.
>
> I've attached a patch to fix this. It simply zero's out the memory that
> was allocated. It results in "(null)" being printed, but it's better
> than segfault atleast.
>
> It looks like much of the code is kinda sloppy. You can see from my
> patch that simple things like checking if malloc succeeded or not is
> ignored and that's not the only place I see that.
>
> JE
>
> Index: src/ldap.c
> ===================================================================
> RCS file: /cvsroot/cpu/cpu-1.3/src/ldap.c,v
> retrieving revision 1.12
> diff -u -r1.12 ldap.c
> --- src/ldap.c 7 May 2002 21:10:26 -0000 1.12
> +++ src/ldap.c 26 May 2002 22:56:50 -0000
> @@ -1409,6 +1409,8 @@
> ldap_memfree(dn);
> passentry = malloc(sizeof (struct passerd));
>
> + memset(passentry, 0, sizeof(*passentry));
> +
> for (a = ldap_first_attribute(ld, e, &ber); a != NULL;
> a = ldap_next_attribute(ld, e, ber)) {
> if ((vals = ldap_get_values(ld, e, a)) != NULL) {
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
>
> _______________________________________________
> Cpu-users mailing list
> Cpu...@li...
> https://lists.sourceforge.net/lists/listinfo/cpu-users
--
Blake Matheny
ma...@db...
http://www.dbaseiv.net
|