mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 23:36:23 -05:00
Avoid copy to buffer name using same source as destination to accomodate sensitive implementation of str(n)cpy.
This commit is contained in:
parent
19e33fef82
commit
7f8ab2d2a5
6
file.c
6
file.c
@ -283,8 +283,10 @@ int readin(const char *fname, boolean lockfl)
|
||||
return status ;
|
||||
|
||||
bp->b_flag &= ~(BFINVS | BFCHG);
|
||||
strncpy( bp->b_fname, fname, sizeof( fname_t) - 1) ;
|
||||
bp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
||||
if( fname != bp->b_fname) { /* Copy if source differs from destination */
|
||||
strncpy( bp->b_fname, fname, sizeof( fname_t) - 1) ;
|
||||
bp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
||||
}
|
||||
|
||||
/* let a user macro get hold of things...if he wants */
|
||||
execute(META | SPEC | 'R', FALSE, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user