File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
c/common/src/codingstandards/c Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,10 @@ module OOB {
8282 dst = - 1 and
8383 src = [ 0 , 1 ]
8484 or
85- name = "strtok" and
86- dst = 0 and
87- src = 1
85+ // do not specify a src and dst to avoid buffer size assumptions
86+ name = [ "strtok" , "strtok_r" ] and
87+ dst = - 1 and
88+ src = [ 0 , 1 ]
8889 )
8990 }
9091
@@ -479,6 +480,18 @@ module OOB {
479480 }
480481 }
481482
483+ /**
484+ * A `BufferAccessLibraryFunction` modelling `strtok`
485+ */
486+ class StrtokLibraryFunction extends BufferAccessLibraryFunction {
487+ StrtokLibraryFunction ( ) { this .getName ( ) = getNameOrInternalName ( [ "strtok" , "strtok_r" ] ) }
488+
489+ override predicate getAPermissiblyNullParameterIndex ( int i ) {
490+ // `strtok` does not require a non-null `str` parameter
491+ i = 0
492+ }
493+ }
494+
482495 /**
483496 * An construction of a pointer to a buffer.
484497 */
You can’t perform that action at this time.
0 commit comments