$OpenBSD: patch-gpal_codegen_c,v 1.1 2004/01/30 01:01:11 naddy Exp $ --- gpal/codegen.c.orig 2004-01-07 17:35:53.000000000 +1100 +++ gpal/codegen.c 2004-01-26 10:49:18.000000000 +1100 @@ -74,7 +74,7 @@ codegen_write_asm(const char *format, .. char buffer[BUFSIZ]; va_start(args, format); - vsprintf(buffer, format, args); + vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); fprintf(state.output.f, " %s\n", buffer); @@ -89,7 +89,7 @@ codegen_write_comment(const char *format char buffer[BUFSIZ]; va_start(args, format); - vsprintf(buffer, format, args); + vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); fprintf(state.output.f, "; %s\n", buffer); @@ -107,7 +107,7 @@ char * codegen_next_label(void) { char label[BUFSIZ]; - sprintf(label, "_%i", label_number++); + snprintf(label, sizeof(label), "_%i", label_number++); return strdup(label); } @@ -517,7 +517,7 @@ codegen_get_temp(enum size_tag size) { char temp_name[BUFSIZ]; - sprintf(temp_name, "_%s_temp_%d", FILE_NAME(state.module), temp_number); + snprintf(temp_name, sizeof(temp_name), "_%s_temp_%d", FILE_NAME(state.module), temp_number); temp_number += prim_size(size); @@ -534,8 +534,8 @@ codegen_init_asm() char buffer[BUFSIZ]; /* open output filename */ - strcpy(state.asmfilename, state.basefilename); - strcat(state.asmfilename, ".asm"); + strlcpy(state.asmfilename, state.basefilename, sizeof(state.asmfilename)); + strlcat(state.asmfilename, ".asm", sizeof(state.asmfilename)); state.output.f = fopen(state.asmfilename, "w"); if (state.output.f == NULL) { perror(state.asmfilename); @@ -548,7 +548,7 @@ codegen_init_asm() codegen_size = size_uint8; codegen_bytes = prim_size(codegen_size); - gp_date_string(buffer); + gp_date_string(buffer, sizeof(buffer)); fprintf(state.output.f, "; %s\n", state.asmfilename); fprintf(state.output.f, "; generated by %s on %s\n\n",