$OpenBSD: patch-gpasm_scan_l,v 1.2 2004/01/30 01:01:11 naddy Exp $ --- gpasm/scan.l.orig 2004-01-21 17:17:52.000000000 +1100 +++ gpasm/scan.l 2004-01-25 20:36:31.000000000 +1100 @@ -86,8 +86,7 @@ end { [^<"\r\n]*[>"]? { /* got the title text */ #define LEN sizeof(state.lst.title_name) yytext[yyleng - 1] = '\0'; - strncpy(state.lst.title_name, yytext, LEN - 1); - state.lst.title_name[LEN - 1] = '\0'; + strlcpy(state.lst.title_name, yytext, LEN); BEGIN(INITIAL); #undef LEN } @@ -97,8 +96,7 @@ end { <subtitle>[^<"\r\n]*[>"]? { /* got the subtitle text */ #define LEN sizeof(state.lst.subtitle_name) yytext[yyleng - 1] = '\0'; - strncpy(state.lst.subtitle_name, yytext, LEN - 1); - state.lst.subtitle_name[LEN - 1] = '\0'; + strlcpy(state.lst.subtitle_name, yytext, LEN); BEGIN(INITIAL); #undef LEN } @@ -468,9 +466,9 @@ search_pathes(struct source_context *new int i; for(i = 0; i < state.path_num; i++) { - strcpy(tryname, state.paths[i]); - strcat(tryname, COPY_CHAR); - strcat(tryname, name); + strlcpy(tryname, state.paths[i], sizeof(tryname)); + strlcat(tryname, COPY_CHAR, sizeof(tryname)); + strlcat(tryname, name, sizeof(tryname)); new->f = fopen(tryname, "rt"); if(new->f) { new->name = strdup(tryname); @@ -516,7 +514,7 @@ void open_src(char *name, int isinclude) if (state.src) { char complaint[BUFSIZ]; - sprintf(complaint, + snprintf(complaint, sizeof(complaint), "Unable to open file \"%s\" - %s", name, strerror(errno));