mirror of
https://github.com/rfivet/uemacs.git
synced 2025-02-20 06:57:11 -05:00
Review potential buffer overflow when prompting for (incremental-)search pattern.
This commit is contained in:
parent
cfed6fdddf
commit
ac267617ae
@ -209,7 +209,7 @@ static int isearch(int f, int n)
|
||||
start_over:
|
||||
|
||||
/* ask the user for the text of a pattern */
|
||||
col = promptpattern("ISearch: "); /* Prompt, remember the col */
|
||||
col = promptpattern( "I-Search") ; /* Prompt, remember the col */
|
||||
|
||||
cpos = 0; /* Start afresh */
|
||||
status = TRUE; /* Assume everything's cool */
|
||||
@ -432,7 +432,8 @@ static int promptpattern(char *prompt)
|
||||
{
|
||||
char tpat[NPAT + 20];
|
||||
|
||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||
strncpy( tpat, prompt, 8) ; /* copy prompt to output string */
|
||||
tpat[ 8] = '\0' ; /* only one pattern "I-Search" */
|
||||
strcat(tpat, " ("); /* build new prompt string */
|
||||
expandp(pat, &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
|
||||
strcat(tpat, ")<Meta>: ");
|
||||
|
6
search.c
6
search.c
@ -513,8 +513,7 @@ static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *p
|
||||
mcptr++;
|
||||
|
||||
for (;;) {
|
||||
c = nextch(&curline, &curoff,
|
||||
direct ^ REVERSE);
|
||||
(void) nextch( &curline, &curoff, direct ^ REVERSE) ;
|
||||
|
||||
if (amatch
|
||||
(mcptr, direct, &curline, &curoff)) {
|
||||
@ -699,7 +698,8 @@ static int readpattern(char *prompt, char *apat, int srch)
|
||||
int status;
|
||||
char tpat[NPAT + 20];
|
||||
|
||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||
strncpy( tpat, prompt, 14) ; /* copy prompt to output string */
|
||||
tpat[ 14] = '\0' ; /* longest prompt is "Reverse Search" */
|
||||
strcat(tpat, " ("); /* build new prompt string */
|
||||
expandp(&apat[0], &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
|
||||
strcat(tpat, ")<Meta>: ");
|
||||
|
Loading…
x
Reference in New Issue
Block a user