9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: yaroslav <yarikos@gmail.com>
To: 9fans@9fans.net
Subject: [9fans] bug in topng(1)
Date: Mon, 24 Dec 2012 14:27:46 +0200	[thread overview]
Message-ID: <3c86a4fb63baedd9ccb7697326b7f3d7@isd.dp.ua> (raw)

There's a bug in topng(1) which under certain circumstances may result in
broken output image.  When such an image then is fed to png(1)
diagnostics like the following are produced:

	term% png /tmp/1.png
	png: unknown filtering scheme 49

(The filtering scheme number may differ.)

This happens when at the beginning of an input line (z->x == 0) there
are only room for exactly one pixel in output buffer (b+pixwids == e),
at /sys/src/cmd/jpg/writepng.c:/^zread/+/while/.

Since every scan line should start with a filter algorithm ID it
consumes a byte in the buffer, leaving no room for the pixel.  The
"pixels" variable turns zero, no pixels are emitted, yet the alg byte
slips out.  During next run of zread() with empty buffer, the alg byte
is emitted again, causing permanent skew of output bytes.

The proposed fix is to modify the loop condition so the loop won't
proceed if there are not enough room for at least one pixel plus a
byte for the filter alg ID.

Submitted /n/sources/patch/topng-extrabyte/.

- yk




             reply	other threads:[~2012-12-24 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24 12:27 yaroslav [this message]
2012-12-24 14:07 Erik Quanstrom
2012-12-24 17:45 ` cinap_lenrek
2012-12-24 20:01   ` erik quanstrom
2012-12-25  1:49     ` cinap_lenrek
2012-12-25 13:39       ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c86a4fb63baedd9ccb7697326b7f3d7@isd.dp.ua \
    --to=yarikos@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).