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
48}48}
49 49
50static int50static int
51pjwit(int f, char *s, int scale)51pjwit(int f, char *s, int ssz, int scale)
52{52{
53 SDL_Surface *g, *line;53 SDL_Surface *g, *line;
54 int dummy, advance, r;54 int dummy, advance, r;
@@ -79,13 +79,13 @@ pjwit(int f, char *s, int scale) · 24 unmodified lines
79 if(b == NULL)79 if(b == NULL)
80 goto err;80 goto err;
81 81
82 sprintf(s, "%s.%X-%X", opath, 0, 0);82 snprintf(s, ssz, "%s.%X-%X", opath, 0, 0);
83 memset(&fc, 0, sizeof(fc));83 memset(&fc, 0, sizeof(fc));
84 fc.width = advance;84 fc.width = advance;
85 fc.bottom = line->h;85 fc.bottom = line->h;
86 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)86 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)
87 goto err2;87 goto err2;
88 sprintf(s, "%s.%X-%X", opath, Substitute, Substitute);88 snprintf(s, ssz, "%s.%X-%X", opath, Substitute, Substitute);
89 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)89 if(savesubfont(b, line->w, line->h, TTF_FontAscent(pf), 1, &fc, 1, s) != 0)
90 goto err2;90 goto err2;
91 91
@@ -110,7 +110,7 @@ err2: · 18 unmodified lines
110int110int
111main(int argc, char **argv)111main(int argc, char **argv)
112{112{
113 int c, optend, nr, i, fdfont;113 int c, optend, nr, i, fdfont, ssz;
114 int minx, maxx, advance, dummy, w, h, maxh, pjwface, hdr, scale;114 int minx, maxx, advance, dummy, w, h, maxh, pjwface, hdr, scale;
115 struct parg_state ps;115 struct parg_state ps;
116 Range *ranges, *rn;116 Range *ranges, *rn;
@@ -206,8 +206,8 @@ usage: · 89 unmodified lines
206 opath = argv[argc-1];206 opath = argv[argc-1];
207 207
208 i = strlen(opath);208 i = strlen(opath);
209 s = malloc(i+64);209 s = malloc(ssz = i+64);
210 sprintf(s, "%s.font", opath);210 snprintf(s, ssz, "%s.font", opath);
211 211
212 if((prefix = strrchr(s, '/')) == NULL)212 if((prefix = strrchr(s, '/')) == NULL)
213 prefix = s;213 prefix = s;
@@ -346,7 +346,7 @@ done: · 132 unmodified lines
346 dst.x += advance;346 dst.x += advance;
347 SDL_FreeSurface(g);347 SDL_FreeSurface(g);
348 }348 }
349 sprintf(s, "%s.%X-%X", opath, rn->min, rn->max);349 snprintf(s, ssz, "%s.%X-%X", opath, rn->min, rn->max);
350 b = surf2k8(line);350 b = surf2k8(line);
351 if(savesubfont(b, line->w, line->h, TTF_FontAscent(f), scale, cs, ncs, s) != 0)351 if(savesubfont(b, line->w, line->h, TTF_FontAscent(f), scale, cs, ncs, s) != 0)
352 return 1;352 return 1;
@@ -360,7 +360,7 @@ done: · 7 unmodified lines
360 }360 }
361 361
362 if(pjwface)362 if(pjwface)
363 pjwit(fdfont, s, scale);363 pjwit(fdfont, s, ssz, scale);
364 364
365 /* actual height of the font might be slightly different, so rewrite it */365 /* actual height of the font might be slightly different, so rewrite it */
366 lseek(fdfont, 0, 0);366 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