Title: Valid 1-bit and 4-bit indexed BMPs with `clrUsed` at 0 crash with `IndexDefect` · Issue #561 · treeform/pixie · GitHub
Open Graph Title: Valid 1-bit and 4-bit indexed BMPs with `clrUsed` at 0 crash with `IndexDefect` · Issue #561 · treeform/pixie
X Title: Valid 1-bit and 4-bit indexed BMPs with `clrUsed` at 0 crash with `IndexDefect` · Issue #561 · treeform/pixie
Description: src/pixie/fileformats/bmp.nim:77, src/pixie/fileformats/bmp.nim:80, and src/pixie/fileformats/bmp.nim:130 only synthesize a default palette size for 8-bit BMPs. Valid 1-bit and 4-bit indexed BMPs are allowed by the format to leave clrUse...
Open Graph Description: src/pixie/fileformats/bmp.nim:77, src/pixie/fileformats/bmp.nim:80, and src/pixie/fileformats/bmp.nim:130 only synthesize a default palette size for 8-bit BMPs. Valid 1-bit and 4-bit indexed BMPs a...
X Description: src/pixie/fileformats/bmp.nim:77, src/pixie/fileformats/bmp.nim:80, and src/pixie/fileformats/bmp.nim:130 only synthesize a default palette size for 8-bit BMPs. Valid 1-bit and 4-bit indexed BMPs a...
Opengraph URL: https://github.com/treeform/pixie/issues/561
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Valid 1-bit and 4-bit indexed BMPs with `clrUsed` at 0 crash with `IndexDefect`","articleBody":"[src/pixie/fileformats/bmp.nim:77](https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/bmp.nim#L77), [src/pixie/fileformats/bmp.nim:80](https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/bmp.nim#L80), and [src/pixie/fileformats/bmp.nim:130](https://github.com/treeform/pixie/blob/master/src/pixie/fileformats/bmp.nim#L130) only synthesize a default palette size for 8-bit BMPs. Valid 1-bit and 4-bit indexed BMPs are allowed by the format to leave `clrUsed` at 0, but this decoder leaves the palette empty and then indexes it during decode. Verified locally with a valid 1-bit BMP repro, which crashed with `IndexDefect`.\n\n\n```nim\n# Run: nim r --path:src pocs/bmp_1bit_default_palette_crash.nim\nimport pixie\n\nproc addLe16(data: var string, value: int) =\n data.add(char(value and 0xff))\n data.add(char((value shr 8) and 0xff))\n\nproc addLe32(data: var string, value: int) =\n data.add(char(value and 0xff))\n data.add(char((value shr 8) and 0xff))\n data.add(char((value shr 16) and 0xff))\n data.add(char((value shr 24) and 0xff))\n\nlet pixelDataOffset = 14 + 40 + 8\nlet fileSize = pixelDataOffset + 4\n\nvar payload = \"BM\"\npayload.addLe32(fileSize)\npayload.addLe16(0)\npayload.addLe16(0)\npayload.addLe32(pixelDataOffset)\n\npayload.addLe32(40) # BITMAPINFOHEADER\npayload.addLe32(1) # width\npayload.addLe32(1) # height\npayload.addLe16(1) # planes\npayload.addLe16(1) # 1-bit indexed BMP\npayload.addLe32(0) # BI_RGB\npayload.addLe32(4) # padded pixel data size\npayload.addLe32(0)\npayload.addLe32(0)\npayload.addLe32(0) # clrUsed = 0, meaning default palette size should apply\npayload.addLe32(0)\n\n# Valid 1-bit palette: black and white.\npayload.add(\"\\x00\\x00\\x00\\x00\")\npayload.add(\"\\xff\\xff\\xff\\x00\")\n\n# One white pixel, padded to a 4-byte row.\npayload.add(\"\\x80\\x00\\x00\\x00\")\n\necho \"parsing valid 1-bit BMP with clrUsed == 0\"\ndiscard decodeImage(payload)\n```","author":{"url":"https://github.com/hourianto","@type":"Person","name":"hourianto"},"datePublished":"2026-03-10T13:43:01Z","url":"https://github.com/treeform/pixie/issues/561"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a9b70ebc-6c4a-6451-2019-3470edbd3a9b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9982:9F770:756043:9F177A:6B04D032 |
| html-safe-nonce | f8ae06fd524f667d9114b161304b6af68d34159848fcf7c8072bf71aa43d340e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTgyOjlGNzcwOjc1NjA0Mzo5RjE3N0E6NkIwNEQwMzIiLCJ2aXNpdG9yX2lkIjoiODMyOTIzOTI0ODY4MzQ1NDUxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2fbda13f8ae5c90f6c8a7271d6e9a809a3eba766aeae9e15ee1826aa2ae2ee94 |
| hovercard-subject-tag | issue:4051909329 |
| github-keyboard-shortcuts | repository,source-code,file-tree,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/treeform/pixie/561/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9b7b3564f4c21de8a38833172d7ec1a28216a91385f70121c090fc345ca85d1e/treeform/pixie/issues/561 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9b7b3564f4c21de8a38833172d7ec1a28216a91385f70121c090fc345ca85d1e/treeform/pixie/issues/561 |
| og:image:alt | src/pixie/fileformats/bmp.nim:77, src/pixie/fileformats/bmp.nim:80, and src/pixie/fileformats/bmp.nim:130 only synthesize a default palette size for 8-bit BMPs. Valid 1-bit and 4-bit indexed BMPs a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hourianto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27ed421e5c2dac040a37529b5b9191edcc4a3de70521471e81fb4b4d9dc2aa7d |
| turbo-cache-control | no-preview |
| go-import | github.com/treeform/pixie git https://github.com/treeform/pixie.git |
| octolytics-dimension-user_id | 125948 |
| octolytics-dimension-user_login | treeform |
| octolytics-dimension-repository_id | 314427501 |
| octolytics-dimension-repository_nwo | treeform/pixie |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 314427501 |
| octolytics-dimension-repository_network_root_nwo | treeform/pixie |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63dc19014c621c67306d7899c04c78dcd0d95803 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width