Bug 49856

Summary: diff -r blindly follows symlinks
Product: [Retired] Red Hat Linux Reporter: David Nečas <yeti>
Component: diffutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED RAWHIDE QA Contact: Aaron Brown <abrown>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-07-24 16:35:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Nečas 2001-07-24 16:35:04 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.19 i686; en-US; rv:0.9.1)
Gecko/20010607

Description of problem:
diff -r blindly follows symlinks, namely directory symlinks.  When the
compared directories accidentaly contain link cycles, strange things
happen.  It's not possible to use diff -r at such directory structures at all.

How reproducible:
Always

Steps to Reproduce:
1. Create two identical directory structures with link cycles using
following commands:

  mkdir 1 2
  cd 1
  mkdir a b
  cd a
  ln -s ../b b
  cd ../b
  ln -s ../a a
  cd ../../2
  mkdir a b
  cd a
  ln -s ../b b
  cd ../b
  ln -s ../a a
  cd ../..

2. run

  diff -r 1 2
	

Actual Results:  For a good while it seems nothing is happening, then diff
prints two messages like (several hundreds of `a/b/'s omitted in the place
of `...')

   diff: 1/a/b/a/b/a/b/a/b/a/b/a/b/.../a/b/a/b/a/b: File name too long

and after a while it ends.

Expected Results:  diff realizes the directories are identical, realizes it
pretty fast and doesn't print any error messages.

Additional info:

It is arguable what diff should do in similar situations.  I don't see why
it should follow symlinks at all, namely directory symlinks.  Maybe it
could be made optional, at least.

Comment 1 Tim Waugh 2001-07-30 11:45:53 UTC
This behaviour is fixed in our rawhide tree.  diffutils-2.7.2-1 gives this:

diff: 1/a/b/a: recursive directory loop
diff: 1/b/a/b: recursive directory loop