Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-08-25
04:07 • Closed ticket [2562113fff]: strlen() audit plus 7 other changes artifact: 3b51586685 user: dgp
04:06 • Ticket [2562113fff]: 4 changes artifact: 2cdff70149 user: dgp
2009-02-03
21:20 • New ticket [2562113fff]. artifact: f190a71683 user: dgp

strlen() audit

Closed / Rejected2562113fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 17 years ago
Descriptionplain2009-02-03 21:20:19
dgphmmm... these days strlen() returns a size_t, doesn't it?
gpsyes
dgpso everywhere we have
dgpint numBytes = strlen(bytes);
dgpwe've got the potential for a value Tcl can't handle

ƎƎisn't size_t supposed to be a large unsigned type? (or am I misremembering?)
dgpAIUI, size_t is an unsigned integral type....
dgp...with enough range to hold the size of anything held in memory.
jenglishdgp - yes, but that's still safe as long as bytes == objPtr->bytes or something else that came from ckalloc().
ƎƎyeah. typically equivalent to unsigned long long, I think. (but not guaranteed)
dgpah, jenglish, thanks;  that should help quite a bit
dgpplain2009-08-25 04:06:59
didn't completely do this, but a quick skim
indicates the existing cases are 1) known short
strings; 2) things pulled from objPtr->bytes known
safe; and 3) things that trace back to a (char *)
argument passed into Tcl that we can blame on
the caller.

Closing this as a general bug.  Specific cases
that need more stringent checking can be raised in
a new report.
dgpplain2009-08-25 04:07:00
allow_comments - 1
Log in (anonymous is fine) to add a comment.