mhl: added mhl_strmove() function (memmove semantics)
commite48cb7c89ff3e54de70130a3de2136a9902a023d
authorSergei Trofimovich <st@anti-virus.by>
Fri, 30 Jan 2009 07:31:28 +0000 (30 09:31 +0200)
committerSergei Trofimovich <st@anti-virus.by>
Fri, 30 Jan 2009 07:31:28 +0000 (30 09:31 +0200)
treef3c6b9a4ecd2c59c5a1aac5b233d909787c497b6
parent17772239ff7ff6b2ce2fc4af8801a203bb757b13
mhl: added mhl_strmove() function (memmove semantics)

valgrind detected an error in completion path:
==2962== Source and destination overlap in strcpy(0x459F068, 0x459F06A)
==2962==    at 0x4026056: strcpy (mc_replace_strmem.c:268)
==2962==    by 0x808F70B: canonicalize_pathname (string3.h:106)
==2962==    by 0x805ECBA: filename_completion_function (complete.c:125)
==2962==    by 0x805FB35: command_completion_function (complete.c:448)
==2962==    by 0x805EA34: completion_matches (complete.c:552)
==2962==    by 0x8060454: complete (complete.c:735)
==2962==    by 0x809AAC4: handle_char (widget.c:1545)
==2962==    by 0x807867E: midnight_callback (dialog.h:201)
==2962==    by 0x8061B27: dlg_process_event (dialog.c:664)
==2962==    by 0x8061ECE: run_dlg (dialog.c:786)
==2962==    by 0x807996C: main (main.c:1674)

Snippet of man strcpy:
DESCRIPTION
       The  strcpy()  function copies the string pointed to by src, including the terminating
       null byte ('\0'), to the buffer pointed to by dest.  ___The strings may not overlap___,
       and the destination string dest must be  large enough to receive the copy.
We used strcpy to move data chunk in memory: "./foo" -> "foo", etc.

This patch introduces mhl_strmove and fixed canonicalize_pathname.

Signed-off-by: Sergei Trofimovich <st@anti-virus.by>
mhl/string.h
src/utilunix.c