aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2009-02-18 15:13:05 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2009-02-18 15:13:05 +0000
commit8dcb33c3eb97ca668f609baf790fc79ac3f9da1c (patch)
tree4275d103965ce4ce334fae7fad45dc324b461625
parente455f6ec27fe92aad98bb2097c8790ccdc0b12b5 (diff)
downloadbusybox-w32-8dcb33c3eb97ca668f609baf790fc79ac3f9da1c.tar.gz
busybox-w32-8dcb33c3eb97ca668f609baf790fc79ac3f9da1c.tar.bz2
busybox-w32-8dcb33c3eb97ca668f609baf790fc79ac3f9da1c.zip
- document ppm header and skip whitespace
-rw-r--r--miscutils/fbsplash.c16
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);