diff --git a/bind.c b/bind.c index 593306d..fbc3bff 100644 --- a/bind.c +++ b/bind.c @@ -352,7 +352,8 @@ static int buildlist( char *mstring) continue ; #endif /* add in the command name */ - strcpy(outseq, nptr->n_name); + strncpy( outseq, nptr->n_name, sizeof outseq - 1) ; + outseq[ sizeof outseq - 1] = '\0' ; cpos = strlen(outseq); /* search down any keys bound to this */ diff --git a/eval.c b/eval.c index f5f98ca..55b656e 100644 --- a/eval.c +++ b/eval.c @@ -796,9 +796,11 @@ int setvar(int f, int n) } /* get the value for that variable */ - if (f == TRUE) - strcpy(value, i_to_a(n)); - else { + if( f == TRUE) { + /* a bit overcautious here in using strncpy */ + strncpy( value, i_to_a( n), sizeof value - 1) ; + value[ sizeof value - 1] = '\0' ; + } else { status = mlreply( "Value: ", value, sizeof value); if (status != TRUE) return status; diff --git a/exec.c b/exec.c index 3dab6c9..bc49e3d 100644 --- a/exec.c +++ b/exec.c @@ -176,7 +176,8 @@ static int docmd( char *cline) { /* process leadin argument */ if( !is_it_cmd( tkn)) { f = TRUE; - strcpy(tkn, getval(tkn)); + strncpy( tkn, getval( tkn), sizeof tkn - 1) ; + tkn[ sizeof tkn - 1] = '\0' ; n = atoi(tkn); /* and now get the command to execute */ diff --git a/file.c b/file.c index 3b3dedf..ed868e2 100644 --- a/file.c +++ b/file.c @@ -325,7 +325,8 @@ int readin(const char *fname, boolean lockfl) if ((s = bclear(bp)) != TRUE) /* Might be old. */ return s; bp->b_flag &= ~(BFINVS | BFCHG); - strcpy(bp->b_fname, fname); + 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);