ls(1) on System V

Mark Plotnick mp at allegra.UUCP
Sat Apr 6 09:11:22 AEST 1985


Well, the problem is that in the readdir() routine, the code is doing
strlen(dentry.d_name), and d_name isn't null-terminated if it's 14
characters long (I think strlen returns 44 or so).  Now if you have a
binary distribution, all is not lost; since dentry is the only
automatic variable in the readdir() routine, you can increase your
chances of finding a null at the end of the structure by increasing the
amount of automatic space the routine allocates.  I changed the .s file
and assembled it and this works until you start asking ls to list more
than one directory at a time.


*** old	Fri Apr  5 17:41:31 1985
--- new	Fri Apr  5 17:42:33 1985
***************
*** 1,6
  readdir()
  	8080112e:  10 47                     SAVE    %r7
! 	80801130:  9c 10 4c                  ADDW2   &0x10,%sp
  	80801133:  a0 5a                     PUSHW   0(%ap)
  	80801135:  a0 4f c5 14 88 80         PUSHW   &0x808814c5
  	8080113b:  2c cc f8 7f a8 44 80 80   CALL    0xf8(%sp),$0x808044a8

--- 1,6 -----
  readdir()
  	8080112e:  10 47                     SAVE    %r7
! 	80801130:  9c 14 4c                  ADDW2   &0x14,%sp
  	80801133:  a0 5a                     PUSHW   0(%ap)
  	80801135:  a0 4f c5 14 88 80         PUSHW   &0x808814c5
  	8080113b:  2c cc f8 7f a8 44 80 80   CALL    0xf8(%sp),$0x808044a8

Lacking adb (they don't offer it on 3b's) and sufficient knowledge
about the COFF, I can't offer a sure-fire way to patch
the binary, though.
	Mark Plotnick
	allegra!mp



More information about the Comp.unix.wizards mailing list