History

openbsd whining: sprintf → snprintf

Sigrid Solveig Haflínudóttir committed 3 years ago

Commit dac34e41 parent 36fd7a51 file · +8 −8Browse files

Unified · Split

ttfs.c+8−8
@@ -48,7 +48,7 @@ surf2k8(SDL_Surface *s) · 47 unmodified lines
4848 }
4949
5050 static int
51−pjwit(int f, char *s, int scale)
51+pjwit(int f, char *s, int ssz, int scale)
5252 {
5353 SDL_Surface *g, *line;
5454 int dummy, advance, r;
@@ -79,13 +79,13 @@ pjwit(int f, char *s, int scale) · 24 unmodified lines
7979 if(b == NULL)
8080 goto err;
8181
82− sprintf(s, "%s.%X-%X", opath, 0, 0);
82+ snprintf(s, ssz, "%s.%X-%X", opath, 0, 0);
8383 memset(&fc, 0, sizeof(fc));
8484 fc.width = advance;
8585 fc.bottom = line->h;
8686 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)
8787 goto err2;
88− sprintf(s, "%s.%X-%X", opath, Substitute, Substitute);
88+ snprintf(s, ssz, "%s.%X-%X", opath, Substitute, Substitute);
8989 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)
9090 goto err2;
9191
@@ -110,7 +110,7 @@ err2: · 18 unmodified lines
110110 int
111111 main(int argc, char **argv)
112112 {
113− int c, optend, nr, i, fdfont;
113+ int c, optend, nr, i, fdfont, ssz;
114114 int minx, maxx, advance, dummy, w, h, maxh, pjwface, hdr, scale;
115115 struct parg_state ps;
116116 Range *ranges, *rn;
@@ -206,8 +206,8 @@ usage: · 89 unmodified lines
206206 opath = argv[argc-1];
207207
208208 i = strlen(opath);
209− s = malloc(i+64);
210− sprintf(s, "%s.font", opath);
209+ s = malloc(ssz = i+64);
210+ snprintf(s, ssz, "%s.font", opath);
211211
212212 if((prefix = strrchr(s, '/')) == NULL)
213213 prefix = s;
@@ -346,7 +346,7 @@ done: · 132 unmodified lines
346346 dst.x += advance;
347347 SDL_FreeSurface(g);
348348 }
349− sprintf(s, "%s.%X-%X", opath, rn->min, rn->max);
349+ snprintf(s, ssz, "%s.%X-%X", opath, rn->min, rn->max);
350350 b = surf2k8(line);
351351 if(savesubfont(b, line->w, line->h, TTF_FontAscent(f), scale, cs, ncs, s) != 0)
352352 return 1;
@@ -360,7 +360,7 @@ done: · 7 unmodified lines
360360 }
361361
362362 if(pjwface)
363− pjwit(fdfont, s, scale);
363+ pjwit(fdfont, s, ssz, scale);
364364
365365 /* actual height of the font might be slightly different, so rewrite it */
366366 lseek(fdfont, 0, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t