[BusyBox] [BusyBox 0000191]: memcpy used on overlapping areas in shell/cmdedit.c
bugs at busybox.net
bugs at busybox.net
Thu Mar 24 10:58:00 UTC 2005
The following issue has been SUBMITTED.
======================================================================
<http://busybox.net/bugs/view.php?id=191>
======================================================================
Reported By: hornet
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 191
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 03-24-2005 02:58 PST
Last Modified: 03-24-2005 02:58 PST
======================================================================
Summary: memcpy used on overlapping areas in shell/cmdedit.c
Description:
Using busybox on SH4 platform (STi5528, http://www.superhlinux.com) ash
crashes during TAB command line completion (always if used as parameter
completion, rarely as command completion).
There is macro in shell/cmdedit.c:
#define collapse_pos(is, in) { \
memcopy(int_buf+(is), int_buf+(in),
(BUFSIZ+1-(is)-(in))*sizeof(int)); \
memcopy(pos_buf+(is), pos_buf+(in),
(BUFSIZ+1-(is)-(in))*sizeof(int)); }
Meantime it is written in memcopy manual:
The memcpy() function copies n bytes from memory area src to memory area
dest. THE MEMORY AREAS MAY NOT OVERLAP. Use memmove(3) if the memory
areas do overlap.
So, the correct macro is:
#define collapse_pos(is, in) { \
memmove(int_buf+(is), int_buf+(in),
(BUFSIZ+1-(is)-(in))*sizeof(int)); \
memmove(pos_buf+(is), pos_buf+(in),
(BUFSIZ+1-(is)-(in))*sizeof(int)); }
And it solves the problem :-)
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
03-24-05 02:58 hornet New Issue
======================================================================
More information about the busybox
mailing list