diff options
-rw-r--r-- | miscutils/fbsplash.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index a0f7d0dc2..1ea5d8ebb 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c | |||
@@ -224,14 +224,26 @@ static void fb_drawimage(void) | |||
224 | theme_file = xfopen_stdin(G.image_filename); | 224 | theme_file = xfopen_stdin(G.image_filename); |
225 | head = xmalloc(256); | 225 | head = xmalloc(256); |
226 | 226 | ||
227 | // parse ppm header | 227 | /* parse ppm header |
228 | * - A ppm image’s magic number is the two characters "P6". | ||
229 | * - Whitespace (blanks, TABs, CRs, LFs). | ||
230 | * - A width, formatted as ASCII characters in decimal. | ||
231 | * - Whitespace. | ||
232 | * - A height, again in ASCII decimal. | ||
233 | * - Whitespace. | ||
234 | * - The maximum color value (Maxval), again in ASCII decimal. Must be | ||
235 | * less than 65536. | ||
236 | * - Newline or other single whitespace character. | ||
237 | * - A raster of Width * Height pixels in triplets of rgb | ||
238 | * in pure binary by 1 (or not implemented 2) bytes. | ||
239 | */ | ||
228 | while (1) { | 240 | while (1) { |
229 | if (fgets(head, 256, theme_file) == NULL | 241 | if (fgets(head, 256, theme_file) == NULL |
230 | /* do not overrun the buffer */ | 242 | /* do not overrun the buffer */ |
231 | || strlen(bb_common_bufsiz1) >= sizeof(bb_common_bufsiz1) - 256) | 243 | || strlen(bb_common_bufsiz1) >= sizeof(bb_common_bufsiz1) - 256) |
232 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); | 244 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); |
233 | 245 | ||
234 | ptr = memchr(head, '#', 256); | 246 | ptr = memchr(skip_whitespace(head), '#', 256); |
235 | if (ptr != NULL) | 247 | if (ptr != NULL) |
236 | *ptr = 0; /* ignore comments */ | 248 | *ptr = 0; /* ignore comments */ |
237 | strcat(bb_common_bufsiz1, head); | 249 | strcat(bb_common_bufsiz1, head); |