Patch Name: PHCO_26907 Patch Description: s700_800 11.11 diff(1) patch Creation Date: 02/06/17 Post Date: 02/06/20 Hardware Platforms - OS Releases: s700: 11.11 s800: 11.11 Products: N/A Filesets: OS-Core.CMDS-AUX,fr=B.11.11,fa=HP-UX_B.11.11_32/64,v=HP Automatic Reboot?: No Status: General Release Critical: No Category Tags: defect_repair general_release Path Name: /hp-ux_patches/s700_800/11.X/PHCO_26907 Symptoms: PHCO_26907: ( SR:8606254124 CR:JAGae18456 ) diff(1) is not handling the incomplete/illegal multibyte characters properly in multibyte environment. ( SR:8606192634 CR:JAGad61846 ) diff(1) command does not return the proper exit value when comparing sub-directories. ( SR:8606251084 CR:JAGae17150 ) diff(1) command in few cases does not report minimal results. Defect Description: PHCO_26907: ( SR:8606254124 CR:JAGae18456 ) diff(1) command misbehaves in multi-byte environment for files containing invalid multi-byte characters. The problem can be reproduced as follows: - Generate a file(file1) with few invalid multi-byte characters. $cp file1 file2 $export LANG= $vi file2 :wq - ls -l file1 file2 shows that files have different size. $diff file1 file2 $ Note that diff(1) should have shown the difference between the two files. $export LANG=C $diff file1 file2 $ Resolution: In the multibyte environment, while comparing the two characters, diff(1) tries to match their wide character representation. Now along with this comparison, diff(1) also compares the validity of the two characters. ( SR:8606192634 CR:JAGad61846 ) 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) behavior 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 also. So if the subdirectories differ, then diff(1) will return with an exit value "1". ( SR:8606251084 CR:JAGae17150 ) 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 8606254124 Patch Files: OS-Core.CMDS-AUX,fr=B.11.11,fa=HP-UX_B.11.11_32/64,v=HP: /usr/bin/diff what(1) Output: OS-Core.CMDS-AUX,fr=B.11.11,fa=HP-UX_B.11.11_32/64,v=HP: /usr/bin/diff: diff.c $Date: 2002/06/03 03:20:39 $Revision: r11.11/ 2 PATCH_11.11 (PHCO_26907) diffdir.c $Date: 2002/06/03 03:20:03 $Revision: r11. 11/3 PATCH_11.11 (PHCO_26907) diffreg.c $Date: 2002/06/03 03:18:35 $Revision: r11. 11/3 PATCH_11.11 (PHCO_26907) $Revision: @(#) diff CUP11.11_BL2002_0617_2 PATCH_11 .11 PHCO_26907 Mon Jun 17 05:04:06 PDT 2002 $ cksum(1) Output: OS-Core.CMDS-AUX,fr=B.11.11,fa=HP-UX_B.11.11_32/64,v=HP: 2027264724 36864 /usr/bin/diff Patch Conflicts: None Patch Dependencies: None Hardware Dependencies: None Other Dependencies: None Supersedes: None Equivalent Patches: PHCO_27012: s700: 11.00 s800: 11.00 Patch Package Size: 60 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_26907 5. Run swinstall to install the patch: swinstall -x autoreboot=true -x patch_match_target=true \ -s /tmp/PHCO_26907.depot By default swinstall will archive the original software in /var/adm/sw/save/PHCO_26907. If you do not wish to retain a copy of the original software, include the patch_save_files option in the swinstall command above: -x patch_save_files=false WARNING: If patch_save_files is false when a patch is installed, the patch cannot be deinstalled. Please be careful when using this feature. For future reference, the contents of the PHCO_26907.text file is available in the product readme: swlist -l product -a readme -d @ /tmp/PHCO_26907.depot To put this patch on a magnetic tape and install from the tape drive, use the command: dd if=/tmp/PHCO_26907.depot of=/dev/rmt/0m bs=2k Special Installation Instructions: None