hn.today

Decode kernel panic from QR Code photo

gist.github.com29 points11 comments
Screenshot of Decode kernel panic from QR Code photo

A Python command-line utility extracts a Linux kernel panic log from a QR code in a screenshot or photo. It uses ZXingReader to scan the image and retrieve the QR code’s text, then parses the URL for a compressed-data parameter named “z.” The parameter may appear in either the URL query or fragment. Its decimal digits encode bytes in groups: each full 17-digit group represents seven little-endian bytes, while a final partial group can represent one to six bytes. The utility converts those groups back into compressed data and uses zlib to recover the log.

The decoded log is written to standard output by default or to a chosen file with the “-o” option; the example invocation saves it as panic.log. The script is designed to run locally without network access and requires Python 3 and ZXingReader available on the system PATH. It checks for missing image files, unreadable QR codes, malformed or repeated data parameters, invalid digit groups, decoding failures, and attempts to overwrite the input image, reporting errors to standard error. It also handles a broken output pipe gracefully, allowing the command to feed another program.

Read on gist.github.com11 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Spooky C++

Spooky C++

A C++ function returns a string_view into a temporary string, causing undefined behavior that lets optimized builds incorrectly grant root permissions. The bug reproduces with both Clang and GCC, illustrating how dangling references can produce surprising results. (nablag.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.