Skip to content

Commit e01f050

Browse files
committed
C++: QLDoc BufferWrite.qll.
1 parent dea9a13 commit e01f050

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cpp/ql/src/semmle/code/cpp/security/BufferWrite.qll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class StrCopyBW extends BufferWriteCall {
146146
)
147147
}
148148

149+
/**
150+
* Gets the index of the parameter that is the maximum size of the copy (in characters).
151+
*/
149152
int getParamSize() {
150153
exists(TopLevelFunction fn, string name |
151154
fn = getTarget() and
@@ -161,6 +164,9 @@ class StrCopyBW extends BufferWriteCall {
161164
)
162165
}
163166

167+
/**
168+
* Gets the index of the parameter that is the source of the copy.
169+
*/
164170
int getParamSrc() {
165171
exists(TopLevelFunction fn, string name |
166172
fn = getTarget() and
@@ -194,8 +200,14 @@ class StrCopyBW extends BufferWriteCall {
194200
class StrCatBW extends BufferWriteCall {
195201
StrCatBW() { exists(TopLevelFunction fn | fn = getTarget() and fn instanceof StrcatFunction) }
196202

203+
/**
204+
* Gets the index of the parameter that is the maximum size of the copy (in characters).
205+
*/
197206
int getParamSize() { if exists(getArgument(2)) then result = 2 else none() }
198207

208+
/**
209+
* Gets the index of the parameter that is the source of the copy.
210+
*/
199211
int getParamSrc() { result = 1 }
200212

201213
override Type getBufferType() {
@@ -349,6 +361,9 @@ class SnprintfBW extends BufferWriteCall {
349361
)
350362
}
351363

364+
/**
365+
* Gets the index of the parameter that is the size of the destination (in characters).
366+
*/
352367
int getParamSize() { result = 1 }
353368

354369
override Type getBufferType() {
@@ -399,6 +414,9 @@ class GetsBW extends BufferWriteCall {
399414
)
400415
}
401416

417+
/**
418+
* Gets the index of the parameter that is the maximum number of characters to be read.
419+
*/
402420
int getParamSize() { if exists(getArgument(1)) then result = 1 else none() }
403421

404422
override Type getBufferType() { result = this.getTarget().getParameter(0).getUnspecifiedType() }
@@ -434,6 +452,9 @@ class ScanfBW extends BufferWrite {
434452
)
435453
}
436454

455+
/**
456+
* Gets the index of the parameter that is the first format argument.
457+
*/
437458
int getParamArgs() {
438459
exists(FunctionCall fc |
439460
this = fc.getArgument(_) and

0 commit comments

Comments
 (0)