use s*n*printf instead of sprintf

This commit is contained in:
Stefan Bühler 2021-09-15 15:12:45 +02:00
parent fc3baeef51
commit 38de80b9f1
2 changed files with 6 additions and 6 deletions

8
draw.c
View File

@ -97,11 +97,11 @@ static int dopcxreal(char *name,gfxset *gs) {
memset(gs,0,sizeof(gfxset));
ileft=0;
sprintf(tname,DATADIR "/%s",name);
snprintf(tname,sizeof(tname),DATADIR "/%s",name);
ihand=open(tname,O_RDONLY);
if(ihand<0) {
char tname2[260];
sprintf(tname2,"%s.pcx",tname);
snprintf(tname2,sizeof(tname2),"%s.pcx",tname);
ihand=open(tname2,O_RDONLY);
if(ihand<0)
return 1;
@ -258,7 +258,7 @@ static void bigscrprintf(char *str,...) {
va_list ap;
va_start(ap, str);
vsprintf(output,str,ap);
vsnprintf(output,sizeof(output),str,ap);
p=output;
for(;;) {
p2=p;
@ -407,7 +407,7 @@ void loadgfx() {
colorgs=gs+1;
for(i=0;i<MAXSETS;++i) {
sprintf(name,"%s%d",colorsetname,i);
snprintf(name,sizeof(name),"%s%d",colorsetname,i);
err=dopcx(name,colorgs+i);
if(err) continue;
}

4
menu.c
View File

@ -230,7 +230,7 @@ static void draw_host_game(void) {
for(i=0;i<MAXNETNODES;++i) {
if(!netnodes[i].used) continue;
name=netnodes[i].name;
sprintf(temp," %d %s",i+1,name);
snprintf(temp,sizeof(temp)," %d %s",i+1,name);
drawbigstring(M3X,M3Y+(i+2)*bigfontyspace,temp);
}
@ -288,7 +288,7 @@ static void drawjoinscreen(void) {
if(!netnodes[i].used) continue;
memmove(name,netnodes[i].name,16);
name[16]=0;
sprintf(temp," %d %s",i+1,name);
snprintf(temp,sizeof(temp)," %d %s",i+1,name);
drawbigstring(JX,JY+(i+1)*bigfontyspace,temp);
}
}