Page MenuHomeFreeBSD

indent: Fix buffer overflow
ClosedPublic

Authored by des on Aug 7 2025, 4:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 22, 12:49 PM
Unknown Object (File)
Sun, Sep 21, 2:21 AM
Unknown Object (File)
Sat, Sep 20, 5:34 PM
Unknown Object (File)
Fri, Sep 19, 12:42 PM
Unknown Object (File)
Mon, Sep 15, 7:50 AM
Unknown Object (File)
Sep 1 2025, 12:05 PM
Unknown Object (File)
Aug 28 2025, 2:04 AM
Unknown Object (File)
Aug 20 2025, 11:47 PM
Subscribers

Details

Summary

The function used to create a backup of the input before starting work
used a static buffer and did not check that the file name it constructed
did not overflow. Switch to using asprintf(), clean up the rest of the
function, and update some comments that still referred to an earlier
version of the code.

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Aug 7 2025, 4:35 PM
bnovkov added inline comments.
usr.bin/indent/indent.c
1270

Shouldn't we free bakfile before returning?

des marked an inline comment as done.Aug 7 2025, 6:28 PM
des added inline comments.
usr.bin/indent/indent.c
1270

yeah, it used to be global, but there's no reason to keep it around.

des marked an inline comment as done.Aug 7 2025, 6:28 PM
des changed the visibility from "Public (No Login Required)" to "Subscribers".Aug 7 2025, 6:59 PM
des changed the edit policy from "All Users" to "Subscribers".
This revision is now accepted and ready to land.Aug 7 2025, 10:02 PM
des changed the visibility from "Subscribers" to "Public (No Login Required)".Aug 7 2025, 10:51 PM
des changed the edit policy from "Subscribers" to "All Users".
This revision was automatically updated to reflect the committed changes.