x11: fix out-of-bounds access in adopt_atoms() error handling
authorRan Benita <ran234@gmail.com>
Wed, 14 May 2014 08:44:29 +0000 (11:44 +0300)
committerRan Benita <ran234@gmail.com>
Wed, 14 May 2014 09:02:13 +0000 (12:02 +0300)
commite3f751be660e28e48d1477660e99e5456c864296
treed4d452ec22f68e60cfbb68cc4f6a49668775d77d
parent86cfef63ca9ae6ad01791e4a6ec73754e4a769d7
x11: fix out-of-bounds access in adopt_atoms() error handling

Two problems:

- `j` can be >= `SIZE`, and needs to be wrapped like in the rest of the
   code.

- `cookies[j % SIZE]` is not initialized if there's no atom in `from[j]`.

The is manifested when:

- We've already gone through one batch (>= 128 atoms) (in fact this
  cannot happen in call to `adopt_atoms` in the current code).

- An XCB request failed in the middle of a batch.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/x11/util.c