Opened 3 years ago

Closed 3 years ago

#7315 closed defect (fixed)

PDBio.cpp buffer overflow

Reported by: Tom Goddard Owned by: Eric Pettersen
Priority: moderate Milestone:
Component: Input/Output Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Noticed this nice warning on the Mac M1 build output.

pdbio_cpp/PDBio.cpp:262:17: warning: 'sprintf' will always overflow; destination buffer has size 4, but format string expands to at least 5 [-Wfortify-source]

std::sprintf(buffer, "%4d", ssbond_serial++);

Change History (2)

comment:1 by Eric Pettersen, 3 years ago

Status: assignedaccepted

comment:2 by Eric Pettersen, 3 years ago

Resolution: fixed
Status: acceptedclosed

Oooh, that _is_ nice. I didn't allocate space for the '\0' terminator in the buffer, though the bug would only actually have an effect for structures with 1000+ SSBONDs, so basically never.

fix: https://github.com/RBVI/ChimeraX/commit/b94a476dbc36216cb01de99c04b791311b4d354b

Note: See TracTickets for help on using tickets.