The new C version of initdb presently provokes the following valgrind
warnings:

==15366== 
==15366== Conditional jump or move depends on uninitialised value(s)
==15366==    at 0x8049713: mkdir_p (initdb.c:556)
==15366==    by 0x8049C8E: mkdatadir (initdb.c:812)
==15366==    by 0x804C833: main (initdb.c:2370)
==15366== Invalid read of size 1
==15366==    at 0x8049710: mkdir_p (initdb.c:556)
==15366==    by 0x8049C8E: mkdatadir (initdb.c:812)
==15366==    by 0x804C957: main (initdb.c:2418)
==15366==  Address 0x4177D8D3 is 0 bytes after a block of size 19 alloc'd
==15366==    at 0x4002CBEE: malloc (vg_replace_malloc.c:160)
==15366==    by 0x8049084: xmalloc (initdb.c:249)
==15366==    by 0x8049C39: mkdatadir (initdb.c:804)
==15366==    by 0x804C957: main (initdb.c:2418)

I doubt the mistake that causes these warnings would cause any
problems in practise (mkdir_p() reads one past the end of the string
passed into it, but doesn't actually change any meaningful state based
on what it reads), but being valgrind-clean is a good thing, so I've
applied the attached one-line patch to fix this.

-Neil

Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.20
diff -c -r1.20 initdb.c
*** src/bin/initdb/initdb.c	31 Jan 2004 21:18:00 -0000	1.20
--- src/bin/initdb/initdb.c	31 Jan 2004 21:45:05 -0000
***************
*** 553,559 ****
  		else if (p[0] != '/')
  			continue;
  		*p = '\0';
! 		if (p[1] == '\0')
  			last = 1;
  		if (first)
  		{
--- 553,559 ----
  		else if (p[0] != '/')
  			continue;
  		*p = '\0';
! 		if (!last && p[1] == '\0')
  			last = 1;
  		if (first)
  		{
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to