[krbdev.mit.edu #9305] [PATCH] Fix out-of-bounds read in read_primary_file()

Богдан Богуславский via RT rt-comment at krbdev.mit.edu
Wed Dec 2 19:08:04 EST 2026


Wed Dec 02 19:08:04 2026: Request 9305 was acted upon.
 Transaction: Ticket created by boguslavskijbj at basealt.ru
       Queue: krb5
     Subject: [PATCH] Fix out-of-bounds read in read_primary_file()
       Owner: Nobody
  Requestors: boguslavskijbj at basealt.ru
      Status: new
 Ticket <URL: https://krbdev.mit.edu/rt/Ticket/Display.html?id=9305 >


Hello,

The attached patch fixes an out-of-bounds read in read_primary_file(), 
which reads the primary file of a DIR: credential cache collection.

The function reads the first line into the stack buffer buf and stores 
its length in len. If the file starts with a null byte, fgets() returns 
buf, but strlen(buf) returns 0. The subsequent buf[len - 1] check then 
accesses buf[-1], one byte before the beginning of the buffer.

The patch adds a check for len == 0 before accessing the last character 
of the string.

Regards,
Bogdan Boguslavskij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Avoid-OOB-read-in-DIR-primary-file-parsing.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://mailman.mit.edu/pipermail/krb5-bugs/attachments/20261202/32b820ed/attachment.bin>


More information about the krb5-bugs mailing list