Going to beta 3a - mistake in scandir?

Nick.SIMON at syntegra.bt.co.uk Nick.SIMON at syntegra.bt.co.uk
Wed Aug 16 14:15:57 UTC 2000


Going through the beta 3 to 3a diff file ('cos I've got a problem) I
discovered this snippet, which looks wrong to me - the new strncpy is
copying FROM just-malloced memory.  Note also there's no version control
change.


*** rtems-4.5.0-beta3/c/src/lib/libc/scandir.c	Tue Nov 16 09:26:29 1999
--- rtems-4.5.0-beta3a/c/src/lib/libc/scandir.c	Tue May 16 14:06:41 2000
***************
*** 112,118 ****
  		p->d_ino = d->d_ino;
  		p->d_reclen = d->d_reclen;
  		p->d_namlen = d->d_namlen;
! 		strncpy(p->d_name, d->d_name, p->d_namlen + 1);
  		/*
  		 * Check to make sure the array has space left and
  		 * realloc the maximum size.
--- 112,118 ----
  		p->d_ino = d->d_ino;
  		p->d_reclen = d->d_reclen;
  		p->d_namlen = d->d_namlen;
! 		strncpy(d->d_name, p->d_name, p->d_namlen + 1);
  		/*
  		 * Check to make sure the array has space left and
  		 * realloc the maximum size.


-- Nick Simon 



More information about the users mailing list