Open Bug 177336 Opened 23 years ago Updated 3 years ago

File name buffer may not be large enough

Categories

(NSPR :: NSPR, defect)

PowerPC
macOS
defect

Tracking

(Not tracked)

People

(Reporter: wtc, Unassigned)

Details

In mozilla/nsprpub/pr/src/linking/prlink.c, we have: char cName[64]; ... FSSpec fileSpec; ... memcpy(cName, fileSpec.name + 1, fileSpec.name[0]); cName[fileSpec.name[0]] = '\0'; The FSSpec structure is defined as: struct FSSpec { SInt16 vRefNum; SInt32 parID; StrFileName name; }; and StrFileName is defined as: typedef Str255 StrFileName; This seems to mean that fileSpec.name can be 255 character long, and the cName buffer, which can only hold a 63 character string, may not be large enough. Is my understanding correct? If my understanding is correct, the fix would be: 1. Declare cName as: char cName[256]; 2. For extra protection, check that fileSpec.name[0] is less than 256 before copying fileSpec.name to cName.
File names in FSSpecs can be a max of 31 chars long, so the buffer will always be big enough, but we should play safe here.
Status: NEW → ASSIGNED
Actually StrFileName should be defined as a Str63 when building for Mac. It's a Str255 under Windows (thanks to QuickTime APIs being cross-platform)
QA Contact: wtchang → nspr
Assignee: sfraser_bugs → wtc

The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.

Assignee: wtc → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.