Patch Name: PHCO_27021 Patch Description: s700_800 10.20 diff(1) patch Creation Date: 02/06/13 Post Date: 02/06/24 Hardware Platforms - OS Releases: s700: 10.20 s800: 10.20 Products: N/A Filesets: OS-Core.CMDS-AUX Automatic Reboot?: No Status: General Release Critical: No Path Name: /hp-ux_patches/s700_800/10.X/PHCO_27021 Symptoms: PHCO_27021: 1. diff(1) command in few cases does not return the proper exit value when comparing sub-directories. 2. diff(1) command in few cases does not report minimal results. Defect Description: PHCO_27021: 1. diff(1) command returns wrong exit value in some cases when comparing the directories i.e. if the sub-directories of the two input directories differ, diff(1) command reports the correct differences, but it returns with an exit value "0". The expected (documented) behaviour is to return with an exit value "1" for any differences ( files, directories or sub directories). The problem can be reproduced as follows: $mkdir -p dir1/subdir1 dir2/subdir1 $touch dir1/subdir1/file1 $diff -r dir1 dir2 Common subdirectories: dir1/subdir1 and dir2/subdir1 Only in dir1/subdir1: file1 $echo $? 0 <--- This is wrong. Expected exit value is 1. $ Resolution : Initially the status of child process was not properly trapped in the parent process. Now the code is modified to capture the exit status of the child process. So if the subdirectories differ, then diff(1) will return with an exit value "1". 2. diff(1) command for some files does not report minimal differences. The problem can be reproduced as follows: $cat file1 12345678 01081679 $cat file2 01081679 $diff file1 file2 1,2c1 < 12345678 < 01081679 --- > 01081679 $ The expected output is $diff file1 file2 1d0 < 12345678 $ diff(1) command uses the hashing algorithm to compare the files. A hash value is generated for each line in the two files specified. diff(1) used to generate 16 bit hashing values. Because of this, the possibilities of having hash collisions(having the same hash values for two different lines) were high. If mth line of file1 and nth line of file2 computes to same hash value, then diff(1) assumes the two lines could be identical and hence applies the character-wise comparison on these two lines only. On finding them different,it just outputs them as the difference, without considering the situation that there could be an another line in file2 which is identical to mth line of file1. Hence diff(1) is not able to report minimal difference. The output differs depending on the ordering of lines in the input files. Resolution : The problem is addressed by modifying diff(1) command to generate 32bit hash values instead of 16bit values. This fix only minimizes the hash collisions. Even after this fix, there could be rare possibilities of getting hash value collisions in which case one could again see the command not generating minimal output. SR: 8606192634 8606251084 Patch Files: /usr/bin/diff what(1) Output: /usr/bin/diff: $Revision: 78.2.1.10 $ PATCH_10_20: diff.o diffdir.o diffreg.o hpux_rel.o 0 2/06/13 PATCH-PHCO_20441 for 10.20; for 10.30, 11.x compatib ility libc.a_ID@@/main/r10dav/libc_dav/libc_ dav_cpe/9 /ux/core/libs/libc/archive_pa1/libc.a_ID Nov 10 1999 10:43:44 cksum(1) Output: 722829 270336 /usr/bin/diff Patch Conflicts: None Patch Dependencies: None Hardware Dependencies: None Other Dependencies: None Supersedes: None Equivalent Patches: None Patch Package Size: 320 KBytes Installation Instructions: Please review all instructions and the Hewlett-Packard SupportLine User Guide or your Hewlett-Packard support terms and conditions for precautions, scope of license, restrictions, and, limitation of liability and warranties, before installing this patch. ------------------------------------------------------------ 1. Back up your system before installing a patch. 2. Login as root. 3. Copy the patch to the /tmp directory. 4. Move to the /tmp directory and unshar the patch: cd /tmp sh PHCO_27021 5a. For a standalone system, run swinstall to install the patch: swinstall -x autoreboot=true -x match_target=true \ -s /tmp/PHCO_27021.depot By default swinstall will archive the original software in /var/adm/sw/patch/PHCO_27021. If you do not wish to retain a copy of the original software, you can create an empty file named /var/adm/sw/patch/PATCH_NOSAVE. WARNING: If this file exists when a patch is installed, the patch cannot be deinstalled. Please be careful when using this feature. It is recommended that you move the PHCO_27021.text file to /var/adm/sw/patch for future reference. To put this patch on a magnetic tape and install from the tape drive, use the command: dd if=/tmp/PHCO_27021.depot of=/dev/rmt/0m bs=2k Special Installation Instructions: None