[OpenAFS-devel] problem with ptserver after upgrade to 1.2.6

Johan Danielsson joda+openafs@pdc.kth.se
07 Aug 2002 14:35:26 +0200


We got the interesting behaviour that "pts exa name" returned an
error, while "pts exa number" worked. It turned out to be due to an
error introduced in ptprocs.c rev 1.10. The error is that malloc is
assumed to either always return non-NULL, or not be passed 0. This
change fixed this problem:

--- ptprocs.c~  Sun Apr 21 06:01:51 2002
+++ ptprocs.c   Wed Aug  7 14:12:45 2002
@ -527,7 +527,7 @
     if (size <= 0) size = 0;
     aname->namelist_val = (prname *)malloc(size*PR_MAXNAMELEN);
     aname->namelist_len = 0;
-    if (aname->namelist_val == 0) return PRNOMEM;
+    if (aname->namelist_val == 0 && size > 0) return PRNOMEM;
     if (aid->idlist_len == 0) return 0;
     if (size == 0) return PRTOOMANY;   /* rxgen will probably handle this */

I suppose a more elegant fix would be to just return 0 if
aid->idlist_len == 0, before trying to malloc anything.

Looking at other functions in the same file, I get a feeling that this
type of problem can be lurking in more places. I have no idea how many
of these functions can get a size of 0 passed to them.

"Someone" should take a look at this.

/Johan