[gnu.utils.bug] GNU diff's BUG

toshi@saturn.isl.melco.junet (Toshiyuki Game Player Ito) (04/24/89)

Dear FSF.

My name is ITO, TOSHIYUKI. 

I installed GNU diff(v.1.4) on SYSV.R2 machine. But It wasn't succeed because
free(2) bug? on SYSV.

I try to

% diff <file> <dir>

Usually it acts diff <file> <dir>/<file> on SYSV and BSD. GNU diff dumps
core(bus error). This bug is caused at line 479 in diff.c

	  free (inf[dir_arg].name);

In this case, inf[dir_arg].name may be argv[1] or argv[2]. So free(2) tries to
free *argv pointer on SYSV, and core dumped later. Because SYSV dose not check
free address.

I patched diff.c. (see below)

*** diff.c	Wed Apr  5 21:10:06 1989
--- ../gdiff/diff.c	Thu Apr 13 13:30:58 1989
***************
*** 292,298 ****
--- 292,302 ----
  
    switch_string = option_list (argv + 1, optind - 1);
  
+ #ifdef USG
+   val = compare_files (0, strcpy((char *) xmalloc(strlen(argv[optind]) + 1), argv[optind]), 0, strcpy((char *) xmalloc(strlen(argv[optind + 1]) + 1), argv[optind + 1]), 0);
+ #else
    val = compare_files (0, argv[optind], 0, argv[optind + 1], 0);
+ #endif
  
    /* Print any messages that were saved up for last.  */
    print_message_queue ();

I hope, this bug will be fixed, Thank you.

---------
          ITO, TOSHIYUKI
Office:   INFORMATION SYSTEMS & ELECTRONICS DEVELOPMENT LAB.
          MITSUBISHI ELECTRIC CORPORATION
Address:  5-1-1 OFUNA KAMAKURA 247, JAPAN
PHONE:    +81-467-44-9084
E-mail:   toshi%isl.melco.co.jp@uunet.uu.net