Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9886e4a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merge-master-next-20180913
2 parents bc0d4f1 + 6266d8b commit 9886e4a

20 files changed

Lines changed: 105 additions & 20 deletions

File tree

cpp/ql/src/Architecture/InappropriateIntimacy.cpp

Whitespace-only changes.

cpp/ql/src/Documentation/UncommentedFunction.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/ql/src/Likely Bugs/Arithmetic/BadCheckOdd.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/ql/src/Likely Bugs/Arithmetic/BitwiseSignCheck.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/ql/src/Likely Bugs/Memory Management/UnsafeUseOfStrcat.ql

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ predicate isEffectivelyConstAccess(VariableAccess a)
2929
)
3030
}
3131

32-
from FunctionCall fc, VariableAccess src
33-
where fc.getTarget().hasName("strcat") and
34-
src = fc.getArgument(1) and
35-
not src.getType() instanceof ArrayType and
32+
class StrcatSource extends VariableAccess {
33+
FunctionCall strcat;
34+
35+
StrcatSource() {
36+
strcat.getTarget().hasName("strcat") and
37+
this = strcat.getArgument(1)
38+
}
39+
40+
FunctionCall getStrcatCall() { result = strcat }
41+
}
42+
43+
from StrcatSource src
44+
where not src.getType() instanceof ArrayType and
3645
not exists(BufferSizeExpr bse |
3746
bse.getArg().(VariableAccess).getTarget() = src.getTarget()) and
3847
not isEffectivelyConstAccess(src)
39-
select fc, "Always check the size of the source buffer when using strcat."
48+
select src.getStrcatCall(), "Always check the size of the source buffer when using strcat."

cpp/ql/src/semmle/code/cpp/Declaration.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ abstract class Declaration extends Locatable, @declaration {
5656
// MemberFunction, MemberVariable, MemberType
5757
exists (Declaration m
5858
| m = this and
59+
not m instanceof EnumConstant and
5960
result = m.getDeclaringType().getQualifiedName() + "::" + m.getName())
6061
or
6162
exists (EnumConstant c

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,25 @@ class ArrayType extends DerivedType {
904904
ArrayType() { derivedtypes(underlyingElement(this),_,4,_) }
905905

906906
predicate hasArraySize() { arraysizes(underlyingElement(this),_,_,_) }
907+
908+
/**
909+
* Gets the number of elements in this array. Only has a result for arrays declared to be of a
910+
* constant size. See `getByteSize` for getting the number of bytes.
911+
*/
907912
int getArraySize() { arraysizes(underlyingElement(this),result,_,_) }
908913

914+
/**
915+
* Gets the byte size of this array. Only has a result for arrays declared to be of a constant
916+
* size. See `getArraySize` for getting the number of elements.
917+
*/
909918
int getByteSize() { arraysizes(underlyingElement(this),_,result,_) }
910919

911920
override int getAlignment() { arraysizes(underlyingElement(this), _, _, result) }
912921

913922
/**
914-
* Gets the size of this array (only valid for arrays declared to be of a constant
915-
* size, will fail for all others).
923+
* Gets the byte size of this array. Only has a result for arrays declared to be of a constant
924+
* size. This predicate is a synonym for `getByteSize`. See `getArraySize` for getting the number
925+
* of elements.
916926
*/
917927
override int getSize() {
918928
result = this.getByteSize()

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module InstructionSanity {
6363
* Holds if instruction `instr` has multiple operands with tag `tag`.
6464
*/
6565
query predicate duplicateOperand(Instruction instr, OperandTag tag) {
66-
count(instr.getOperand(tag)) > 1 and
66+
strictcount(instr.getOperand(tag)) > 1 and
6767
not tag instanceof UnmodeledUseOperand
6868
}
6969

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module InstructionSanity {
6363
* Holds if instruction `instr` has multiple operands with tag `tag`.
6464
*/
6565
query predicate duplicateOperand(Instruction instr, OperandTag tag) {
66-
count(instr.getOperand(tag)) > 1 and
66+
strictcount(instr.getOperand(tag)) > 1 and
6767
not tag instanceof UnmodeledUseOperand
6868
}
6969

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module InstructionSanity {
6363
* Holds if instruction `instr` has multiple operands with tag `tag`.
6464
*/
6565
query predicate duplicateOperand(Instruction instr, OperandTag tag) {
66-
count(instr.getOperand(tag)) > 1 and
66+
strictcount(instr.getOperand(tag)) > 1 and
6767
not tag instanceof UnmodeledUseOperand
6868
}
6969

0 commit comments

Comments
 (0)