Use memmove instead of memcpy for overlapping memory area. (reproducible on OpenBSD).

This commit is contained in:
Renaud 2022-08-26 11:16:45 +08:00
parent 737fee5323
commit 041210b228
6 changed files with 13 additions and 15 deletions

View File

@ -1,7 +1,7 @@
# README #
µEMACS (ue) on Cygwin/Linux/NetBSD, based on uEmacs/PK (em) from [kernel.org](
https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).
µEMACS (ue) on Cygwin/MSYS2/Linux/NetBSD/OpenBSD, based on uEmacs/PK (em)
from [kernel.org](https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).
### Changes compare to uEmacs/PK ###
@ -26,6 +26,6 @@ https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).
### How to build ###
* dependencies: gcc, gmake, ncurses-devel.
* dependencies: (gcc || clang) && gmake && ncurses-devel.
* make

View File

@ -4,7 +4,7 @@
#if __unix__ || (defined(__APPLE__) && defined(__MACH__))
# define UNIX 1
# if __NetBSD__ || (defined(__APPLE__) && defined(__MACH__))
# if __NetBSD__ || __OpenBSD__ || (defined(__APPLE__) && defined(__MACH__))
# define BSD 1
# define POSIX 1
# elif __linux__

6
exec.c
View File

@ -557,9 +557,7 @@ static int dobuf( buffer_p bp) {
/* remove leading spaces */
if( eline != lp->l_text) {
int size = lp->l_used = eol - eline ;
if( size)
memcpy( lp->l_text, eline, size) ;
memmove( lp->l_text, eline, size) ;
eline = lp->l_text ;
eol = &lp->l_text[ size] ;
}
@ -595,7 +593,7 @@ static int dobuf( buffer_p bp) {
/* turn line into a string */
int size = lp->l_used - 6 ;
if( size)
memcpy( lp->l_text, &eline[ 6], size) ;
memmove( lp->l_text, &eline[ 6], size) ;
eline = lp->l_text ;
eline[ size] = 0 ;

2
line.c
View File

@ -455,7 +455,7 @@ boolean lnewline( void) {
memcpy( lp2->l_text, lp1->l_text, doto) ;
lp1->l_used -= doto ;
memcpy( lp1->l_text, &lp1->l_text[ doto], lp1->l_used) ;
memmove( lp1->l_text, &lp1->l_text[ doto], lp1->l_used) ;
lp2->l_fp = lp1 ;
lp2->l_bp = lp1->l_bp ;
lp1->l_bp = lp2 ;

View File

@ -12,11 +12,7 @@
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <errno.h>
#include "util.h"

View File

@ -31,8 +31,12 @@ int ttcol = -1 ; /* Column location of HW cursor */
/* Define missing macroes for BSD and CYGWIN environment */
#if BSD
#define OLCUC 0000002
#define XCASE 0000004
# ifndef OLCUC
# define OLCUC 0000002
# endif
# ifndef XCASE
# define XCASE 0000004
# endif
#endif
#ifdef __CYGWIN__ /* gcc predefined (see cpp -dM) */