func
stringlengths 0
484k
| target
int64 0
1
| cwe
sequence | project
stringlengths 2
29
| commit_id
stringlengths 40
40
| hash
float64 1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
| size
int64 1
24k
| message
stringlengths 0
13.3k
|
---|---|---|---|---|---|---|---|
static int cuse_channel_release(struct inode *inode, struct file *file)
{
struct fuse_dev *fud = file->private_data;
struct cuse_conn *cc = fc_to_cc(fud->fc);
int rc;
/* remove from the conntbl, no more access from this point on */
mutex_lock(&cuse_lock);
list_del_init(&cc->list);
mutex_unlock(&cuse_lock);
/* remove device */
if (cc->dev)
device_unregister(cc->dev);
if (cc->cdev) {
unregister_chrdev_region(cc->cdev->dev, 1);
cdev_del(cc->cdev);
}
/* Base reference is now owned by "fud" */
fuse_conn_put(&cc->fc);
rc = fuse_dev_release(inode, file); /* puts the base reference */
return rc;
} | 0 | [
"CWE-399"
] | linux | 2c5816b4beccc8ba709144539f6fdd764f8fa49c | 133,335,029,805,109,830,000,000,000,000,000,000,000 | 25 | cuse: fix memory leak
The problem is that fuse_dev_alloc() acquires an extra reference to cc.fc,
and the original ref count is never dropped.
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
Cc: <stable@vger.kernel.org> # v4.2+ |
int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
Vdbe *v = pParse->pVdbe; /* The VM under construction */
int op; /* The opcode being coded */
int inReg = target; /* Results stored in register inReg */
int regFree1 = 0; /* If non-zero free this temporary register */
int regFree2 = 0; /* If non-zero free this temporary register */
int r1, r2; /* Various register numbers */
Expr tempX; /* Temporary expression node */
int p5 = 0;
assert( target>0 && target<=pParse->nMem );
if( v==0 ){
assert( pParse->db->mallocFailed );
return 0;
}
expr_code_doover:
if( pExpr==0 ){
op = TK_NULL;
}else{
op = pExpr->op;
}
switch( op ){
case TK_AGG_COLUMN: {
AggInfo *pAggInfo = pExpr->pAggInfo;
struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
if( !pAggInfo->directMode ){
assert( pCol->iMem>0 );
return pCol->iMem;
}else if( pAggInfo->useSortingIdx ){
sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,
pCol->iSorterColumn, target);
return target;
}
/* Otherwise, fall thru into the TK_COLUMN case */
}
case TK_COLUMN: {
int iTab = pExpr->iTable;
if( ExprHasProperty(pExpr, EP_FixedCol) ){
/* This COLUMN expression is really a constant due to WHERE clause
** constraints, and that constant is coded by the pExpr->pLeft
** expresssion. However, make sure the constant has the correct
** datatype by applying the Affinity of the table column to the
** constant.
*/
int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);
int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);
if( aff>SQLITE_AFF_BLOB ){
static const char zAff[] = "B\000C\000D\000E";
assert( SQLITE_AFF_BLOB=='A' );
assert( SQLITE_AFF_TEXT=='B' );
if( iReg!=target ){
sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);
iReg = target;
}
sqlite3VdbeAddOp4(v, OP_Affinity, iReg, 1, 0,
&zAff[(aff-'B')*2], P4_STATIC);
}
return iReg;
}
if( iTab<0 ){
if( pParse->iSelfTab<0 ){
/* Other columns in the same row for CHECK constraints or
** generated columns or for inserting into partial index.
** The row is unpacked into registers beginning at
** 0-(pParse->iSelfTab). The rowid (if any) is in a register
** immediately prior to the first column.
*/
Column *pCol;
Table *pTab = pExpr->y.pTab;
int iSrc;
int iCol = pExpr->iColumn;
assert( pTab!=0 );
assert( iCol>=XN_ROWID );
assert( iCol<pExpr->y.pTab->nCol );
if( iCol<0 ){
return -1-pParse->iSelfTab;
}
pCol = pTab->aCol + iCol;
testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) );
iSrc = sqlite3TableColumnToStorage(pTab, iCol) - pParse->iSelfTab;
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
if( pCol->colFlags & COLFLAG_GENERATED ){
if( pCol->colFlags & COLFLAG_BUSY ){
sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"",
pCol->zName);
return 0;
}
pCol->colFlags |= COLFLAG_BUSY;
if( pCol->colFlags & COLFLAG_NOTAVAIL ){
sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc);
}
pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL);
return iSrc;
}else
#endif /* SQLITE_OMIT_GENERATED_COLUMNS */
if( pCol->affinity==SQLITE_AFF_REAL ){
sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target);
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
return target;
}else{
return iSrc;
}
}else{
/* Coding an expression that is part of an index where column names
** in the index refer to the table to which the index belongs */
iTab = pParse->iSelfTab - 1;
}
}
return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,
pExpr->iColumn, iTab, target,
pExpr->op2);
}
case TK_INTEGER: {
codeInteger(pParse, pExpr, 0, target);
return target;
}
case TK_TRUEFALSE: {
sqlite3VdbeAddOp2(v, OP_Integer, sqlite3ExprTruthValue(pExpr), target);
return target;
}
#ifndef SQLITE_OMIT_FLOATING_POINT
case TK_FLOAT: {
assert( !ExprHasProperty(pExpr, EP_IntValue) );
codeReal(v, pExpr->u.zToken, 0, target);
return target;
}
#endif
case TK_STRING: {
assert( !ExprHasProperty(pExpr, EP_IntValue) );
sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
return target;
}
case TK_NULL: {
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
return target;
}
#ifndef SQLITE_OMIT_BLOB_LITERAL
case TK_BLOB: {
int n;
const char *z;
char *zBlob;
assert( !ExprHasProperty(pExpr, EP_IntValue) );
assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );
assert( pExpr->u.zToken[1]=='\'' );
z = &pExpr->u.zToken[2];
n = sqlite3Strlen30(z) - 1;
assert( z[n]=='\'' );
zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n);
sqlite3VdbeAddOp4(v, OP_Blob, n/2, target, 0, zBlob, P4_DYNAMIC);
return target;
}
#endif
case TK_VARIABLE: {
assert( !ExprHasProperty(pExpr, EP_IntValue) );
assert( pExpr->u.zToken!=0 );
assert( pExpr->u.zToken[0]!=0 );
sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
if( pExpr->u.zToken[1]!=0 ){
const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);
assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );
pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */
sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);
}
return target;
}
case TK_REGISTER: {
return pExpr->iTable;
}
#ifndef SQLITE_OMIT_CAST
case TK_CAST: {
/* Expressions of the form: CAST(pLeft AS token) */
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
if( inReg!=target ){
sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
inReg = target;
}
sqlite3VdbeAddOp2(v, OP_Cast, target,
sqlite3AffinityType(pExpr->u.zToken, 0));
return inReg;
}
#endif /* SQLITE_OMIT_CAST */
case TK_IS:
case TK_ISNOT:
op = (op==TK_IS) ? TK_EQ : TK_NE;
p5 = SQLITE_NULLEQ;
/* fall-through */
case TK_LT:
case TK_LE:
case TK_GT:
case TK_GE:
case TK_NE:
case TK_EQ: {
Expr *pLeft = pExpr->pLeft;
if( sqlite3ExprIsVector(pLeft) ){
codeVectorCompare(pParse, pExpr, target, op, p5);
}else{
r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1);
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
codeCompare(pParse, pLeft, pExpr->pRight, op,
r1, r2, inReg, SQLITE_STOREP2 | p5,
ExprHasProperty(pExpr,EP_Commuted));
assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);
assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);
assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);
assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);
assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);
assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);
testcase( regFree1==0 );
testcase( regFree2==0 );
}
break;
}
case TK_AND:
case TK_OR:
case TK_PLUS:
case TK_STAR:
case TK_MINUS:
case TK_REM:
case TK_BITAND:
case TK_BITOR:
case TK_SLASH:
case TK_LSHIFT:
case TK_RSHIFT:
case TK_CONCAT: {
assert( TK_AND==OP_And ); testcase( op==TK_AND );
assert( TK_OR==OP_Or ); testcase( op==TK_OR );
assert( TK_PLUS==OP_Add ); testcase( op==TK_PLUS );
assert( TK_MINUS==OP_Subtract ); testcase( op==TK_MINUS );
assert( TK_REM==OP_Remainder ); testcase( op==TK_REM );
assert( TK_BITAND==OP_BitAnd ); testcase( op==TK_BITAND );
assert( TK_BITOR==OP_BitOr ); testcase( op==TK_BITOR );
assert( TK_SLASH==OP_Divide ); testcase( op==TK_SLASH );
assert( TK_LSHIFT==OP_ShiftLeft ); testcase( op==TK_LSHIFT );
assert( TK_RSHIFT==OP_ShiftRight ); testcase( op==TK_RSHIFT );
assert( TK_CONCAT==OP_Concat ); testcase( op==TK_CONCAT );
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2);
sqlite3VdbeAddOp3(v, op, r2, r1, target);
testcase( regFree1==0 );
testcase( regFree2==0 );
break;
}
case TK_UMINUS: {
Expr *pLeft = pExpr->pLeft;
assert( pLeft );
if( pLeft->op==TK_INTEGER ){
codeInteger(pParse, pLeft, 1, target);
return target;
#ifndef SQLITE_OMIT_FLOATING_POINT
}else if( pLeft->op==TK_FLOAT ){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
codeReal(v, pLeft->u.zToken, 1, target);
return target;
#endif
}else{
tempX.op = TK_INTEGER;
tempX.flags = EP_IntValue|EP_TokenOnly;
tempX.u.iValue = 0;
r1 = sqlite3ExprCodeTemp(pParse, &tempX, ®Free1);
r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free2);
sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);
testcase( regFree2==0 );
}
break;
}
case TK_BITNOT:
case TK_NOT: {
assert( TK_BITNOT==OP_BitNot ); testcase( op==TK_BITNOT );
assert( TK_NOT==OP_Not ); testcase( op==TK_NOT );
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
testcase( regFree1==0 );
sqlite3VdbeAddOp2(v, op, r1, inReg);
break;
}
case TK_TRUTH: {
int isTrue; /* IS TRUE or IS NOT TRUE */
int bNormal; /* IS TRUE or IS FALSE */
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
testcase( regFree1==0 );
isTrue = sqlite3ExprTruthValue(pExpr->pRight);
bNormal = pExpr->op2==TK_IS;
testcase( isTrue && bNormal);
testcase( !isTrue && bNormal);
sqlite3VdbeAddOp4Int(v, OP_IsTrue, r1, inReg, !isTrue, isTrue ^ bNormal);
break;
}
case TK_ISNULL:
case TK_NOTNULL: {
int addr;
assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
testcase( regFree1==0 );
addr = sqlite3VdbeAddOp1(v, op, r1);
VdbeCoverageIf(v, op==TK_ISNULL);
VdbeCoverageIf(v, op==TK_NOTNULL);
sqlite3VdbeAddOp2(v, OP_Integer, 0, target);
sqlite3VdbeJumpHere(v, addr);
break;
}
case TK_AGG_FUNCTION: {
AggInfo *pInfo = pExpr->pAggInfo;
if( pInfo==0 ){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
}else{
return pInfo->aFunc[pExpr->iAgg].iMem;
}
break;
}
case TK_FUNCTION: {
ExprList *pFarg; /* List of function arguments */
int nFarg; /* Number of function arguments */
FuncDef *pDef; /* The function definition object */
const char *zId; /* The function name */
u32 constMask = 0; /* Mask of function arguments that are constant */
int i; /* Loop counter */
sqlite3 *db = pParse->db; /* The database connection */
u8 enc = ENC(db); /* The text encoding used by this database */
CollSeq *pColl = 0; /* A collating sequence */
#ifndef SQLITE_OMIT_WINDOWFUNC
if( ExprHasProperty(pExpr, EP_WinFunc) ){
return pExpr->y.pWin->regResult;
}
#endif
if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){
/* SQL functions can be expensive. So try to move constant functions
** out of the inner loop, even if that means an extra OP_Copy. */
return sqlite3ExprCodeAtInit(pParse, pExpr, -1);
}
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
if( ExprHasProperty(pExpr, EP_TokenOnly) ){
pFarg = 0;
}else{
pFarg = pExpr->x.pList;
}
nFarg = pFarg ? pFarg->nExpr : 0;
assert( !ExprHasProperty(pExpr, EP_IntValue) );
zId = pExpr->u.zToken;
pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
if( pDef==0 && pParse->explain ){
pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0);
}
#endif
if( pDef==0 || pDef->xFinalize!=0 ){
sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
break;
}
/* Attempt a direct implementation of the built-in COALESCE() and
** IFNULL() functions. This avoids unnecessary evaluation of
** arguments past the first non-NULL argument.
*/
if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
int endCoalesce = sqlite3VdbeMakeLabel(pParse);
assert( nFarg>=2 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
for(i=1; i<nFarg; i++){
sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
VdbeCoverage(v);
sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
}
sqlite3VdbeResolveLabel(v, endCoalesce);
break;
}
/* The UNLIKELY() function is a no-op. The result is the value
** of the first argument.
*/
if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){
assert( nFarg>=1 );
return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);
}
#ifdef SQLITE_DEBUG
/* The AFFINITY() function evaluates to a string that describes
** the type affinity of the argument. This is used for testing of
** the SQLite type logic.
*/
if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){
const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
char aff;
assert( nFarg==1 );
aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
sqlite3VdbeLoadString(v, target,
(aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]);
return target;
}
#endif
for(i=0; i<nFarg; i++){
if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
testcase( i==31 );
constMask |= MASKBIT32(i);
}
if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){
pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);
}
}
if( pFarg ){
if( constMask ){
r1 = pParse->nMem+1;
pParse->nMem += nFarg;
}else{
r1 = sqlite3GetTempRange(pParse, nFarg);
}
/* For length() and typeof() functions with a column argument,
** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
** loading.
*/
if( (pDef->funcFlags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
u8 exprOp;
assert( nFarg==1 );
assert( pFarg->a[0].pExpr!=0 );
exprOp = pFarg->a[0].pExpr->op;
if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){
assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
testcase( pDef->funcFlags & OPFLAG_LENGTHARG );
pFarg->a[0].pExpr->op2 =
pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);
}
}
sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,
SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);
}else{
r1 = 0;
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
/* Possibly overload the function if the first argument is
** a virtual table column.
**
** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the
** second argument, not the first, as the argument to test to
** see if it is a column in a virtual table. This is done because
** the left operand of infix functions (the operand we want to
** control overloading) ends up as the second argument to the
** function. The expression "A glob B" is equivalent to
** "glob(B,A). We want to use the A in "A glob B" to test
** for function overloading. But we use the B term in "glob(B,A)".
*/
if( nFarg>=2 && ExprHasProperty(pExpr, EP_InfixFunc) ){
pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);
}else if( nFarg>0 ){
pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);
}
#endif
if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){
if( !pColl ) pColl = db->pDfltColl;
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
}
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){
Expr *pArg = pFarg->a[0].pExpr;
if( pArg->op==TK_COLUMN ){
sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
}else
#endif
{
sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg,
pDef, pExpr->op2);
}
if( nFarg && constMask==0 ){
sqlite3ReleaseTempRange(pParse, r1, nFarg);
}
return target;
}
#ifndef SQLITE_OMIT_SUBQUERY
case TK_EXISTS:
case TK_SELECT: {
int nCol;
testcase( op==TK_EXISTS );
testcase( op==TK_SELECT );
if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
sqlite3SubselectError(pParse, nCol, 1);
}else{
return sqlite3CodeSubselect(pParse, pExpr);
}
break;
}
case TK_SELECT_COLUMN: {
int n;
if( pExpr->pLeft->iTable==0 ){
pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
}
assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
if( pExpr->iTable!=0
&& pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
){
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
pExpr->iTable, n);
}
return pExpr->pLeft->iTable + pExpr->iColumn;
}
case TK_IN: {
int destIfFalse = sqlite3VdbeMakeLabel(pParse);
int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
sqlite3VdbeResolveLabel(v, destIfFalse);
sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);
sqlite3VdbeResolveLabel(v, destIfNull);
return target;
}
#endif /* SQLITE_OMIT_SUBQUERY */
/*
** x BETWEEN y AND z
**
** This is equivalent to
**
** x>=y AND x<=z
**
** X is stored in pExpr->pLeft.
** Y is stored in pExpr->pList->a[0].pExpr.
** Z is stored in pExpr->pList->a[1].pExpr.
*/
case TK_BETWEEN: {
exprCodeBetween(pParse, pExpr, target, 0, 0);
return target;
}
case TK_SPAN:
case TK_COLLATE:
case TK_UPLUS: {
pExpr = pExpr->pLeft;
goto expr_code_doover; /* 2018-04-28: Prevent deep recursion. OSSFuzz. */
}
case TK_TRIGGER: {
/* If the opcode is TK_TRIGGER, then the expression is a reference
** to a column in the new.* or old.* pseudo-tables available to
** trigger programs. In this case Expr.iTable is set to 1 for the
** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn
** is set to the column of the pseudo-table to read, or to -1 to
** read the rowid field.
**
** The expression is implemented using an OP_Param opcode. The p1
** parameter is set to 0 for an old.rowid reference, or to (i+1)
** to reference another column of the old.* pseudo-table, where
** i is the index of the column. For a new.rowid reference, p1 is
** set to (n+1), where n is the number of columns in each pseudo-table.
** For a reference to any other column in the new.* pseudo-table, p1
** is set to (n+2+i), where n and i are as defined previously. For
** example, if the table on which triggers are being fired is
** declared as:
**
** CREATE TABLE t1(a, b);
**
** Then p1 is interpreted as follows:
**
** p1==0 -> old.rowid p1==3 -> new.rowid
** p1==1 -> old.a p1==4 -> new.a
** p1==2 -> old.b p1==5 -> new.b
*/
Table *pTab = pExpr->y.pTab;
int iCol = pExpr->iColumn;
int p1 = pExpr->iTable * (pTab->nCol+1) + 1
+ (iCol>=0 ? sqlite3TableColumnToStorage(pTab, iCol) : -1);
assert( pExpr->iTable==0 || pExpr->iTable==1 );
assert( iCol>=-1 && iCol<pTab->nCol );
assert( pTab->iPKey<0 || iCol!=pTab->iPKey );
assert( p1>=0 && p1<(pTab->nCol*2+2) );
sqlite3VdbeAddOp2(v, OP_Param, p1, target);
VdbeComment((v, "r[%d]=%s.%s", target,
(pExpr->iTable ? "new" : "old"),
(pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName)
));
#ifndef SQLITE_OMIT_FLOATING_POINT
/* If the column has REAL affinity, it may currently be stored as an
** integer. Use OP_RealAffinity to make sure it is really real.
**
** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
** floating point when extracting it from the record. */
if( iCol>=0 && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){
sqlite3VdbeAddOp1(v, OP_RealAffinity, target);
}
#endif
break;
}
case TK_VECTOR: {
sqlite3ErrorMsg(pParse, "row value misused");
break;
}
/* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions
** that derive from the right-hand table of a LEFT JOIN. The
** Expr.iTable value is the table number for the right-hand table.
** The expression is only evaluated if that table is not currently
** on a LEFT JOIN NULL row.
*/
case TK_IF_NULL_ROW: {
int addrINR;
u8 okConstFactor = pParse->okConstFactor;
addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
/* Temporarily disable factoring of constant expressions, since
** even though expressions may appear to be constant, they are not
** really constant because they originate from the right-hand side
** of a LEFT JOIN. */
pParse->okConstFactor = 0;
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
pParse->okConstFactor = okConstFactor;
sqlite3VdbeJumpHere(v, addrINR);
sqlite3VdbeChangeP3(v, addrINR, inReg);
break;
}
/*
** Form A:
** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END
**
** Form B:
** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END
**
** Form A is can be transformed into the equivalent form B as follows:
** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...
** WHEN x=eN THEN rN ELSE y END
**
** X (if it exists) is in pExpr->pLeft.
** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is
** odd. The Y is also optional. If the number of elements in x.pList
** is even, then Y is omitted and the "otherwise" result is NULL.
** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].
**
** The result of the expression is the Ri for the first matching Ei,
** or if there is no matching Ei, the ELSE term Y, or if there is
** no ELSE term, NULL.
*/
default: assert( op==TK_CASE ); {
int endLabel; /* GOTO label for end of CASE stmt */
int nextCase; /* GOTO label for next WHEN clause */
int nExpr; /* 2x number of WHEN terms */
int i; /* Loop counter */
ExprList *pEList; /* List of WHEN terms */
struct ExprList_item *aListelem; /* Array of WHEN terms */
Expr opCompare; /* The X==Ei expression */
Expr *pX; /* The X expression */
Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
Expr *pDel = 0;
sqlite3 *db = pParse->db;
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
assert(pExpr->x.pList->nExpr > 0);
pEList = pExpr->x.pList;
aListelem = pEList->a;
nExpr = pEList->nExpr;
endLabel = sqlite3VdbeMakeLabel(pParse);
if( (pX = pExpr->pLeft)!=0 ){
pDel = sqlite3ExprDup(db, pX, 0);
if( db->mallocFailed ){
sqlite3ExprDelete(db, pDel);
break;
}
testcase( pX->op==TK_COLUMN );
exprToRegister(pDel, exprCodeVector(pParse, pDel, ®Free1));
testcase( regFree1==0 );
memset(&opCompare, 0, sizeof(opCompare));
opCompare.op = TK_EQ;
opCompare.pLeft = pDel;
pTest = &opCompare;
/* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
** The value in regFree1 might get SCopy-ed into the file result.
** So make sure that the regFree1 register is not reused for other
** purposes and possibly overwritten. */
regFree1 = 0;
}
for(i=0; i<nExpr-1; i=i+2){
if( pX ){
assert( pTest!=0 );
opCompare.pRight = aListelem[i].pExpr;
}else{
pTest = aListelem[i].pExpr;
}
nextCase = sqlite3VdbeMakeLabel(pParse);
testcase( pTest->op==TK_COLUMN );
sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);
sqlite3VdbeGoto(v, endLabel);
sqlite3VdbeResolveLabel(v, nextCase);
}
if( (nExpr&1)!=0 ){
sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
sqlite3ExprDelete(db, pDel);
sqlite3VdbeResolveLabel(v, endLabel);
break;
}
#ifndef SQLITE_OMIT_TRIGGER
case TK_RAISE: {
assert( pExpr->affExpr==OE_Rollback
|| pExpr->affExpr==OE_Abort
|| pExpr->affExpr==OE_Fail
|| pExpr->affExpr==OE_Ignore
);
if( !pParse->pTriggerTab ){
sqlite3ErrorMsg(pParse,
"RAISE() may only be used within a trigger-program");
return 0;
}
if( pExpr->affExpr==OE_Abort ){
sqlite3MayAbort(pParse);
}
assert( !ExprHasProperty(pExpr, EP_IntValue) );
if( pExpr->affExpr==OE_Ignore ){
sqlite3VdbeAddOp4(
v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);
VdbeCoverage(v);
}else{
sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,
pExpr->affExpr, pExpr->u.zToken, 0, 0);
}
break;
}
#endif
}
sqlite3ReleaseTempReg(pParse, regFree1);
sqlite3ReleaseTempReg(pParse, regFree2);
return inReg;
} | 1 | [
"CWE-476"
] | sqlite | 57f7ece78410a8aae86aa4625fb7556897db384c | 103,274,332,561,532,090,000,000,000,000,000,000,000 | 739 | Fix a problem that comes up when using generated columns that evaluate to a
constant in an index and then making use of that index in a join.
FossilOrigin-Name: 8b12e95fec7ce6e0de82a04ca3dfcf1a8e62e233b7382aa28a8a9be6e862b1af |
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) {
mz_uint flags;
mz_uint8 *pLZ_codes;
mz_uint8 *pOutput_buf = d->m_pOutput_buf;
mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf;
mz_uint64 bit_buffer = d->m_bit_buffer;
mz_uint bits_in = d->m_bits_in;
#define TDEFL_PUT_BITS_FAST(b, l) \
{ \
bit_buffer |= (((mz_uint64)(b)) << bits_in); \
bits_in += (l); \
}
flags = 1;
for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end;
flags >>= 1) {
if (flags == 1) flags = *pLZ_codes++ | 0x100;
if (flags & 1) {
mz_uint s0, s1, n0, n1, sym, num_extra_bits;
mz_uint match_len = pLZ_codes[0],
match_dist = *(const mz_uint16 *)(pLZ_codes + 1);
pLZ_codes += 3;
MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]],
d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]],
s_tdefl_len_extra[match_len]);
// This sequence coaxes MSVC into using cmov's vs. jmp's.
s0 = s_tdefl_small_dist_sym[match_dist & 511];
n0 = s_tdefl_small_dist_extra[match_dist & 511];
s1 = s_tdefl_large_dist_sym[match_dist >> 8];
n1 = s_tdefl_large_dist_extra[match_dist >> 8];
sym = (match_dist < 512) ? s0 : s1;
num_extra_bits = (match_dist < 512) ? n0 : n1;
MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym],
d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits],
num_extra_bits);
} else {
mz_uint lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) {
flags >>= 1;
lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) {
flags >>= 1;
lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit],
d->m_huff_code_sizes[0][lit]);
}
}
}
if (pOutput_buf >= d->m_pOutput_buf_end) return MZ_FALSE;
*(mz_uint64 *)pOutput_buf = bit_buffer;
pOutput_buf += (bits_in >> 3);
bit_buffer >>= (bits_in & ~7);
bits_in &= 7;
}
#undef TDEFL_PUT_BITS_FAST
d->m_pOutput_buf = pOutput_buf;
d->m_bits_in = 0;
d->m_bit_buffer = 0;
while (bits_in) {
mz_uint32 n = MZ_MIN(bits_in, 16);
TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n);
bit_buffer >>= n;
bits_in -= n;
}
TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);
return (d->m_pOutput_buf < d->m_pOutput_buf_end);
} | 0 | [
"CWE-20",
"CWE-190"
] | tinyexr | a685e3332f61cd4e59324bf3f669d36973d64270 | 267,242,065,693,840,940,000,000,000,000,000,000,000 | 92 | Make line_no with too large value(2**20) invalid. Fixes #124 |
static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
union sctp_addr *addr,
int vparam_len)
{
sctp_addiphdr_t asconf;
struct sctp_chunk *retval;
int length = sizeof(asconf) + vparam_len;
union sctp_addr_param addrparam;
int addrlen;
struct sctp_af *af = sctp_get_af_specific(addr->v4.sin_family);
addrlen = af->to_addr_param(addr, &addrparam);
if (!addrlen)
return NULL;
length += addrlen;
/* Create the chunk. */
retval = sctp_make_control(asoc, SCTP_CID_ASCONF, 0, length);
if (!retval)
return NULL;
asconf.serial = htonl(asoc->addip_serial++);
retval->subh.addip_hdr =
sctp_addto_chunk(retval, sizeof(asconf), &asconf);
retval->param_hdr.v =
sctp_addto_chunk(retval, addrlen, &addrparam);
return retval;
} | 0 | [
"CWE-20",
"CWE-399"
] | linux | 9de7922bc709eee2f609cd01d98aaedc4cf5ea74 | 226,163,481,243,593,520,000,000,000,000,000,000,000 | 30 | net: sctp: fix skb_over_panic when receiving malformed ASCONF chunks
Commit 6f4c618ddb0 ("SCTP : Add paramters validity check for
ASCONF chunk") added basic verification of ASCONF chunks, however,
it is still possible to remotely crash a server by sending a
special crafted ASCONF chunk, even up to pre 2.6.12 kernels:
skb_over_panic: text:ffffffffa01ea1c3 len:31056 put:30768
head:ffff88011bd81800 data:ffff88011bd81800 tail:0x7950
end:0x440 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:129!
[...]
Call Trace:
<IRQ>
[<ffffffff8144fb1c>] skb_put+0x5c/0x70
[<ffffffffa01ea1c3>] sctp_addto_chunk+0x63/0xd0 [sctp]
[<ffffffffa01eadaf>] sctp_process_asconf+0x1af/0x540 [sctp]
[<ffffffff8152d025>] ? _read_unlock_bh+0x15/0x20
[<ffffffffa01e0038>] sctp_sf_do_asconf+0x168/0x240 [sctp]
[<ffffffffa01e3751>] sctp_do_sm+0x71/0x1210 [sctp]
[<ffffffff8147645d>] ? fib_rules_lookup+0xad/0xf0
[<ffffffffa01e6b22>] ? sctp_cmp_addr_exact+0x32/0x40 [sctp]
[<ffffffffa01e8393>] sctp_assoc_bh_rcv+0xd3/0x180 [sctp]
[<ffffffffa01ee986>] sctp_inq_push+0x56/0x80 [sctp]
[<ffffffffa01fcc42>] sctp_rcv+0x982/0xa10 [sctp]
[<ffffffffa01d5123>] ? ipt_local_in_hook+0x23/0x28 [iptable_filter]
[<ffffffff8148bdc9>] ? nf_iterate+0x69/0xb0
[<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff8148bf86>] ? nf_hook_slow+0x76/0x120
[<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff81496ded>] ip_local_deliver_finish+0xdd/0x2d0
[<ffffffff81497078>] ip_local_deliver+0x98/0xa0
[<ffffffff8149653d>] ip_rcv_finish+0x12d/0x440
[<ffffffff81496ac5>] ip_rcv+0x275/0x350
[<ffffffff8145c88b>] __netif_receive_skb+0x4ab/0x750
[<ffffffff81460588>] netif_receive_skb+0x58/0x60
This can be triggered e.g., through a simple scripted nmap
connection scan injecting the chunk after the handshake, for
example, ...
-------------- INIT[ASCONF; ASCONF_ACK] ------------->
<----------- INIT-ACK[ASCONF; ASCONF_ACK] ------------
-------------------- COOKIE-ECHO -------------------->
<-------------------- COOKIE-ACK ---------------------
------------------ ASCONF; UNKNOWN ------------------>
... where ASCONF chunk of length 280 contains 2 parameters ...
1) Add IP address parameter (param length: 16)
2) Add/del IP address parameter (param length: 255)
... followed by an UNKNOWN chunk of e.g. 4 bytes. Here, the
Address Parameter in the ASCONF chunk is even missing, too.
This is just an example and similarly-crafted ASCONF chunks
could be used just as well.
The ASCONF chunk passes through sctp_verify_asconf() as all
parameters passed sanity checks, and after walking, we ended
up successfully at the chunk end boundary, and thus may invoke
sctp_process_asconf(). Parameter walking is done with
WORD_ROUND() to take padding into account.
In sctp_process_asconf()'s TLV processing, we may fail in
sctp_process_asconf_param() e.g., due to removal of the IP
address that is also the source address of the packet containing
the ASCONF chunk, and thus we need to add all TLVs after the
failure to our ASCONF response to remote via helper function
sctp_add_asconf_response(), which basically invokes a
sctp_addto_chunk() adding the error parameters to the given
skb.
When walking to the next parameter this time, we proceed
with ...
length = ntohs(asconf_param->param_hdr.length);
asconf_param = (void *)asconf_param + length;
... instead of the WORD_ROUND()'ed length, thus resulting here
in an off-by-one that leads to reading the follow-up garbage
parameter length of 12336, and thus throwing an skb_over_panic
for the reply when trying to sctp_addto_chunk() next time,
which implicitly calls the skb_put() with that length.
Fix it by using sctp_walk_params() [ which is also used in
INIT parameter processing ] macro in the verification *and*
in ASCONF processing: it will make sure we don't spill over,
that we walk parameters WORD_ROUND()'ed. Moreover, we're being
more defensive and guard against unknown parameter types and
missized addresses.
Joint work with Vlad Yasevich.
Fixes: b896b82be4ae ("[SCTP] ADDIP: Support for processing incoming ASCONF_ACK chunks.")
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Vlad Yasevich <vyasevich@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net> |
box_poly(PG_FUNCTION_ARGS)
{
BOX *box = PG_GETARG_BOX_P(0);
POLYGON *poly;
int size;
/* map four corners of the box to a polygon */
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * 4;
poly = (POLYGON *) palloc(size);
SET_VARSIZE(poly, size);
poly->npts = 4;
poly->p[0].x = box->low.x;
poly->p[0].y = box->low.y;
poly->p[1].x = box->low.x;
poly->p[1].y = box->high.y;
poly->p[2].x = box->high.x;
poly->p[2].y = box->high.y;
poly->p[3].x = box->high.x;
poly->p[3].y = box->low.y;
box_fill(&poly->boundbox, box->high.x, box->low.x,
box->high.y, box->low.y);
PG_RETURN_POLYGON_P(poly);
} | 0 | [
"CWE-703",
"CWE-189"
] | postgres | 31400a673325147e1205326008e32135a78b4d8a | 239,521,768,776,852,450,000,000,000,000,000,000,000 | 27 | Predict integer overflow to avoid buffer overruns.
Several functions, mostly type input functions, calculated an allocation
size such that the calculation wrapped to a small positive value when
arguments implied a sufficiently-large requirement. Writes past the end
of the inadvertent small allocation followed shortly thereafter.
Coverity identified the path_in() vulnerability; code inspection led to
the rest. In passing, add check_stack_depth() to prevent stack overflow
in related functions.
Back-patch to 8.4 (all supported versions). The non-comment hstore
changes touch code that did not exist in 8.4, so that part stops at 9.0.
Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
Security: CVE-2014-0064 |
logger_start_buffer (struct t_gui_buffer *buffer, int write_info_line)
{
struct t_logger_buffer *ptr_logger_buffer;
int log_level, log_enabled;
if (!buffer)
return;
log_level = logger_get_level_for_buffer (buffer);
log_enabled = weechat_config_boolean (logger_config_file_auto_log)
&& (log_level > 0);
ptr_logger_buffer = logger_buffer_search_buffer (buffer);
/* logging is disabled for buffer */
if (!log_enabled)
{
/* stop logger if it is active */
if (ptr_logger_buffer)
logger_stop (ptr_logger_buffer, 1);
}
else
{
/* logging is enabled for buffer */
if (ptr_logger_buffer)
ptr_logger_buffer->log_level = log_level;
else
{
ptr_logger_buffer = logger_buffer_add (buffer, log_level);
if (ptr_logger_buffer)
{
if (ptr_logger_buffer->log_filename)
{
if (ptr_logger_buffer->log_file)
{
fclose (ptr_logger_buffer->log_file);
ptr_logger_buffer->log_file = NULL;
}
}
}
}
if (ptr_logger_buffer)
ptr_logger_buffer->write_start_info_line = write_info_line;
}
} | 0 | [
"CWE-119",
"CWE-787"
] | weechat | f105c6f0b56fb5687b2d2aedf37cb1d1b434d556 | 114,042,339,569,812,520,000,000,000,000,000,000,000 | 46 | logger: call strftime before replacing buffer local variables |
option_was_set(char_u *name)
{
int idx;
idx = findoption(name);
if (idx < 0) // unknown option
return FALSE;
if (options[idx].flags & P_WAS_SET)
return TRUE;
return FALSE;
} | 0 | [
"CWE-122"
] | vim | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | 241,576,788,501,647,620,000,000,000,000,000,000,000 | 11 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. |
handle_sysmouse(int sig GCC_UNUSED)
{
sysmouse_server(CURRENT_SCREEN);
} | 0 | [] | ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | 226,393,251,484,162,500,000,000,000,000,000,000,000 | 4 | ncurses 6.2 - patch 20200531
+ correct configure version-check/warnng for g++ to allow for 10.x
+ re-enable "bel" in konsole-base (report by Nia Huang)
+ add linux-s entry (patch by Alexandre Montaron).
+ drop long-obsolete convert_configure.pl
+ add test/test_parm.c, for checking tparm changes.
+ improve parameter-checking for tparm, adding function _nc_tiparm() to
handle the most-used case, which accepts only numeric parameters
(report/testcase by "puppet-meteor").
+ use a more conservative estimate of the buffer-size in lib_tparm.c's
save_text() and save_number(), in case the sprintf() function
passes-through unexpected characters from a format specifier
(report/testcase by "puppet-meteor").
+ add a check for end-of-string in cvtchar to handle a malformed
string in infotocap (report/testcase by "puppet-meteor"). |
pk_transaction_locked_changed_cb (PkBackendJob *job,
gboolean locked,
PkTransaction *transaction)
{
g_return_if_fail (PK_IS_TRANSACTION (transaction));
g_return_if_fail (transaction->priv->tid != NULL);
g_debug ("backend job lock status changed: %i", locked);
/* if backend cache is locked at some time, this transaction is running in exclusive mode */
if (locked)
pk_transaction_make_exclusive (transaction);
} | 0 | [
"CWE-287"
] | PackageKit | 7e8a7905ea9abbd1f384f05f36a4458682cd4697 | 260,364,231,728,047,920,000,000,000,000,000,000,000 | 13 | Do not set JUST_REINSTALL on any kind of auth failure
If we try to continue the auth queue when it has been cancelled (or failed)
then we fall upon the obscure JUST_REINSTALL transaction flag which only the
DNF backend actually verifies.
Many thanks to Matthias Gerstner <mgerstner@suse.de> for spotting the problem. |
static inline int shmem_parse_mpol(char *value, int *policy, nodemask_t *policy_nodes)
{
char *nodelist = strchr(value, ':');
int err = 1;
if (nodelist) {
/* NUL-terminate policy string */
*nodelist++ = '\0';
if (nodelist_parse(nodelist, *policy_nodes))
goto out;
if (!nodes_subset(*policy_nodes, node_states[N_HIGH_MEMORY]))
goto out;
}
if (!strcmp(value, "default")) {
*policy = MPOL_DEFAULT;
/* Don't allow a nodelist */
if (!nodelist)
err = 0;
} else if (!strcmp(value, "prefer")) {
*policy = MPOL_PREFERRED;
/* Insist on a nodelist of one node only */
if (nodelist) {
char *rest = nodelist;
while (isdigit(*rest))
rest++;
if (!*rest)
err = 0;
}
} else if (!strcmp(value, "bind")) {
*policy = MPOL_BIND;
/* Insist on a nodelist */
if (nodelist)
err = 0;
} else if (!strcmp(value, "interleave")) {
*policy = MPOL_INTERLEAVE;
/*
* Default to online nodes with memory if no nodelist
*/
if (!nodelist)
*policy_nodes = node_states[N_HIGH_MEMORY];
err = 0;
}
out:
/* Restore string for error message */
if (nodelist)
*--nodelist = ':';
return err;
} | 0 | [
"CWE-200"
] | linux-2.6 | e84e2e132c9c66d8498e7710d4ea532d1feaaac5 | 155,493,777,917,846,000,000,000,000,000,000,000,000 | 48 | tmpfs: restore missing clear_highpage
tmpfs was misconverted to __GFP_ZERO in 2.6.11. There's an unusual case in
which shmem_getpage receives the page from its caller instead of allocating.
We must cover this case by clear_highpage before SetPageUptodate, as before.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
static int session_call_on_header(nghttp2_session *session,
const nghttp2_frame *frame,
const nghttp2_hd_nv *nv) {
int rv = 0;
if (session->callbacks.on_header_callback2) {
rv = session->callbacks.on_header_callback2(
session, frame, nv->name, nv->value, nv->flags, session->user_data);
} else if (session->callbacks.on_header_callback) {
rv = session->callbacks.on_header_callback(
session, frame, nv->name->base, nv->name->len, nv->value->base,
nv->value->len, nv->flags, session->user_data);
}
if (rv == NGHTTP2_ERR_PAUSE || rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) {
return rv;
}
if (rv != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
return 0;
} | 0 | [] | nghttp2 | 0a6ce87c22c69438ecbffe52a2859c3a32f1620f | 1,579,521,267,944,471,700,000,000,000,000,000,000 | 22 | Add nghttp2_option_set_max_outbound_ack |
WandExport double DrawGetTextKerning(DrawingWand *wand)
{
assert(wand != (DrawingWand *) NULL);
assert(wand->signature == MagickWandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
return(CurrentContext->kerning);
} | 0 | [
"CWE-476"
] | ImageMagick | 6ad5fc3c9b652eec27fc0b1a0817159f8547d5d9 | 126,738,662,098,950,080,000,000,000,000,000,000,000 | 9 | https://github.com/ImageMagick/ImageMagick/issues/716 |
UnicodeString::moveIndex32(int32_t index, int32_t delta) const {
// pin index
int32_t len = length();
if(index<0) {
index=0;
} else if(index>len) {
index=len;
}
const UChar *array = getArrayStart();
if(delta>0) {
U16_FWD_N(array, index, len, delta);
} else {
U16_BACK_N(array, 0, index, -delta);
}
return index;
} | 0 | [
"CWE-190",
"CWE-787"
] | icu | b7d08bc04a4296982fcef8b6b8a354a9e4e7afca | 339,409,841,241,313,700,000,000,000,000,000,000,000 | 18 | ICU-20958 Prevent SEGV_MAPERR in append
See #971 |
static struct scatterlist *alloc_sgtable(int size)
{
int alloc_size, nents, i;
struct page *new_page;
struct scatterlist *iter;
struct scatterlist *table;
nents = DIV_ROUND_UP(size, PAGE_SIZE);
table = kcalloc(nents, sizeof(*table), GFP_KERNEL);
if (!table)
return NULL;
sg_init_table(table, nents);
iter = table;
for_each_sg(table, iter, sg_nents(table), i) {
new_page = alloc_page(GFP_KERNEL);
if (!new_page) {
/* release all previous allocated pages in the table */
iter = table;
for_each_sg(table, iter, sg_nents(table), i) {
new_page = sg_page(iter);
if (new_page)
__free_page(new_page);
}
return NULL;
}
alloc_size = min_t(int, size, PAGE_SIZE);
size -= PAGE_SIZE;
sg_set_page(iter, new_page, alloc_size, 0);
}
return table;
} | 1 | [
"CWE-400",
"CWE-401"
] | linux | b4b814fec1a5a849383f7b3886b654a13abbda7d | 155,226,500,233,023,100,000,000,000,000,000,000,000 | 31 | iwlwifi: dbg_ini: fix memory leak in alloc_sgtable
In alloc_sgtable if alloc_page fails, the alocated table should be
released.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com> |
GC_API void GC_CALL GC_incr_bytes_allocd(size_t n)
{
GC_bytes_allocd += n;
} | 0 | [
"CWE-189"
] | bdwgc | be9df82919960214ee4b9d3313523bff44fd99e1 | 236,693,931,674,642,980,000,000,000,000,000,000,000 | 4 | Fix allocation size overflows due to rounding.
* malloc.c (GC_generic_malloc): Check if the allocation size is
rounded to a smaller value.
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. |
int ssl3_send_client_certificate(SSL *s)
{
X509 *x509 = NULL;
EVP_PKEY *pkey = NULL;
int i;
if (s->state == SSL3_ST_CW_CERT_A) {
/* Let cert callback update client certificates if required */
if (s->cert->cert_cb) {
i = s->cert->cert_cb(s, s->cert->cert_cb_arg);
if (i < 0) {
s->rwstate = SSL_X509_LOOKUP;
return -1;
}
if (i == 0) {
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return 0;
}
s->rwstate = SSL_NOTHING;
}
if (ssl3_check_client_certificate(s))
s->state = SSL3_ST_CW_CERT_C;
else
s->state = SSL3_ST_CW_CERT_B;
}
/* We need to get a client cert */
if (s->state == SSL3_ST_CW_CERT_B) {
/*
* If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP;
* return(-1); We then get retied later
*/
i = 0;
i = ssl_do_client_cert_cb(s, &x509, &pkey);
if (i < 0) {
s->rwstate = SSL_X509_LOOKUP;
return (-1);
}
s->rwstate = SSL_NOTHING;
if ((i == 1) && (pkey != NULL) && (x509 != NULL)) {
s->state = SSL3_ST_CW_CERT_B;
if (!SSL_use_certificate(s, x509) || !SSL_use_PrivateKey(s, pkey))
i = 0;
} else if (i == 1) {
i = 0;
SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE,
SSL_R_BAD_DATA_RETURNED_BY_CALLBACK);
}
if (x509 != NULL)
X509_free(x509);
if (pkey != NULL)
EVP_PKEY_free(pkey);
if (i && !ssl3_check_client_certificate(s))
i = 0;
if (i == 0) {
if (s->version == SSL3_VERSION) {
s->s3->tmp.cert_req = 0;
ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_CERTIFICATE);
return (1);
} else {
s->s3->tmp.cert_req = 2;
}
}
/* Ok, we have a cert */
s->state = SSL3_ST_CW_CERT_C;
}
if (s->state == SSL3_ST_CW_CERT_C) {
s->state = SSL3_ST_CW_CERT_D;
if (!ssl3_output_cert_chain(s,
(s->s3->tmp.cert_req ==
2) ? NULL : s->cert->key)) {
SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE, ERR_R_INTERNAL_ERROR);
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return 0;
}
}
/* SSL3_ST_CW_CERT_D */
return ssl_do_write(s);
} | 0 | [
"CWE-310"
] | openssl | 10a70da729948bb573d27cef4459077c49f3eb46 | 247,363,252,675,717,740,000,000,000,000,000,000,000 | 84 | client: reject handshakes with DH parameters < 768 bits.
Since the client has no way of communicating her supported parameter
range to the server, connections to servers that choose weak DH will
simply fail.
Reviewed-by: Kurt Roeckx <kurt@openssl.org> |
void sctp_data_ready(struct sock *sk, int len)
{
struct socket_wq *wq;
rcu_read_lock();
wq = rcu_dereference(sk->sk_wq);
if (wq_has_sleeper(wq))
wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
POLLRDNORM | POLLRDBAND);
sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
rcu_read_unlock();
} | 0 | [
"CWE-20"
] | linux | 726bc6b092da4c093eb74d13c07184b18c1af0f1 | 68,683,894,906,860,060,000,000,000,000,000,000,000 | 12 | net/sctp: Validate parameter size for SCTP_GET_ASSOC_STATS
Building sctp may fail with:
In function ‘copy_from_user’,
inlined from ‘sctp_getsockopt_assoc_stats’ at
net/sctp/socket.c:5656:20:
arch/x86/include/asm/uaccess_32.h:211:26: error: call to
‘copy_from_user_overflow’ declared with attribute error: copy_from_user()
buffer size is not provably correct
if built with W=1 due to a missing parameter size validation
before the call to copy_from_user.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net> |
static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode,
int sync, void *arg)
{
struct wait_page_queue *wpq;
struct io_kiocb *req = wait->private;
struct wait_page_key *key = arg;
wpq = container_of(wait, struct wait_page_queue, wait);
if (!wake_page_match(wpq, key))
return 0;
req->rw.kiocb.ki_flags &= ~IOCB_WAITQ;
list_del_init(&wait->entry);
io_req_task_queue(req);
return 1;
} | 0 | [
"CWE-416"
] | linux | e677edbcabee849bfdd43f1602bccbecf736a646 | 168,853,248,238,605,400,000,000,000,000,000,000,000 | 17 | io_uring: fix race between timeout flush and removal
io_flush_timeouts() assumes the timeout isn't in progress of triggering
or being removed/canceled, so it unconditionally removes it from the
timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care
of it.
Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: Jens Axboe <axboe@kernel.dk> |
static ssize_t print_cpu_modalias(struct device *dev,
struct device_attribute *attr,
char *buf)
{
ssize_t n;
u32 i;
n = sprintf(buf, "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:",
CPU_FEATURE_TYPEVAL);
for (i = 0; i < MAX_CPU_FEATURES; i++)
if (cpu_have_feature(i)) {
if (PAGE_SIZE < n + sizeof(",XXXX\n")) {
WARN(1, "CPU features overflow page\n");
break;
}
n += sprintf(&buf[n], ",%04X", i);
}
buf[n++] = '\n';
return n;
} | 1 | [
"CWE-787"
] | linux | aa838896d87af561a33ecefea1caa4c15a68bc47 | 133,532,921,148,595,370,000,000,000,000,000,000,000 | 21 | drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions
Convert the various sprintf fmaily calls in sysfs device show functions
to sysfs_emit and sysfs_emit_at for PAGE_SIZE buffer safety.
Done with:
$ spatch -sp-file sysfs_emit_dev.cocci --in-place --max-width=80 .
And cocci script:
$ cat sysfs_emit_dev.cocci
@@
identifier d_show;
identifier dev, attr, buf;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- sprintf(buf,
+ sysfs_emit(buf,
...);
...>
}
@@
identifier d_show;
identifier dev, attr, buf;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, PAGE_SIZE,
+ sysfs_emit(buf,
...);
...>
}
@@
identifier d_show;
identifier dev, attr, buf;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- scnprintf(buf, PAGE_SIZE,
+ sysfs_emit(buf,
...);
...>
}
@@
identifier d_show;
identifier dev, attr, buf;
expression chr;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- strcpy(buf, chr);
+ sysfs_emit(buf, chr);
...>
}
@@
identifier d_show;
identifier dev, attr, buf;
identifier len;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
len =
- sprintf(buf,
+ sysfs_emit(buf,
...);
...>
return len;
}
@@
identifier d_show;
identifier dev, attr, buf;
identifier len;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
len =
- snprintf(buf, PAGE_SIZE,
+ sysfs_emit(buf,
...);
...>
return len;
}
@@
identifier d_show;
identifier dev, attr, buf;
identifier len;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
len =
- scnprintf(buf, PAGE_SIZE,
+ sysfs_emit(buf,
...);
...>
return len;
}
@@
identifier d_show;
identifier dev, attr, buf;
identifier len;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
- len += scnprintf(buf + len, PAGE_SIZE - len,
+ len += sysfs_emit_at(buf, len,
...);
...>
return len;
}
@@
identifier d_show;
identifier dev, attr, buf;
expression chr;
@@
ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf)
{
...
- strcpy(buf, chr);
- return strlen(buf);
+ return sysfs_emit(buf, chr);
}
Signed-off-by: Joe Perches <joe@perches.com>
Link: https://lore.kernel.org/r/3d033c33056d88bbe34d4ddb62afd05ee166ab9a.1600285923.git.joe@perches.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
static PHP_MINFO_FUNCTION(session) /* {{{ */
{
ps_module **mod;
ps_serializer *ser;
smart_str save_handlers = {0};
smart_str ser_handlers = {0};
int i;
/* Get save handlers */
for (i = 0, mod = ps_modules; i < MAX_MODULES; i++, mod++) {
if (*mod && (*mod)->s_name) {
smart_str_appends(&save_handlers, (*mod)->s_name);
smart_str_appendc(&save_handlers, ' ');
}
}
/* Get serializer handlers */
for (i = 0, ser = ps_serializers; i < MAX_SERIALIZERS; i++, ser++) {
if (ser && ser->name) {
smart_str_appends(&ser_handlers, ser->name);
smart_str_appendc(&ser_handlers, ' ');
}
}
php_info_print_table_start();
php_info_print_table_row(2, "Session Support", "enabled" );
if (save_handlers.c) {
smart_str_0(&save_handlers);
php_info_print_table_row(2, "Registered save handlers", save_handlers.c);
smart_str_free(&save_handlers);
} else {
php_info_print_table_row(2, "Registered save handlers", "none");
}
if (ser_handlers.c) {
smart_str_0(&ser_handlers);
php_info_print_table_row(2, "Registered serializer handlers", ser_handlers.c);
smart_str_free(&ser_handlers);
} else {
php_info_print_table_row(2, "Registered serializer handlers", "none");
}
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
} | 0 | [
"CWE-264"
] | php-src | 25e8fcc88fa20dc9d4c47184471003f436927cde | 88,650,798,117,099,140,000,000,000,000,000,000,000 | 47 | Strict session |
bool rtl_ps_disable_nic(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
/*<1> Stop all timer */
rtl_deinit_deferred_work(hw, true);
/*<2> Disable Interrupt */
rtlpriv->cfg->ops->disable_interrupt(hw);
tasklet_kill(&rtlpriv->works.irq_tasklet);
/*<3> Disable Adapter */
rtlpriv->cfg->ops->hw_disable(hw);
return true;
} | 0 | [
"CWE-120"
] | linux | 8c55dedb795be8ec0cf488f98c03a1c2176f7fb1 | 55,467,660,144,033,680,000,000,000,000,000,000,000 | 16 | rtlwifi: Fix potential overflow on P2P code
Nicolas Waisman noticed that even though noa_len is checked for
a compatible length it's still possible to overrun the buffers
of p2pinfo since there's no check on the upper bound of noa_num.
Bound noa_num against P2P_MAX_NOA_NUM.
Reported-by: Nicolas Waisman <nico@semmle.com>
Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org> |
static void intel_fixup_er(struct perf_event *event, int idx)
{
event->hw.extra_reg.idx = idx;
if (idx == EXTRA_REG_RSP_0) {
event->hw.config &= ~INTEL_ARCH_EVENT_MASK;
event->hw.config |= 0x01b7;
event->hw.extra_reg.reg = MSR_OFFCORE_RSP_0;
} else if (idx == EXTRA_REG_RSP_1) {
event->hw.config &= ~INTEL_ARCH_EVENT_MASK;
event->hw.config |= 0x01bb;
event->hw.extra_reg.reg = MSR_OFFCORE_RSP_1;
}
} | 0 | [
"CWE-20",
"CWE-401"
] | linux | f1923820c447e986a9da0fc6bf60c1dccdf0408e | 172,266,403,436,415,260,000,000,000,000,000,000,000 | 14 | perf/x86: Fix offcore_rsp valid mask for SNB/IVB
The valid mask for both offcore_response_0 and
offcore_response_1 was wrong for SNB/SNB-EP,
IVB/IVB-EP. It was possible to write to
reserved bit and cause a GP fault crashing
the kernel.
This patch fixes the problem by correctly marking the
reserved bits in the valid mask for all the processors
mentioned above.
A distinction between desktop and server parts is introduced
because bits 24-30 are only available on the server parts.
This version of the patch is just a rebase to perf/urgent tree
and should apply to older kernels as well.
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: jolsa@redhat.com
Cc: gregkh@linuxfoundation.org
Cc: security@kernel.org
Cc: ak@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org> |
Curl_ssl_connect(struct Curl_easy *data, struct connectdata *conn,
int sockindex)
{
CURLcode result;
#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy_ssl_connected[sockindex]) {
result = ssl_connect_init_proxy(conn, sockindex);
if(result)
return result;
}
#endif
if(!ssl_prefs_check(data))
return CURLE_SSL_CONNECT_ERROR;
/* mark this is being ssl-enabled from here on. */
conn->ssl[sockindex].use = TRUE;
conn->ssl[sockindex].state = ssl_connection_negotiating;
result = Curl_ssl->connect_blocking(data, conn, sockindex);
if(!result)
Curl_pgrsTime(data, TIMER_APPCONNECT); /* SSL is connected */
else
conn->ssl[sockindex].use = FALSE;
return result;
} | 0 | [
"CWE-416",
"CWE-295"
] | curl | 7f4a9a9b2a49547eae24d2e19bc5c346e9026479 | 282,793,056,276,706,500,000,000,000,000,000,000,000 | 29 | openssl: associate/detach the transfer from connection
CVE-2021-22901
Bug: https://curl.se/docs/CVE-2021-22901.html |
*/
int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr,
struct netlink_ext_ack *extack)
{
struct netdev_notifier_pre_changeaddr_info info = {
.info.dev = dev,
.info.extack = extack,
.dev_addr = addr,
};
int rc;
rc = call_netdevice_notifiers_info(NETDEV_PRE_CHANGEADDR, &info.info);
return notifier_to_errno(rc); | 0 | [
"CWE-416"
] | linux | a4270d6795b0580287453ea55974d948393e66ef | 165,874,016,821,493,470,000,000,000,000,000,000,000 | 13 | net-gro: fix use-after-free read in napi_gro_frags()
If a network driver provides to napi_gro_frags() an
skb with a page fragment of exactly 14 bytes, the call
to gro_pull_from_frag0() will 'consume' the fragment
by calling skb_frag_unref(skb, 0), and the page might
be freed and reused.
Reading eth->h_proto at the end of napi_frags_skb() might
read mangled data, or crash under specific debugging features.
BUG: KASAN: use-after-free in napi_frags_skb net/core/dev.c:5833 [inline]
BUG: KASAN: use-after-free in napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
Read of size 2 at addr ffff88809366840c by task syz-executor599/8957
CPU: 1 PID: 8957 Comm: syz-executor599 Not tainted 5.2.0-rc1+ #32
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
__kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
kasan_report+0x12/0x20 mm/kasan/common.c:614
__asan_report_load_n_noabort+0xf/0x20 mm/kasan/generic_report.c:142
napi_frags_skb net/core/dev.c:5833 [inline]
napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
tun_get_user+0x2f3c/0x3ff0 drivers/net/tun.c:1991
tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2037
call_write_iter include/linux/fs.h:1872 [inline]
do_iter_readv_writev+0x5f8/0x8f0 fs/read_write.c:693
do_iter_write fs/read_write.c:970 [inline]
do_iter_write+0x184/0x610 fs/read_write.c:951
vfs_writev+0x1b3/0x2f0 fs/read_write.c:1015
do_writev+0x15b/0x330 fs/read_write.c:1058
Fixes: a50e233c50db ("net-gro: restore frag0 optimization")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net> |
int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, struct kvm_io_device *dev)
{
struct kvm_io_bus *new_bus, *bus;
bus = kvm->buses[bus_idx];
/* exclude ioeventfd which is limited by maximum fd */
if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
return -ENOSPC;
new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *
sizeof(struct kvm_io_range)), GFP_KERNEL);
if (!new_bus)
return -ENOMEM;
memcpy(new_bus, bus, sizeof(*bus) + (bus->dev_count *
sizeof(struct kvm_io_range)));
kvm_io_bus_insert_dev(new_bus, dev, addr, len);
rcu_assign_pointer(kvm->buses[bus_idx], new_bus);
synchronize_srcu_expedited(&kvm->srcu);
kfree(bus);
return 0;
} | 0 | [
"CWE-20"
] | linux | 338c7dbadd2671189cec7faf64c84d01071b3f96 | 190,180,695,594,500,200,000,000,000,000,000,000,000 | 23 | KVM: Improve create VCPU parameter (CVE-2013-4587)
In multiple functions the vcpu_id is used as an offset into a bitfield. Ag
malicious user could specify a vcpu_id greater than 255 in order to set or
clear bits in kernel memory. This could be used to elevate priveges in the
kernel. This patch verifies that the vcpu_id provided is less than 255.
The api documentation already specifies that the vcpu_id must be less than
max_vcpus, but this is currently not checked.
Reported-by: Andrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
virtual ~JSONParser() {} | 0 | [
"CWE-787"
] | opencv | f42d5399aac80d371b17d689851406669c9b9111 | 144,027,317,756,948,520,000,000,000,000,000,000,000 | 1 | core(persistence): add more checks for implementation limitations |
SPL_METHOD(SplFileObject, next)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_filesystem_file_free_line(intern);
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {
spl_filesystem_file_read_line(getThis(), intern, 1);
}
intern->u.file.current_line_num++;
} /* }}} */ | 0 | [
"CWE-74"
] | php-src | a5a15965da23c8e97657278fc8dfbf1dfb20c016 | 214,934,991,876,060,900,000,000,000,000,000,000,000 | 14 | Fix #78863: DirectoryIterator class silently truncates after a null byte
Since the constructor of DirectoryIterator and friends is supposed to
accepts paths (i.e. strings without NUL bytes), we must not accept
arbitrary strings. |
RZ_API void rz_analysis_function_delete_var(RzAnalysisFunction *fcn, RzAnalysisVar *var) {
rz_return_if_fail(fcn && var);
rz_pvector_remove_data(&fcn->vars, var);
var_free(var);
} | 0 | [
"CWE-703"
] | rizin | 6ce71d8aa3dafe3cdb52d5d72ae8f4b95916f939 | 800,820,762,370,370,800,000,000,000,000,000,000 | 5 | Initialize retctx,ctx before freeing the inner elements
In rz_core_analysis_type_match retctx structure was initialized on the
stack only after a "goto out_function", where a field of that structure
was freed. When the goto path is taken, the field is not properly
initialized and it cause cause a crash of Rizin or have other effects.
Fixes: CVE-2021-4022 |
float compute_error_of_weight_set_1plane(
const endpoints_and_weights& eai,
const decimation_info& di,
const float* dec_weight_quant_uvalue
) {
vfloat4 error_summav = vfloat4::zero();
float error_summa = 0.0f;
unsigned int texel_count = di.texel_count;
bool is_decimated = di.texel_count != di.weight_count;
// Process SIMD-width chunks, safe to over-fetch - the extra space is zero initialized
if (is_decimated)
{
for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values = bilinear_infill_vla(di, dec_weight_quant_uvalue, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values = loada(eai.weights + i);
vfloat diff = current_values - actual_values;
vfloat significance = loada(eai.weight_error_scale + i);
vfloat error = diff * diff * significance;
haccumulate(error_summav, error);
}
}
else
{
for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Load the weight set directly, without interpolation
vfloat current_values = loada(dec_weight_quant_uvalue + i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values = loada(eai.weights + i);
vfloat diff = current_values - actual_values;
vfloat significance = loada(eai.weight_error_scale + i);
vfloat error = diff * diff * significance;
haccumulate(error_summav, error);
}
}
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
} | 0 | [
"CWE-787"
] | astc-encoder | bdd385fe19bf2737bead4b5664acdfdeca7aab15 | 230,807,954,512,977,260,000,000,000,000,000,000,000 | 50 | Only load based on texel index if undecimated |
TEST(HeaderMapImplTest, HostHeader) {
TestRequestHeaderMapImpl request_headers{{"host", "foo"}};
EXPECT_EQ(request_headers.size(), 1);
EXPECT_EQ(request_headers.get_(":authority"), "foo");
TestRequestTrailerMapImpl request_trailers{{"host", "foo"}};
EXPECT_EQ(request_trailers.size(), 1);
EXPECT_EQ(request_trailers.get_("host"), "foo");
TestResponseHeaderMapImpl response_headers{{"host", "foo"}};
EXPECT_EQ(response_headers.size(), 1);
EXPECT_EQ(response_headers.get_("host"), "foo");
TestResponseTrailerMapImpl response_trailers{{"host", "foo"}};
EXPECT_EQ(response_trailers.size(), 1);
EXPECT_EQ(response_trailers.get_("host"), "foo");
} | 0 | [] | envoy | 2c60632d41555ec8b3d9ef5246242be637a2db0f | 69,463,685,538,444,465,000,000,000,000,000,000,000 | 17 | http: header map security fixes for duplicate headers (#197)
Previously header matching did not match on all headers for
non-inline headers. This patch changes the default behavior to
always logically match on all headers. Multiple individual
headers will be logically concatenated with ',' similar to what
is done with inline headers. This makes the behavior effectively
consistent. This behavior can be temporary reverted by setting
the runtime value "envoy.reloadable_features.header_match_on_all_headers"
to "false".
Targeted fixes have been additionally performed on the following
extensions which make them consider all duplicate headers by default as
a comma concatenated list:
1) Any extension using CEL matching on headers.
2) The header to metadata filter.
3) The JWT filter.
4) The Lua filter.
Like primary header matching used in routing, RBAC, etc. this behavior
can be disabled by setting the runtime value
"envoy.reloadable_features.header_match_on_all_headers" to false.
Finally, the setCopy() header map API previously only set the first
header in the case of duplicate non-inline headers. setCopy() now
behaves similiarly to the other set*() APIs and replaces all found
headers with a single value. This may have had security implications
in the extauth filter which uses this API. This behavior can be disabled
by setting the runtime value
"envoy.reloadable_features.http_set_copy_replace_all_headers" to false.
Fixes https://github.com/envoyproxy/envoy-setec/issues/188
Signed-off-by: Matt Klein <mklein@lyft.com> |
bool ms_verify_authorizer(Connection *con, int peer_type, int protocol,
bufferlist& authorizer, bufferlist& authorizer_reply,
bool& isvalid, CryptoKey& session_key) override {
isvalid = true;
return true;
} | 1 | [
"CWE-287",
"CWE-284"
] | ceph | 5ead97120e07054d80623dada90a5cc764c28468 | 89,914,117,185,406,400,000,000,000,000,000,000,000 | 6 | auth/cephx: add authorizer challenge
Allow the accepting side of a connection to reject an initial authorizer
with a random challenge. The connecting side then has to respond with an
updated authorizer proving they are able to decrypt the service's challenge
and that the new authorizer was produced for this specific connection
instance.
The accepting side requires this challenge and response unconditionally
if the client side advertises they have the feature bit. Servers wishing
to require this improved level of authentication simply have to require
the appropriate feature.
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b)
# Conflicts:
# src/auth/Auth.h
# src/auth/cephx/CephxProtocol.cc
# src/auth/cephx/CephxProtocol.h
# src/auth/none/AuthNoneProtocol.h
# src/msg/Dispatcher.h
# src/msg/async/AsyncConnection.cc
- const_iterator
- ::decode vs decode
- AsyncConnection ctor arg noise
- get_random_bytes(), not cct->random() |
int nft_parse_register_store(const struct nft_ctx *ctx,
const struct nlattr *attr, u8 *dreg,
const struct nft_data *data,
enum nft_data_types type, unsigned int len)
{
int err;
u32 reg;
reg = nft_parse_register(attr);
err = nft_validate_register_store(ctx, reg, data, type, len);
if (err < 0)
return err;
*dreg = reg;
return 0;
} | 1 | [
"CWE-787"
] | linux | 6e1acfa387b9ff82cfc7db8cc3b6959221a95851 | 293,953,775,694,832,540,000,000,000,000,000,000,000 | 16 | netfilter: nf_tables: validate registers coming from userspace.
Bail out in case userspace uses unsupported registers.
Fixes: 49499c3e6e18 ("netfilter: nf_tables: switch registers to 32 bit addressing")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> |
static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
EVP_AES_XTS_CTX *xctx = ctx->cipher_data;
if (!iv && !key)
return 1;
if (key)
do {
# ifdef AES_XTS_ASM
xctx->stream = enc ? AES_xts_encrypt : AES_xts_decrypt;
# else
xctx->stream = NULL;
# endif
/* key_len is two AES keys */
# ifdef HWAES_CAPABLE
if (HWAES_CAPABLE) {
if (enc) {
HWAES_set_encrypt_key(key, ctx->key_len * 4,
&xctx->ks1.ks);
xctx->xts.block1 = (block128_f) HWAES_encrypt;
} else {
HWAES_set_decrypt_key(key, ctx->key_len * 4,
&xctx->ks1.ks);
xctx->xts.block1 = (block128_f) HWAES_decrypt;
}
HWAES_set_encrypt_key(key + ctx->key_len / 2,
ctx->key_len * 4, &xctx->ks2.ks);
xctx->xts.block2 = (block128_f) HWAES_encrypt;
xctx->xts.key1 = &xctx->ks1;
break;
} else
# endif
# ifdef BSAES_CAPABLE
if (BSAES_CAPABLE)
xctx->stream = enc ? bsaes_xts_encrypt : bsaes_xts_decrypt;
else
# endif
# ifdef VPAES_CAPABLE
if (VPAES_CAPABLE) {
if (enc) {
vpaes_set_encrypt_key(key, ctx->key_len * 4,
&xctx->ks1.ks);
xctx->xts.block1 = (block128_f) vpaes_encrypt;
} else {
vpaes_set_decrypt_key(key, ctx->key_len * 4,
&xctx->ks1.ks);
xctx->xts.block1 = (block128_f) vpaes_decrypt;
}
vpaes_set_encrypt_key(key + ctx->key_len / 2,
ctx->key_len * 4, &xctx->ks2.ks);
xctx->xts.block2 = (block128_f) vpaes_encrypt;
xctx->xts.key1 = &xctx->ks1;
break;
} else
# endif
(void)0; /* terminate potentially open 'else' */
if (enc) {
AES_set_encrypt_key(key, ctx->key_len * 4, &xctx->ks1.ks);
xctx->xts.block1 = (block128_f) AES_encrypt;
} else {
AES_set_decrypt_key(key, ctx->key_len * 4, &xctx->ks1.ks);
xctx->xts.block1 = (block128_f) AES_decrypt;
}
AES_set_encrypt_key(key + ctx->key_len / 2,
ctx->key_len * 4, &xctx->ks2.ks);
xctx->xts.block2 = (block128_f) AES_encrypt;
xctx->xts.key1 = &xctx->ks1;
} while (0);
if (iv) {
xctx->xts.key2 = &xctx->ks2;
memcpy(ctx->iv, iv, 16);
}
return 1;
} | 0 | [] | openssl | 1a3701f4fe0530a40ec073cd78d02cfcc26c0f8e | 241,819,503,665,010,870,000,000,000,000,000,000,000 | 84 | Sanity check EVP_CTRL_AEAD_TLS_AAD
The various implementations of EVP_CTRL_AEAD_TLS_AAD expect a buffer of at
least 13 bytes long. Add sanity checks to ensure that the length is at
least that. Also add a new constant (EVP_AEAD_TLS1_AAD_LEN) to evp.h to
represent this length. Thanks to Kevin Wojtysiak (Int3 Solutions) and
Paramjot Oberoi (Int3 Solutions) for reporting this issue.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit c8269881093324b881b81472be037055571f73f3)
Conflicts:
ssl/record/ssl3_record.c |
compare_method_imap (const void *key, const void *elem)
{
const char** method_name = (const char**)elem;
return strcmp (key, *method_name);
} | 0 | [
"CWE-264"
] | mono | 035c8587c0d8d307e45f1b7171a0d337bb451f1e | 55,113,535,490,446,280,000,000,000,000,000,000,000 | 5 | Allow only primitive types/enums in RuntimeHelpers.InitializeArray (). |
static int nf_tables_dump_rules_start(struct netlink_callback *cb)
{
const struct nlattr * const *nla = cb->data;
struct nft_rule_dump_ctx *ctx = NULL;
if (nla[NFTA_RULE_TABLE] || nla[NFTA_RULE_CHAIN]) {
ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
if (!ctx)
return -ENOMEM;
if (nla[NFTA_RULE_TABLE]) {
ctx->table = nla_strdup(nla[NFTA_RULE_TABLE],
GFP_ATOMIC);
if (!ctx->table) {
kfree(ctx);
return -ENOMEM;
}
}
if (nla[NFTA_RULE_CHAIN]) {
ctx->chain = nla_strdup(nla[NFTA_RULE_CHAIN],
GFP_ATOMIC);
if (!ctx->chain) {
kfree(ctx->table);
kfree(ctx);
return -ENOMEM;
}
}
}
cb->data = ctx;
return 0;
} | 0 | [
"CWE-665"
] | linux | ad9f151e560b016b6ad3280b48e42fa11e1a5440 | 43,103,151,243,437,300,000,000,000,000,000,000,000 | 32 | netfilter: nf_tables: initialize set before expression setup
nft_set_elem_expr_alloc() needs an initialized set if expression sets on
the NFT_EXPR_GC flag. Move set fields initialization before expression
setup.
[4512935.019450] ==================================================================
[4512935.019456] BUG: KASAN: null-ptr-deref in nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019487] Read of size 8 at addr 0000000000000070 by task nft/23532
[4512935.019494] CPU: 1 PID: 23532 Comm: nft Not tainted 5.12.0-rc4+ #48
[...]
[4512935.019502] Call Trace:
[4512935.019505] dump_stack+0x89/0xb4
[4512935.019512] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019536] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019560] kasan_report.cold.12+0x5f/0xd8
[4512935.019566] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019590] nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019615] nf_tables_newset+0xc7f/0x1460 [nf_tables]
Reported-by: syzbot+ce96ca2b1d0b37c6422d@syzkaller.appspotmail.com
Fixes: 65038428b2c6 ("netfilter: nf_tables: allow to specify stateful expression in set definition")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> |
static int idprime_get_token_name(sc_card_t* card, char** tname)
{
idprime_private_data_t * priv = card->drv_data;
sc_path_t tinfo_path = {"\x00\x00", 2, 0, 0, SC_PATH_TYPE_PATH, {"", 0}};
sc_file_t *file = NULL;
u8 buf[2];
int r;
LOG_FUNC_CALLED(card->ctx);
if (tname == NULL) {
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
}
if (!priv->tinfo_present) {
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
}
memcpy(tinfo_path.value, priv->tinfo_df, 2);
r = iso_ops->select_file(card, &tinfo_path, &file);
if (r != SC_SUCCESS || file->size == 0) {
sc_file_free(file);
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
}
/* First two bytes lists 0x01, the second indicates length */
r = iso_ops->read_binary(card, 0, buf, 2, 0);
if (r < 2 || buf[1] > file->size) { /* make sure we do not overrun */
sc_file_free(file);
LOG_FUNC_RETURN(card->ctx, r);
}
sc_file_free(file);
*tname = malloc(buf[1]);
if (*tname == NULL) {
LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
}
r = iso_ops->read_binary(card, 2, (unsigned char *)*tname, buf[1], 0);
if (r < 1) {
free(*tname);
LOG_FUNC_RETURN(card->ctx, r);
}
if ((*tname)[r-1] != '\0') {
(*tname)[r-1] = '\0';
}
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
} | 1 | [] | OpenSC | f015746d22d249642c19674298a18ad824db0ed7 | 155,254,593,995,137,430,000,000,000,000,000,000,000 | 49 | idprime: Use temporary variable instead of messing up the passed one
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28185 |
const char *pos() const { return str - is_quoted(); } | 0 | [
"CWE-703"
] | server | 39feab3cd31b5414aa9b428eaba915c251ac34a2 | 159,226,243,880,677,320,000,000,000,000,000,000,000 | 1 | MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT
IF an INSERT/REPLACE SELECT statement contained an ON expression in the top
level select and this expression used a subquery with a column reference
that could not be resolved then an attempt to resolve this reference as
an outer reference caused a crash of the server. This happened because the
outer context field in the Name_resolution_context structure was not set
to NULL for such references. Rather it pointed to the first element in
the select_stack.
Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select()
method when parsing a SELECT construct.
Approved by Oleksandr Byelkin <sanja@mariadb.com> |
void ConnectionManagerImpl::ActiveStream::decodeMetadata(MetadataMapPtr&& metadata_map) {
resetIdleTimer();
// After going through filters, the ownership of metadata_map will be passed to terminal filter.
// The terminal filter may encode metadata_map to the next hop immediately or store metadata_map
// and encode later when connection pool is ready.
filter_manager_.decodeMetadata(*metadata_map);
} | 0 | [
"CWE-22"
] | envoy | 5333b928d8bcffa26ab19bf018369a835f697585 | 218,950,661,891,762,300,000,000,000,000,000,000,000 | 7 | Implement handling of escaped slash characters in URL path
Fixes: CVE-2021-29492
Signed-off-by: Yan Avlasov <yavlasov@google.com> |
R_API void r_bin_java_reset_bin_info(RBinJavaObj *bin) {
free (bin->cf2.flags_str);
free (bin->cf2.this_class_name);
r_list_free (bin->imports_list);
r_list_free (bin->methods_list);
r_list_free (bin->fields_list);
r_list_free (bin->attrs_list);
r_list_free (bin->cp_list);
r_list_free (bin->interfaces_list);
r_str_constpool_fini (&bin->constpool);
r_str_constpool_init (&bin->constpool);
bin->cf2.flags_str = strdup ("unknown");
bin->cf2.this_class_name = strdup ("unknown");
bin->imports_list = r_list_newf (free);
bin->methods_list = r_list_newf (r_bin_java_fmtype_free);
bin->fields_list = r_list_newf (r_bin_java_fmtype_free);
bin->attrs_list = r_list_newf (r_bin_java_attribute_free);
bin->cp_list = r_list_newf (r_bin_java_constant_pool);
bin->interfaces_list = r_list_newf (r_bin_java_interface_free);
} | 0 | [
"CWE-119",
"CWE-788"
] | radare2 | 6c4428f018d385fc80a33ecddcb37becea685dd5 | 258,495,487,484,337,260,000,000,000,000,000,000,000 | 20 | Improve boundary checks to fix oobread segfaults ##crash
* Reported by Cen Zhang via huntr.dev
* Reproducer: bins/fuzzed/javaoob-havoc.class |
Status RoleGraph::getBSONForRole(RoleGraph* graph,
const RoleName& roleName,
mutablebson::Element result) try {
if (!graph->roleExists(roleName)) {
return Status(ErrorCodes::RoleNotFound,
str::stream() << roleName.getFullName() << "does not name an existing role");
}
std::string id = str::stream() << roleName.getDB() << "." << roleName.getRole();
uassertStatusOK(result.appendString("_id", id));
uassertStatusOK(
result.appendString(AuthorizationManager::ROLE_NAME_FIELD_NAME, roleName.getRole()));
uassertStatusOK(
result.appendString(AuthorizationManager::ROLE_DB_FIELD_NAME, roleName.getDB()));
// Build privileges array
mutablebson::Element privilegesArrayElement =
result.getDocument().makeElementArray("privileges");
uassertStatusOK(result.pushBack(privilegesArrayElement));
const PrivilegeVector& privileges = graph->getDirectPrivileges(roleName);
uassertStatusOK(Privilege::getBSONForPrivileges(privileges, privilegesArrayElement));
// Build roles array
mutablebson::Element rolesArrayElement = result.getDocument().makeElementArray("roles");
uassertStatusOK(result.pushBack(rolesArrayElement));
for (RoleNameIterator roles = graph->getDirectSubordinates(roleName); roles.more();
roles.next()) {
const RoleName& subRole = roles.get();
mutablebson::Element roleObj = result.getDocument().makeElementObject("");
uassertStatusOK(
roleObj.appendString(AuthorizationManager::ROLE_NAME_FIELD_NAME, subRole.getRole()));
uassertStatusOK(
roleObj.appendString(AuthorizationManager::ROLE_DB_FIELD_NAME, subRole.getDB()));
uassertStatusOK(rolesArrayElement.pushBack(roleObj));
}
return Status::OK();
} catch (...) { | 1 | [
"CWE-863"
] | mongo | 521e56b407ac72bc69a97a24d1253f51a5b6e81b | 101,898,441,253,732,920,000,000,000,000,000,000,000 | 37 | SERVER-45472 Ensure RoleGraph can serialize authentication restrictions to BSON |
static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
{
struct net_device *dev = queue->dev;
struct xps_dev_maps *dev_maps;
unsigned long *mask, index;
int j, len, num_tc = 1, tc = 0;
index = get_netdev_queue_index(queue);
if (dev->num_tc) {
num_tc = dev->num_tc;
tc = netdev_txq_to_tc(dev, index);
if (tc < 0)
return -EINVAL;
}
mask = bitmap_zalloc(dev->num_rx_queues, GFP_KERNEL);
if (!mask)
return -ENOMEM;
rcu_read_lock();
dev_maps = rcu_dereference(dev->xps_rxqs_map);
if (!dev_maps)
goto out_no_maps;
for (j = -1; j = netif_attrmask_next(j, NULL, dev->num_rx_queues),
j < dev->num_rx_queues;) {
int i, tci = j * num_tc + tc;
struct xps_map *map;
map = rcu_dereference(dev_maps->attr_map[tci]);
if (!map)
continue;
for (i = map->len; i--;) {
if (map->queues[i] == index) {
set_bit(j, mask);
break;
}
}
}
out_no_maps:
rcu_read_unlock();
len = bitmap_print_to_pagebuf(false, buf, mask, dev->num_rx_queues);
bitmap_free(mask);
return len < PAGE_SIZE ? len : -EINVAL; | 0 | [] | linux | a3e23f719f5c4a38ffb3d30c8d7632a4ed8ccd9e | 33,702,955,230,317,840,000,000,000,000,000,000,000 | 48 | net-sysfs: call dev_hold if kobject_init_and_add success
In netdev_queue_add_kobject and rx_queue_add_kobject,
if sysfs_create_group failed, kobject_put will call
netdev_queue_release to decrease dev refcont, however
dev_hold has not be called. So we will see this while
unregistering dev:
unregister_netdevice: waiting for bcsh0 to become free. Usage count = -1
Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: d0d668371679 ("net: don't decrement kobj reference count on init failure")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net> |
void HGraphBuilder::GenerateObjectEquals(CallRuntime* call) {
ASSERT(call->arguments()->length() == 2);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
HValue* right = Pop();
HValue* left = Pop();
HCompareObjectEqAndBranch* result =
new(zone()) HCompareObjectEqAndBranch(left, right);
return ast_context()->ReturnControl(result, call->id());
} | 0 | [] | node | fd80a31e0697d6317ce8c2d289575399f4e06d21 | 178,791,493,607,217,650,000,000,000,000,000,000,000 | 10 | deps: backport 5f836c from v8 upstream
Original commit message:
Fix Hydrogen bounds check elimination
When combining bounds checks, they must all be moved before the first load/store
that they are guarding.
BUG=chromium:344186
LOG=y
R=svenpanne@chromium.org
Review URL: https://codereview.chromium.org/172093002
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@19475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
fix #8070 |
int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix)
{
BDRVQcowState *s = bs->opaque;
int64_t size, i, highest_cluster;
int nb_clusters, refcount1, refcount2;
QCowSnapshot *sn;
uint16_t *refcount_table;
int ret;
size = bdrv_getlength(bs->file);
nb_clusters = size_to_clusters(s, size);
refcount_table = g_malloc0(nb_clusters * sizeof(uint16_t));
res->bfi.total_clusters =
size_to_clusters(s, bs->total_sectors * BDRV_SECTOR_SIZE);
/* header */
inc_refcounts(bs, res, refcount_table, nb_clusters,
0, s->cluster_size);
/* current L1 table */
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
if (ret < 0) {
goto fail;
}
/* snapshots */
for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
sn->l1_table_offset, sn->l1_size, 0);
if (ret < 0) {
goto fail;
}
}
inc_refcounts(bs, res, refcount_table, nb_clusters,
s->snapshots_offset, s->snapshots_size);
/* refcount data */
inc_refcounts(bs, res, refcount_table, nb_clusters,
s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t));
for(i = 0; i < s->refcount_table_size; i++) {
uint64_t offset, cluster;
offset = s->refcount_table[i];
cluster = offset >> s->cluster_bits;
/* Refcount blocks are cluster aligned */
if (offset_into_cluster(s, offset)) {
fprintf(stderr, "ERROR refcount block %" PRId64 " is not "
"cluster aligned; refcount table entry corrupted\n", i);
res->corruptions++;
continue;
}
if (cluster >= nb_clusters) {
fprintf(stderr, "ERROR refcount block %" PRId64
" is outside image\n", i);
res->corruptions++;
continue;
}
if (offset != 0) {
inc_refcounts(bs, res, refcount_table, nb_clusters,
offset, s->cluster_size);
if (refcount_table[cluster] != 1) {
fprintf(stderr, "%s refcount block %" PRId64
" refcount=%d\n",
fix & BDRV_FIX_ERRORS ? "Repairing" :
"ERROR",
i, refcount_table[cluster]);
if (fix & BDRV_FIX_ERRORS) {
int64_t new_offset;
new_offset = realloc_refcount_block(bs, i, offset);
if (new_offset < 0) {
res->corruptions++;
continue;
}
/* update refcounts */
if ((new_offset >> s->cluster_bits) >= nb_clusters) {
/* increase refcount_table size if necessary */
int old_nb_clusters = nb_clusters;
nb_clusters = (new_offset >> s->cluster_bits) + 1;
refcount_table = g_realloc(refcount_table,
nb_clusters * sizeof(uint16_t));
memset(&refcount_table[old_nb_clusters], 0, (nb_clusters
- old_nb_clusters) * sizeof(uint16_t));
}
refcount_table[cluster]--;
inc_refcounts(bs, res, refcount_table, nb_clusters,
new_offset, s->cluster_size);
res->corruptions_fixed++;
} else {
res->corruptions++;
}
}
}
}
/* compare ref counts */
for (i = 0, highest_cluster = 0; i < nb_clusters; i++) {
refcount1 = get_refcount(bs, i);
if (refcount1 < 0) {
fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",
i, strerror(-refcount1));
res->check_errors++;
continue;
}
refcount2 = refcount_table[i];
if (refcount1 > 0 || refcount2 > 0) {
highest_cluster = i;
}
if (refcount1 != refcount2) {
/* Check if we're allowed to fix the mismatch */
int *num_fixed = NULL;
if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {
num_fixed = &res->leaks_fixed;
} else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) {
num_fixed = &res->corruptions_fixed;
}
fprintf(stderr, "%s cluster %" PRId64 " refcount=%d reference=%d\n",
num_fixed != NULL ? "Repairing" :
refcount1 < refcount2 ? "ERROR" :
"Leaked",
i, refcount1, refcount2);
if (num_fixed) {
ret = update_refcount(bs, i << s->cluster_bits, 1,
refcount2 - refcount1,
QCOW2_DISCARD_ALWAYS);
if (ret >= 0) {
(*num_fixed)++;
continue;
}
}
/* And if we couldn't, print an error */
if (refcount1 < refcount2) {
res->corruptions++;
} else {
res->leaks++;
}
}
}
/* check OFLAG_COPIED */
ret = check_oflag_copied(bs, res, fix);
if (ret < 0) {
goto fail;
}
res->image_end_offset = (highest_cluster + 1) * s->cluster_size;
ret = 0;
fail:
g_free(refcount_table);
return ret;
} | 0 | [
"CWE-190"
] | qemu | b106ad9185f35fc4ad669555ad0e79e276083bd7 | 109,416,027,895,734,650,000,000,000,000,000,000,000 | 171 | qcow2: Don't rely on free_cluster_index in alloc_refcount_block() (CVE-2014-0147)
free_cluster_index is only correct if update_refcount() was called from
an allocation function, and even there it's brittle because it's used to
protect unfinished allocations which still have a refcount of 0 - if it
moves in the wrong place, the unfinished allocation can be corrupted.
So not using it any more seems to be a good idea. Instead, use the
first requested cluster to do the calculations. Return -EAGAIN if
unfinished allocations could become invalid and let the caller restart
its search for some free clusters.
The context of creating a snapsnot is one situation where
update_refcount() is called outside of a cluster allocation. For this
case, the change fixes a buffer overflow if a cluster is referenced in
an L2 table that cannot be represented by an existing refcount block.
(new_table[refcount_table_index] was out of bounds)
[Bump the qemu-iotests 026 refblock_alloc.write leak count from 10 to
11.
--Stefan]
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
R_API int r_bin_select_by_ids(RBin *bin, ut32 binfile_id, ut32 binobj_id) {
RBinFile *binfile = NULL;
RBinObject *obj = NULL;
if (binfile_id == UT32_MAX && binobj_id == UT32_MAX) {
return false;
}
if (binfile_id == -1) {
binfile = r_bin_file_find_by_object_id (bin, binobj_id);
obj = binfile? r_bin_file_object_find_by_id (binfile, binobj_id): NULL;
} else if (binobj_id == -1) {
binfile = r_bin_file_find_by_id (bin, binfile_id);
obj = binfile? binfile->o: NULL;
} else {
binfile = r_bin_file_find_by_id (bin, binfile_id);
obj = binfile? r_bin_file_object_find_by_id (binfile, binobj_id): NULL;
}
if (!binfile || !obj) {
return false;
}
return obj && binfile && r_bin_file_set_cur_binfile_obj (bin, binfile, obj);
} | 0 | [
"CWE-125"
] | radare2 | d31c4d3cbdbe01ea3ded16a584de94149ecd31d9 | 257,760,331,058,532,470,000,000,000,000,000,000,000 | 22 | Fix #8748 - Fix oobread on string search |
getcoprocbyname (name)
const char *name;
{
#if MULTIPLE_COPROCS
struct cpelement *p;
p = cpl_searchbyname (name);
return (p ? p->coproc : 0);
#else
return ((sh_coproc.c_name && STREQ (sh_coproc.c_name, name)) ? &sh_coproc : 0);
#endif
} | 0 | [] | bash | 955543877583837c85470f7fb8a97b7aa8d45e6c | 252,926,514,308,625,550,000,000,000,000,000,000,000 | 12 | bash-4.4-rc2 release |
void HGraphBuilder::GenerateValueOf(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop();
HValueOf* result = new(zone()) HValueOf(value);
return ast_context()->ReturnInstruction(result, call->id());
} | 0 | [] | node | fd80a31e0697d6317ce8c2d289575399f4e06d21 | 326,927,604,709,054,070,000,000,000,000,000,000,000 | 7 | deps: backport 5f836c from v8 upstream
Original commit message:
Fix Hydrogen bounds check elimination
When combining bounds checks, they must all be moved before the first load/store
that they are guarding.
BUG=chromium:344186
LOG=y
R=svenpanne@chromium.org
Review URL: https://codereview.chromium.org/172093002
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@19475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
fix #8070 |
zfs_acl_znode_info(znode_t *zp, int *aclsize, int *aclcount,
zfs_acl_phys_t *aclphys)
{
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
uint64_t acl_count;
int size;
int error;
ASSERT(MUTEX_HELD(&zp->z_acl_lock));
if (zp->z_is_sa) {
if ((error = sa_size(zp->z_sa_hdl, SA_ZPL_DACL_ACES(zfsvfs),
&size)) != 0)
return (error);
*aclsize = size;
if ((error = sa_lookup(zp->z_sa_hdl, SA_ZPL_DACL_COUNT(zfsvfs),
&acl_count, sizeof (acl_count))) != 0)
return (error);
*aclcount = acl_count;
} else {
if ((error = sa_lookup(zp->z_sa_hdl, SA_ZPL_ZNODE_ACL(zfsvfs),
aclphys, sizeof (*aclphys))) != 0)
return (error);
if (aclphys->z_acl_version == ZFS_ACL_VERSION_INITIAL) {
*aclsize = ZFS_ACL_SIZE(aclphys->z_acl_size);
*aclcount = aclphys->z_acl_size;
} else {
*aclsize = aclphys->z_acl_size;
*aclcount = aclphys->z_acl_count;
}
}
return (0);
} | 0 | [
"CWE-200",
"CWE-732"
] | zfs | 716b53d0a14c72bda16c0872565dd1909757e73f | 298,500,099,154,479,830,000,000,000,000,000,000,000 | 33 | FreeBSD: Fix UNIX permissions checking
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #10727 |
~MatrixTriangularSolveOp() override {} | 0 | [
"CWE-125"
] | tensorflow | 480641e3599775a8895254ffbc0fc45621334f68 | 290,064,607,005,731,340,000,000,000,000,000,000,000 | 1 | Validate (and ensure validation sticks) inputs for `MatrixTriangularSolve`.
PiperOrigin-RevId: 370282444
Change-Id: Iaed61a0b0727cc42c830658b72eb69f785f48dc5 |
void RGWREST::register_x_headers(const string& s_headers)
{
std::vector<std::string> hdrs = get_str_vec(s_headers);
for (auto& hdr : hdrs) {
boost::algorithm::to_upper(hdr); // XXX
(void) x_headers.insert(hdr);
}
} | 0 | [
"CWE-770"
] | ceph | ab29bed2fc9f961fe895de1086a8208e21ddaddc | 28,878,482,996,058,495,000,000,000,000,000,000,000 | 8 | rgw: fix issues with 'enforce bounds' patch
The patch to enforce bounds on max-keys/max-uploads/max-parts had a few
issues that would prevent us from compiling it. Instead of changing the
code provided by the submitter, we're addressing them in a separate
commit to maintain the DCO.
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
(cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a)
mimic specific fixes:
As the largeish change from master g_conf() isn't in mimic yet, use the g_conf
global structure, also make rgw_op use the value from req_info ceph context as
we do for all the requests |
static u32 hgcm_call_buf_size_in_pages(void *buf, u32 len)
{
u32 size = PAGE_ALIGN(len + ((unsigned long)buf & ~PAGE_MASK));
return size >> PAGE_SHIFT;
} | 0 | [
"CWE-400",
"CWE-703",
"CWE-401"
] | linux | e0b0cb9388642c104838fac100a4af32745621e2 | 279,876,814,322,899,840,000,000,000,000,000,000,000 | 6 | virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr
In hgcm_call_preprocess_linaddr memory is allocated for bounce_buf but
is not released if copy_form_user fails. In order to prevent memory leak
in case of failure, the assignment to bounce_buf_ret is moved before the
error check. This way the allocated bounce_buf will be released by the
caller.
Fixes: 579db9d45cb4 ("virt: Add vboxguest VMMDEV communication code")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20190930204223.3660-1-navid.emamdoost@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images,
size_t *length,ExceptionInfo *exception)
{
const MagickInfo
*magick_info;
ImageInfo
*clone_info;
MagickBooleanType
status;
void
*blob;
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(images != (Image *) NULL);
assert(images->signature == MagickCoreSignature);
assert(exception != (ExceptionInfo *) NULL);
*length=0;
blob=(unsigned char *) NULL;
clone_info=CloneImageInfo(image_info);
(void) SetImageInfo(clone_info,(unsigned int) GetImageListLength(images),
exception);
if (*clone_info->magick != '\0')
(void) CopyMagickString(images->magick,clone_info->magick,MagickPathExtent);
magick_info=GetMagickInfo(images->magick,exception);
if (magick_info == (const MagickInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
images->magick);
clone_info=DestroyImageInfo(clone_info);
return(blob);
}
if (GetMagickAdjoin(magick_info) == MagickFalse)
{
clone_info=DestroyImageInfo(clone_info);
return(ImageToBlob(image_info,images,length,exception));
}
(void) CopyMagickString(clone_info->magick,images->magick,MagickPathExtent);
if (GetMagickBlobSupport(magick_info) != MagickFalse)
{
/*
Native blob support for this images format.
*/
clone_info->length=0;
clone_info->blob=(void *) AcquireQuantumMemory(MagickMaxBlobExtent,
sizeof(unsigned char));
if (clone_info->blob == (void *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",images->filename);
else
{
(void) CloseBlob(images);
images->blob->exempt=MagickTrue;
*images->filename='\0';
status=WriteImages(clone_info,images,images->filename,exception);
*length=images->blob->length;
blob=DetachBlob(images->blob);
if (blob == (void *) NULL)
clone_info->blob=RelinquishMagickMemory(clone_info->blob);
else if (status == MagickFalse)
blob=RelinquishMagickMemory(blob);
else
blob=ResizeQuantumMemory(blob,*length+1,sizeof(unsigned char));
}
}
else
{
char
filename[MagickPathExtent],
unique[MagickPathExtent];
int
file;
/*
Write file to disk in blob images format.
*/
file=AcquireUniqueFileResource(unique);
if (file == -1)
{
ThrowFileException(exception,FileOpenError,"UnableToWriteBlob",
image_info->filename);
}
else
{
clone_info->file=fdopen(file,"wb");
if (clone_info->file != (FILE *) NULL)
{
(void) FormatLocaleString(filename,MagickPathExtent,"%s:%s",
images->magick,unique);
status=WriteImages(clone_info,images,filename,exception);
(void) CloseBlob(images);
(void) fclose(clone_info->file);
if (status != MagickFalse)
blob=FileToBlob(unique,~0UL,length,exception);
}
(void) RelinquishUniqueFileResource(unique);
}
}
clone_info=DestroyImageInfo(clone_info);
return(blob);
} | 0 | [
"CWE-416",
"CWE-399"
] | ImageMagick | c5d012a46ae22be9444326aa37969a3f75daa3ba | 37,110,106,750,869,604,000,000,000,000,000,000,000 | 109 | https://github.com/ImageMagick/ImageMagick6/issues/43 |
static void port_outb(const struct si_sm_io *io, unsigned int offset,
unsigned char b)
{
unsigned int addr = io->addr_data;
outb(b, addr + (offset * io->regspacing));
} | 0 | [
"CWE-416"
] | linux | 401e7e88d4ef80188ffa07095ac00456f901b8c4 | 229,198,820,348,641,350,000,000,000,000,000,000,000 | 7 | ipmi_si: fix use-after-free of resource->name
When we excute the following commands, we got oops
rmmod ipmi_si
cat /proc/ioports
[ 1623.482380] Unable to handle kernel paging request at virtual address ffff00000901d478
[ 1623.482382] Mem abort info:
[ 1623.482383] ESR = 0x96000007
[ 1623.482385] Exception class = DABT (current EL), IL = 32 bits
[ 1623.482386] SET = 0, FnV = 0
[ 1623.482387] EA = 0, S1PTW = 0
[ 1623.482388] Data abort info:
[ 1623.482389] ISV = 0, ISS = 0x00000007
[ 1623.482390] CM = 0, WnR = 0
[ 1623.482393] swapper pgtable: 4k pages, 48-bit VAs, pgdp = 00000000d7d94a66
[ 1623.482395] [ffff00000901d478] pgd=000000dffbfff003, pud=000000dffbffe003, pmd=0000003f5d06e003, pte=0000000000000000
[ 1623.482399] Internal error: Oops: 96000007 [#1] SMP
[ 1623.487407] Modules linked in: ipmi_si(E) nls_utf8 isofs rpcrdma ib_iser ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_umad rdma_cm ib_cm dm_mirror dm_region_hash dm_log iw_cm dm_mod aes_ce_blk crypto_simd cryptd aes_ce_cipher ses ghash_ce sha2_ce enclosure sha256_arm64 sg sha1_ce hisi_sas_v2_hw hibmc_drm sbsa_gwdt hisi_sas_main ip_tables mlx5_ib ib_uverbs marvell ib_core mlx5_core ixgbe mdio hns_dsaf ipmi_devintf hns_enet_drv ipmi_msghandler hns_mdio [last unloaded: ipmi_si]
[ 1623.532410] CPU: 30 PID: 11438 Comm: cat Kdump: loaded Tainted: G E 5.0.0-rc3+ #168
[ 1623.541498] Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.37 11/21/2017
[ 1623.548822] pstate: a0000005 (NzCv daif -PAN -UAO)
[ 1623.553684] pc : string+0x28/0x98
[ 1623.557040] lr : vsnprintf+0x368/0x5e8
[ 1623.560837] sp : ffff000013213a80
[ 1623.564191] x29: ffff000013213a80 x28: ffff00001138abb5
[ 1623.569577] x27: ffff000013213c18 x26: ffff805f67d06049
[ 1623.574963] x25: 0000000000000000 x24: ffff00001138abb5
[ 1623.580349] x23: 0000000000000fb7 x22: ffff0000117ed000
[ 1623.585734] x21: ffff000011188fd8 x20: ffff805f67d07000
[ 1623.591119] x19: ffff805f67d06061 x18: ffffffffffffffff
[ 1623.596505] x17: 0000000000000200 x16: 0000000000000000
[ 1623.601890] x15: ffff0000117ed748 x14: ffff805f67d07000
[ 1623.607276] x13: ffff805f67d0605e x12: 0000000000000000
[ 1623.612661] x11: 0000000000000000 x10: 0000000000000000
[ 1623.618046] x9 : 0000000000000000 x8 : 000000000000000f
[ 1623.623432] x7 : ffff805f67d06061 x6 : fffffffffffffffe
[ 1623.628817] x5 : 0000000000000012 x4 : ffff00000901d478
[ 1623.634203] x3 : ffff0a00ffffff04 x2 : ffff805f67d07000
[ 1623.639588] x1 : ffff805f67d07000 x0 : ffffffffffffffff
[ 1623.644974] Process cat (pid: 11438, stack limit = 0x000000008d4cbc10)
[ 1623.651592] Call trace:
[ 1623.654068] string+0x28/0x98
[ 1623.657071] vsnprintf+0x368/0x5e8
[ 1623.660517] seq_vprintf+0x70/0x98
[ 1623.668009] seq_printf+0x7c/0xa0
[ 1623.675530] r_show+0xc8/0xf8
[ 1623.682558] seq_read+0x330/0x440
[ 1623.689877] proc_reg_read+0x78/0xd0
[ 1623.697346] __vfs_read+0x60/0x1a0
[ 1623.704564] vfs_read+0x94/0x150
[ 1623.711339] ksys_read+0x6c/0xd8
[ 1623.717939] __arm64_sys_read+0x24/0x30
[ 1623.725077] el0_svc_common+0x120/0x148
[ 1623.732035] el0_svc_handler+0x30/0x40
[ 1623.738757] el0_svc+0x8/0xc
[ 1623.744520] Code: d1000406 aa0103e2 54000149 b4000080 (39400085)
[ 1623.753441] ---[ end trace f91b6a4937de9835 ]---
[ 1623.760871] Kernel panic - not syncing: Fatal exception
[ 1623.768935] SMP: stopping secondary CPUs
[ 1623.775718] Kernel Offset: disabled
[ 1623.781998] CPU features: 0x002,21006008
[ 1623.788777] Memory Limit: none
[ 1623.798329] Starting crashdump kernel...
[ 1623.805202] Bye!
If io_setup is called successful in try_smi_init() but try_smi_init()
goes out_err before calling ipmi_register_smi(), so ipmi_unregister_smi()
will not be called while removing module. It leads to the resource that
allocated in io_setup() can not be freed, but the name(DEVICE_NAME) of
resource is freed while removing the module. It causes use-after-free
when cat /proc/ioports.
Fix this by calling io_cleanup() while try_smi_init() goes to out_err.
and don't call io_cleanup() until io_setup() returns successful to avoid
warning prints.
Fixes: 93c303d2045b ("ipmi_si: Clean up shutdown a bit")
Cc: stable@vger.kernel.org
Reported-by: NuoHan Qiao <qiaonuohan@huawei.com>
Suggested-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com> |
GF_Err stsh_dump(GF_Box *a, FILE * trace)
{
GF_ShadowSyncBox *p;
u32 i;
GF_StshEntry *t;
p = (GF_ShadowSyncBox *)a;
gf_isom_box_dump_start(a, "SyncShadowBox", trace);
fprintf(trace, "EntryCount=\"%d\">\n", gf_list_count(p->entries));
i=0;
while ((t = (GF_StshEntry *)gf_list_enum(p->entries, &i))) {
fprintf(trace, "<SyncShadowEntry ShadowedSample=\"%d\" SyncSample=\"%d\"/>\n", t->shadowedSampleNumber, t->syncSampleNumber);
}
if (!p->size) {
fprintf(trace, "<SyncShadowEntry ShadowedSample=\"\" SyncSample=\"\"/>\n");
}
gf_isom_box_dump_done("SyncShadowBox", a, trace);
return GF_OK;
} | 0 | [
"CWE-125"
] | gpac | bceb03fd2be95097a7b409ea59914f332fb6bc86 | 266,022,548,251,987,950,000,000,000,000,000,000,000 | 19 | fixed 2 possible heap overflows (inc. #1088) |
usm_save_users(const char *token, const char *type)
{
usm_save_users_from_list(userList, token, type);
} | 0 | [
"CWE-415"
] | net-snmp | 5f881d3bf24599b90d67a45cae7a3eb099cd71c9 | 335,775,187,812,769,200,000,000,000,000,000,000,000 | 4 | libsnmp, USM: Introduce a reference count in struct usmStateReference
This patch fixes https://sourceforge.net/p/net-snmp/bugs/2956/. |
static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
struct io_connect *conn = &req->connect;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags ||
sqe->splice_fd_in)
return -EINVAL;
conn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));
conn->addr_len = READ_ONCE(sqe->addr2);
return 0;
} | 0 | [
"CWE-416"
] | linux | e677edbcabee849bfdd43f1602bccbecf736a646 | 207,276,282,919,101,630,000,000,000,000,000,000,000 | 14 | io_uring: fix race between timeout flush and removal
io_flush_timeouts() assumes the timeout isn't in progress of triggering
or being removed/canceled, so it unconditionally removes it from the
timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care
of it.
Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: Jens Axboe <axboe@kernel.dk> |
MagickExport MagickBooleanType XRemoteCommand(Display *display,
const char *window,const char *filename)
{
Atom
remote_atom;
Window
remote_window,
root_window;
assert(filename != (char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
if (display == (Display *) NULL)
display=XOpenDisplay((char *) NULL);
if (display == (Display *) NULL)
{
ThrowXWindowException(XServerError,"UnableToOpenXServer",filename);
return(MagickFalse);
}
remote_atom=XInternAtom(display,"IM_PROTOCOLS",MagickFalse);
remote_window=(Window) NULL;
root_window=XRootWindow(display,XDefaultScreen(display));
if (window != (char *) NULL)
{
/*
Search window hierarchy and identify any clients by name or ID.
*/
if (isdigit((int) ((unsigned char) *window)) != 0)
remote_window=XWindowByID(display,root_window,(Window)
strtol((char *) window,(char **) NULL,0));
if (remote_window == (Window) NULL)
remote_window=XWindowByName(display,root_window,window);
}
if (remote_window == (Window) NULL)
remote_window=XWindowByProperty(display,root_window,remote_atom);
if (remote_window == (Window) NULL)
{
ThrowXWindowException(XServerError,"UnableToConnectToRemoteDisplay",
filename);
return(MagickFalse);
}
/*
Send remote command.
*/
remote_atom=XInternAtom(display,"IM_REMOTE_COMMAND",MagickFalse);
(void) XChangeProperty(display,remote_window,remote_atom,XA_STRING,8,
PropModeReplace,(unsigned char *) filename,(int) strlen(filename));
(void) XSync(display,MagickFalse);
return(MagickTrue);
} | 0 | [
"CWE-401"
] | ImageMagick6 | 13801f5d0bd7a6fdb119682d34946636afdb2629 | 277,627,462,556,875,800,000,000,000,000,000,000,000 | 50 | https://github.com/ImageMagick/ImageMagick/issues/1531 |
int bzrtp_packetUpdateSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber) {
uint32_t CRC;
uint8_t *CRCbuffer;
if (zrtpPacket == NULL) {
return BZRTP_BUILDER_ERROR_INVALIDPACKET;
}
if (zrtpPacket->packetString == NULL) {
return BZRTP_BUILDER_ERROR_INVALIDPACKET;
}
/* update the sequence number field (even if it is probably useless as this function is called just before sending the DHPart2 packet only)*/
zrtpPacket->sequenceNumber = sequenceNumber;
/* update hte sequence number in the packetString */
*(zrtpPacket->packetString+2)= (uint8_t)((sequenceNumber>>8)&0x00FF);
*(zrtpPacket->packetString+3)= (uint8_t)(sequenceNumber&0x00FF);
/* update the CRC */
CRC = bzrtp_CRC32(zrtpPacket->packetString, zrtpPacket->messageLength+ZRTP_PACKET_HEADER_LENGTH);
CRCbuffer = (zrtpPacket->packetString)+(zrtpPacket->messageLength)+ZRTP_PACKET_HEADER_LENGTH;
*CRCbuffer = (uint8_t)((CRC>>24)&0xFF);
CRCbuffer++;
*CRCbuffer = (uint8_t)((CRC>>16)&0xFF);
CRCbuffer++;
*CRCbuffer = (uint8_t)((CRC>>8)&0xFF);
CRCbuffer++;
*CRCbuffer = (uint8_t)(CRC&0xFF);
return 0;
} | 0 | [
"CWE-254",
"CWE-787"
] | bzrtp | bbb1e6e2f467ee4bd7b9a8c800e4f07343d7d99b | 213,483,419,061,573,100,000,000,000,000,000,000,000 | 32 | Add ZRTP Commit packet hvi check on DHPart2 packet reception |
get_cpo_flags(void)
{
reg_cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
reg_cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
} | 0 | [
"CWE-416"
] | vim | 4c13e5e6763c6eb36a343a2b8235ea227202e952 | 108,616,243,878,321,470,000,000,000,000,000,000,000 | 5 | patch 8.2.3949: using freed memory with /\%V
Problem: Using freed memory with /\%V.
Solution: Get the line again after getvvcol(). |
void WebContents::MessageHost(const std::string& channel,
blink::CloneableMessage arguments,
content::RenderFrameHost* render_frame_host) {
TRACE_EVENT1("electron", "WebContents::MessageHost", "channel", channel);
// webContents.emit('ipc-message-host', new Event(), channel, args);
EmitWithSender("ipc-message-host", render_frame_host,
electron::mojom::ElectronApiIPC::InvokeCallback(), channel,
std::move(arguments));
} | 0 | [] | electron | e9fa834757f41c0b9fe44a4dffe3d7d437f52d34 | 76,804,414,255,659,840,000,000,000,000,000,000,000 | 9 | fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33344)
* fix: ensure ElectronBrowser mojo service is only bound to authorized render frames
Notes: no-notes
* refactor: extract electron API IPC to its own mojo interface
* fix: just check main frame not primary main frame
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@salesforce.com> |
ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)
{
return 1;
} | 0 | [
"CWE-703"
] | linux | 6a76f8c0ab19f215af2a3442870eeb5f0e81998d | 109,100,375,652,761,920,000,000,000,000,000,000,000 | 4 | tracing: Fix possible NULL pointer dereferences
Currently set_ftrace_pid and set_graph_function files use seq_lseek
for their fops. However seq_open() is called only for FMODE_READ in
the fops->open() so that if an user tries to seek one of those file
when she open it for writing, it sees NULL seq_file and then panic.
It can be easily reproduced with following command:
$ cd /sys/kernel/debug/tracing
$ echo 1234 | sudo tee -a set_ftrace_pid
In this example, GNU coreutils' tee opens the file with fopen(, "a")
and then the fopen() internally calls lseek().
Link: http://lkml.kernel.org/r/1365663302-2170-1-git-send-email-namhyung@kernel.org
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: stable@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org> |
PHP_FUNCTION(mb_split)
{
char *arg_pattern;
int arg_pattern_len;
php_mb_regex_t *re;
OnigRegion *regs = NULL;
char *string;
OnigUChar *pos, *chunk_pos;
int string_len;
int n, err;
long count = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &arg_pattern, &arg_pattern_len, &string, &string_len, &count) == FAILURE) {
RETURN_FALSE;
}
if (count > 0) {
count--;
}
/* create regex pattern buffer */
if ((re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, MBREX(regex_default_options), MBREX(current_mbctype), MBREX(regex_default_syntax) TSRMLS_CC)) == NULL) {
RETURN_FALSE;
}
array_init(return_value);
chunk_pos = pos = (OnigUChar *)string;
err = 0;
regs = onig_region_new();
/* churn through str, generating array entries as we go */
while (count != 0 && (pos - (OnigUChar *)string) < string_len) {
int beg, end;
err = onig_search(re, (OnigUChar *)string, (OnigUChar *)(string + string_len), pos, (OnigUChar *)(string + string_len), regs, 0);
if (err < 0) {
break;
}
beg = regs->beg[0], end = regs->end[0];
/* add it to the array */
if ((pos - (OnigUChar *)string) < end) {
if (beg < string_len && beg >= (chunk_pos - (OnigUChar *)string)) {
add_next_index_stringl(return_value, (char *)chunk_pos, ((OnigUChar *)(string + beg) - chunk_pos), 1);
--count;
} else {
err = -2;
break;
}
/* point at our new starting point */
chunk_pos = pos = (OnigUChar *)string + end;
} else {
pos++;
}
onig_region_free(regs, 0);
}
onig_region_free(regs, 1);
/* see if we encountered an error */
if (err <= -2) {
OnigUChar err_str[ONIG_MAX_ERROR_MESSAGE_LEN];
onig_error_code_to_str(err_str, err);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex search failure in mbsplit(): %s", err_str);
zval_dtor(return_value);
RETURN_FALSE;
}
/* otherwise we just have one last element to add to the array */
n = ((OnigUChar *)(string + string_len) - chunk_pos);
if (n > 0) {
add_next_index_stringl(return_value, (char *)chunk_pos, n, 1);
} else {
add_next_index_stringl(return_value, "", 0, 1);
}
} | 0 | [
"CWE-415"
] | php-src | 5b597a2e5b28e2d5a52fc1be13f425f08f47cb62 | 209,251,787,211,105,630,000,000,000,000,000,000,000 | 75 | Fix bug #72402: _php_mb_regex_ereg_replace_exec - double free |
ALWAYS_INLINE void CopyAndMayBeInterleave(void* dst, const void* src,
int num_elements) {
if (std::is_same<T, float>::value || kNumOperands < 8) {
memcpy(dst, src, num_elements * sizeof(T));
} else if (std::is_same<T, bfloat16>::value) {
if (num_elements == N) {
CopyAndMayBeInterleaveBfloat16<N>(dst, src, num_elements);
} else {
CopyAndMayBeInterleaveBfloat16<-1>(dst, src, num_elements);
}
} else {
LOG(FATAL) << "Unsupported type";
}
} | 0 | [
"CWE-125"
] | tensorflow | e6cf28c72ba2eb949ca950d834dd6d66bb01cfae | 3,791,299,726,400,630,000,000,000,000,000,000,000 | 14 | Validate that matrix dimension sizes in SparseMatMul are positive.
PiperOrigin-RevId: 401149683
Change-Id: Ib33eafc561a39c8741ece80b2edce6d4aae9a57d |
static void io_req_caches_free(struct io_ring_ctx *ctx)
{
struct io_submit_state *state = &ctx->submit_state;
int nr = 0;
mutex_lock(&ctx->uring_lock);
io_flush_cached_locked_reqs(ctx, state);
while (state->free_list.next) {
struct io_wq_work_node *node;
struct io_kiocb *req;
node = wq_stack_extract(&state->free_list);
req = container_of(node, struct io_kiocb, comp_list);
kmem_cache_free(req_cachep, req);
nr++;
}
if (nr)
percpu_ref_put_many(&ctx->refs, nr);
mutex_unlock(&ctx->uring_lock); | 0 | [
"CWE-416"
] | linux | e677edbcabee849bfdd43f1602bccbecf736a646 | 46,523,828,259,053,820,000,000,000,000,000,000,000 | 21 | io_uring: fix race between timeout flush and removal
io_flush_timeouts() assumes the timeout isn't in progress of triggering
or being removed/canceled, so it unconditionally removes it from the
timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care
of it.
Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: Jens Axboe <axboe@kernel.dk> |
regerror (int errcode, const regex_t *_Restrict_ preg,
char *_Restrict_ errbuf, size_t errbuf_size)
#endif
{
const char *msg;
size_t msg_size;
if (BE (errcode < 0
|| errcode >= (int) (sizeof (__re_error_msgid_idx)
/ sizeof (__re_error_msgid_idx[0])), 0))
/* Only error codes returned by the rest of the code should be passed
to this routine. If we are given anything else, or if other regex
code generates an invalid error code, then the program has a bug.
Dump core so we can fix it. */
abort ();
msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
msg_size = strlen (msg) + 1; /* Includes the null. */
if (BE (errbuf_size != 0, 1))
{
size_t cpy_size = msg_size;
if (BE (msg_size > errbuf_size, 0))
{
cpy_size = errbuf_size - 1;
errbuf[cpy_size] = '\0';
}
memcpy (errbuf, msg, cpy_size);
}
return msg_size;
} | 0 | [
"CWE-19"
] | gnulib | 5513b40999149090987a0341c018d05d3eea1272 | 74,696,180,463,102,810,000,000,000,000,000,000,000 | 33 | Diagnose ERE '()|\1'
Problem reported by Hanno Böck in: http://bugs.gnu.org/21513
* lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep
track of the set of previously-completed subexpressions available
before the first alternative, and restore this set just before
parsing each subsequent alternative. This lets us diagnose the
invalid back-reference in the ERE '()|\1'. |
void ComputeAsync(OpKernelContext* c, DoneCallback done) override {
auto col_params = new CollectiveParams();
auto done_with_cleanup = [col_params, done = std::move(done)]() {
done();
col_params->Unref();
};
core::RefCountPtr<CollectiveGroupResource> resource;
OP_REQUIRES_OK_ASYNC(c, LookupResource(c, HandleFromInput(c, 1), &resource),
done);
Tensor group_assignment = c->input(2);
OP_REQUIRES_OK_ASYNC(
c,
FillCollectiveParams(col_params, group_assignment,
ALL_TO_ALL_COLLECTIVE, resource.get()),
done);
col_params->instance.shape = c->input(0).shape();
VLOG(1) << "CollectiveAllToAll group_size " << col_params->group.group_size
<< " group_key " << col_params->group.group_key << " instance_key "
<< col_params->instance.instance_key;
// Allocate the output tensor, trying to reuse the input.
Tensor* output = nullptr;
OP_REQUIRES_OK_ASYNC(c,
c->forward_input_or_allocate_output(
{0}, 0, col_params->instance.shape, &output),
done_with_cleanup);
Run(c, col_params, std::move(done_with_cleanup));
} | 1 | [
"CWE-416"
] | tensorflow | ca38dab9d3ee66c5de06f11af9a4b1200da5ef75 | 160,769,298,430,772,270,000,000,000,000,000,000,000 | 29 | Fix undefined behavior in CollectiveReduceV2 and others
We should not call done after it's moved.
PiperOrigin-RevId: 400838185
Change-Id: Ifc979740054b8f8c6f4d50acc89472fe60c4fdb1 |
static GIOFlags irssi_ssl_get_flags(GIOChannel *handle)
{
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
return chan->giochan->funcs->io_get_flags(handle);
} | 0 | [
"CWE-20"
] | irssi-proxy | 85bbc05b21678e80423815d2ef1dfe26208491ab | 305,547,825,664,429,420,000,000,000,000,000,000,000 | 6 | Check if an SSL certificate matches the hostname of the server we are connecting to
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@5104 dbcabf3a-b0e7-0310-adc4-f8d773084564 |
Item_result_field(THD *thd): Item_fixed_hybrid(thd), result_field(0) {} | 0 | [
"CWE-617"
] | server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | 230,463,401,046,297,340,000,000,000,000,000,000,000 | 1 | MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...
When doing condition pushdown from HAVING into WHERE,
Item_equal::create_pushable_equalities() calls
item->set_extraction_flag(IMMUTABLE_FL) for constant items.
Then, Item::cleanup_excluding_immutables_processor() checks for this flag
to see if it should call item->cleanup() or leave the item as-is.
The failure happens when a constant item has a non-constant one inside it,
like:
(tbl.col=0 AND impossible_cond)
item->walk(cleanup_excluding_immutables_processor) works in a bottom-up
way so it
1. will call Item_func_eq(tbl.col=0)->cleanup()
2. will not call Item_cond_and->cleanup (as the AND is constant)
This creates an item tree where a fixed Item has an un-fixed Item inside
it which eventually causes an assertion failure.
Fixed by introducing this rule: instead of just calling
item->set_extraction_flag(IMMUTABLE_FL);
we call Item::walk() to set the flag for all sub-items of the item. |
LIBOPENMPT_MODPLUG_API unsigned int ModPlug_SampleName(ModPlugFile* file, unsigned int qual, char* buff)
{
const char* str;
unsigned int retval;
size_t tmpretval;
if(!file) return 0;
str = openmpt_module_get_sample_name(file->mod,qual-1);
if(!str){
if(buff){
*buff = '\0';
}
return 0;
}
tmpretval = strlen(str);
if(tmpretval>=INT_MAX){
tmpretval = INT_MAX-1;
}
retval = (int)tmpretval;
if(buff){
memcpy(buff,str,retval+1);
buff[retval] = '\0';
}
openmpt_free_string(str);
return retval;
} | 1 | [
"CWE-120",
"CWE-295"
] | openmpt | 927688ddab43c2b203569de79407a899e734fabe | 304,330,570,972,204,900,000,000,000,000,000,000,000 | 25 | [Fix] libmodplug: C API: Limit the length of strings copied to the output buffer of ModPlug_InstrumentName() and ModPlug_SampleName() to 32 bytes (including terminating null) as is done by original libmodplug. This avoids potential buffer overflows in software relying on this limit instead of querying the required buffer size beforehand. libopenmpt can return strings longer than 32 bytes here beacuse the internal limit of 32 bytes applies to strings encoded in arbitrary character encodings but the API returns them converted to UTF-8, which can be longer. (reported by Antonio Morales Maldonado of Semmle Security Research Team)
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@12127 56274372-70c3-4bfc-bfc3-4c3a0b034d27 |
static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xmlNodePtr parent, int check_class_map TSRMLS_DC)
{
xmlNodePtr node = NULL;
int add_type = 0;
/* Special handling of class SoapVar */
if (data &&
Z_TYPE_P(data) == IS_OBJECT &&
Z_OBJCE_P(data) == soap_var_class_entry) {
zval **ztype, **zdata, **zns, **zstype, **zname, **znamens;
encodePtr enc = NULL;
HashTable *ht = Z_OBJPROP_P(data);
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
Z_TYPE_PP(zstype) == IS_STRING) {
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
Z_TYPE_PP(zns) == IS_STRING) {
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
} else {
zns = NULL;
enc = get_encoder_ex(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zstype), Z_STRLEN_PP(zstype));
}
if (enc == NULL && SOAP_GLOBAL(typemap)) {
encodePtr *new_enc;
smart_str nscat = {0};
if (zns != NULL) {
smart_str_appendl(&nscat, Z_STRVAL_PP(zns), Z_STRLEN_PP(zns));
smart_str_appendc(&nscat, ':');
}
smart_str_appendl(&nscat, Z_STRVAL_PP(zstype), Z_STRLEN_PP(zstype));
smart_str_0(&nscat);
if (zend_hash_find(SOAP_GLOBAL(typemap), nscat.c, nscat.len + 1, (void**)&new_enc) == SUCCESS) {
enc = *new_enc;
}
smart_str_free(&nscat);
}
}
if (enc == NULL) {
enc = get_conversion(Z_LVAL_P(*ztype));
}
if (enc == NULL) {
enc = encode;
}
if (zend_hash_find(ht, "enc_value", sizeof("enc_value"), (void **)&zdata) == FAILURE) {
node = master_to_xml(enc, NULL, style, parent TSRMLS_CC);
} else {
node = master_to_xml(enc, *zdata, style, parent TSRMLS_CC);
}
if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
Z_TYPE_PP(zstype) == IS_STRING) {
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
Z_TYPE_PP(zns) == IS_STRING) {
set_ns_and_type_ex(node, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
} else {
set_ns_and_type_ex(node, NULL, Z_STRVAL_PP(zstype));
}
}
}
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS &&
Z_TYPE_PP(zname) == IS_STRING) {
xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname)));
}
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS &&
Z_TYPE_PP(znamens) == IS_STRING) {
xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens));
xmlSetNs(node, nsp);
}
} else {
if (check_class_map && SOAP_GLOBAL(class_map) && data &&
Z_TYPE_P(data) == IS_OBJECT &&
!Z_OBJPROP_P(data)->nApplyCount) {
zend_class_entry *ce = Z_OBJCE_P(data);
HashPosition pos;
zval **tmp;
char *type_name = NULL;
uint type_len;
ulong idx;
for (zend_hash_internal_pointer_reset_ex(SOAP_GLOBAL(class_map), &pos);
zend_hash_get_current_data_ex(SOAP_GLOBAL(class_map), (void **) &tmp, &pos) == SUCCESS;
zend_hash_move_forward_ex(SOAP_GLOBAL(class_map), &pos)) {
if (Z_TYPE_PP(tmp) == IS_STRING &&
ce->name_length == Z_STRLEN_PP(tmp) &&
zend_binary_strncasecmp(ce->name, ce->name_length, Z_STRVAL_PP(tmp), ce->name_length, ce->name_length) == 0 &&
zend_hash_get_current_key_ex(SOAP_GLOBAL(class_map), &type_name, &type_len, &idx, 0, &pos) == HASH_KEY_IS_STRING) {
/* TODO: namespace isn't stored */
encodePtr enc = NULL;
if (SOAP_GLOBAL(sdl)) {
enc = get_encoder(SOAP_GLOBAL(sdl), SOAP_GLOBAL(sdl)->target_ns, type_name);
if (!enc) {
enc = find_encoder_by_type_name(SOAP_GLOBAL(sdl), type_name);
}
}
if (enc) {
if (encode != enc && style == SOAP_LITERAL) {
add_type = 1;
}
encode = enc;
}
break;
}
}
}
if (encode == NULL) {
encode = get_conversion(UNKNOWN_TYPE);
}
if (SOAP_GLOBAL(typemap) && encode->details.type_str) {
smart_str nscat = {0};
encodePtr *new_enc;
if (encode->details.ns) {
smart_str_appends(&nscat, encode->details.ns);
smart_str_appendc(&nscat, ':');
}
smart_str_appends(&nscat, encode->details.type_str);
smart_str_0(&nscat);
if (zend_hash_find(SOAP_GLOBAL(typemap), nscat.c, nscat.len + 1, (void**)&new_enc) == SUCCESS) {
encode = *new_enc;
}
smart_str_free(&nscat);
}
if (encode->to_xml) {
node = encode->to_xml(&encode->details, data, style, parent TSRMLS_CC);
if (add_type) {
set_ns_and_type(node, &encode->details);
}
}
}
return node;
} | 0 | [
"CWE-19"
] | php-src | 75f40ae1f3a7ca837d230f099627d121f9b3a32f | 252,233,743,729,302,600,000,000,000,000,000,000,000 | 142 | Fixed bug #69293 |
static inline int ext4_journal_blocks_per_page(struct inode *inode)
{
if (EXT4_JOURNAL(inode) != NULL)
return jbd2_journal_blocks_per_page(inode);
return 0;
} | 0 | [
"CWE-703"
] | linux | 744692dc059845b2a3022119871846e74d4f6e11 | 92,376,974,635,352,080,000,000,000,000,000,000,000 | 6 | ext4: use ext4_get_block_write in buffer write
Allocate uninitialized extent before ext4 buffer write and
convert the extent to initialized after io completes.
The purpose is to make sure an extent can only be marked
initialized after it has been written with new data so
we can safely drop the i_mutex lock in ext4 DIO read without
exposing stale data. This helps to improve multi-thread DIO
read performance on high-speed disks.
Skip the nobh and data=journal mount cases to make things simple for now.
Signed-off-by: Jiaying Zhang <jiayingz@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> |
**/
CImg<T>& noise(const double sigma, const unsigned int noise_type=0) {
if (is_empty()) return *this;
const Tfloat vmin = (Tfloat)cimg::type<T>::min(), vmax = (Tfloat)cimg::type<T>::max();
Tfloat nsigma = (Tfloat)sigma, m = 0, M = 0;
if (nsigma==0 && noise_type!=3) return *this;
if (nsigma<0 || noise_type==2) m = (Tfloat)min_max(M);
if (nsigma<0) nsigma = (Tfloat)(-nsigma*(M-m)/100.);
switch (noise_type) {
case 0 : { // Gaussian noise
cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {
ulongT rng = (cimg::_rand(),cimg::rng());
#if cimg_use_openmp!=0
rng+=omp_get_thread_num();
#endif
cimg_pragma_openmp(for)
cimg_rofoff(*this,off) {
Tfloat val = (Tfloat)(_data[off] + nsigma*cimg::grand(&rng));
if (val>vmax) val = vmax;
if (val<vmin) val = vmin;
_data[off] = (T)val;
}
cimg::srand(rng);
}
} break;
case 1 : { // Uniform noise
cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {
ulongT rng = (cimg::_rand(),cimg::rng());
#if cimg_use_openmp!=0
rng+=omp_get_thread_num();
#endif
cimg_pragma_openmp(for)
cimg_rofoff(*this,off) {
Tfloat val = (Tfloat)(_data[off] + nsigma*cimg::rand(-1,1,&rng));
if (val>vmax) val = vmax;
if (val<vmin) val = vmin;
_data[off] = (T)val;
}
cimg::srand(rng);
}
} break;
case 2 : { // Salt & Pepper noise
if (nsigma<0) nsigma = -nsigma;
if (M==m) {
if (cimg::type<T>::is_float()) { --m; ++M; }
else { m = (Tfloat)cimg::type<T>::min(); M = (Tfloat)cimg::type<T>::max(); }
}
cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {
ulongT rng = (cimg::_rand(),cimg::rng());
#if cimg_use_openmp!=0
rng+=omp_get_thread_num();
#endif
cimg_pragma_openmp(for)
cimg_rofoff(*this,off) if (cimg::rand(100,&rng)<nsigma) _data[off] = (T)(cimg::rand(1,&rng)<0.5?M:m);
cimg::srand(rng);
}
} break;
case 3 : { // Poisson Noise
cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {
ulongT rng = (cimg::_rand(),cimg::rng());
#if cimg_use_openmp!=0
rng+=omp_get_thread_num();
#endif
cimg_pragma_openmp(for)
cimg_rofoff(*this,off) _data[off] = (T)cimg::prand(_data[off],&rng);
cimg::srand(rng);
}
} break;
case 4 : { // Rice noise
const Tfloat sqrt2 = (Tfloat)std::sqrt(2.);
cimg_pragma_openmp(parallel cimg_openmp_if_size(size(),131072)) {
ulongT rng = (cimg::_rand(),cimg::rng());
#if cimg_use_openmp!=0
rng+=omp_get_thread_num();
#endif
cimg_pragma_openmp(for)
cimg_rofoff(*this,off) {
const Tfloat
val0 = (Tfloat)_data[off]/sqrt2,
re = (Tfloat)(val0 + nsigma*cimg::grand(&rng)),
im = (Tfloat)(val0 + nsigma*cimg::grand(&rng));
Tfloat val = cimg::hypot(re,im);
if (val>vmax) val = vmax;
if (val<vmin) val = vmin;
_data[off] = (T)val;
}
cimg::srand(rng);
}
} break;
default :
throw CImgArgumentException(_cimg_instance
"noise(): Invalid specified noise type %d "
"(should be { 0=gaussian | 1=uniform | 2=salt&Pepper | 3=poisson }).",
cimg_instance,
noise_type);
}
return *this; | 0 | [
"CWE-119",
"CWE-787"
] | CImg | ac8003393569aba51048c9d67e1491559877b1d1 | 124,412,820,514,077,160,000,000,000,000,000,000,000 | 102 | . |
void whenInputIs(const char *json) {
strcpy(_jsonString, json);
_result = QuotedString::extractFrom(_jsonString, &_trailing);
} | 0 | [
"CWE-415",
"CWE-119"
] | ArduinoJson | 5e7b9ec688d79e7b16ec7064e1d37e8481a31e72 | 72,690,751,321,299,230,000,000,000,000,000,000,000 | 4 | Fix buffer overflow (pull request #81) |
read_yin_rpc_action(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin,
int options, struct unres_schema *unres)
{
struct ly_ctx *ctx = module->ctx;
struct lyxml_elem *sub, *next, root;
struct lys_node *node = NULL;
struct lys_node *retval;
struct lys_node_rpc_action *rpc;
int r;
int c_tpdf = 0, c_ftrs = 0, c_input = 0, c_output = 0, c_ext = 0;
void *reallocated;
if (!strcmp(yin->name, "action") && (module->version < 2)) {
LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, parent, "action");
return NULL;
}
/* init */
memset(&root, 0, sizeof root);
rpc = calloc(1, sizeof *rpc);
LY_CHECK_ERR_RETURN(!rpc, LOGMEM(ctx), NULL);
rpc->nodetype = (!strcmp(yin->name, "rpc") ? LYS_RPC : LYS_ACTION);
rpc->prev = (struct lys_node *)rpc;
retval = (struct lys_node *)rpc;
if (read_yin_common(module, parent, retval, LYEXT_PAR_NODE, yin, OPT_IDENT | OPT_MODULE, unres)) {
goto error;
}
LOGDBG(LY_LDGYIN, "parsing %s statement \"%s\"", yin->name, retval->name);
/* insert the node into the schema tree */
if (lys_node_addchild(parent, lys_main_module(module), retval, options)) {
goto error;
}
/* process rpc's specific children */
LY_TREE_FOR_SAFE(yin->child, next, sub) {
if (strcmp(sub->ns->value, LY_NSYIN)) {
/* extension */
YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions",
rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
c_ext++;
continue;
} else if (!strcmp(sub->name, "input")) {
if (c_input) {
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
goto error;
}
c_input++;
lyxml_unlink_elem(ctx, sub, 2);
lyxml_add_child(ctx, &root, sub);
} else if (!strcmp(sub->name, "output")) {
if (c_output) {
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
goto error;
}
c_output++;
lyxml_unlink_elem(ctx, sub, 2);
lyxml_add_child(ctx, &root, sub);
/* data statements */
} else if (!strcmp(sub->name, "grouping")) {
lyxml_unlink_elem(ctx, sub, 2);
lyxml_add_child(ctx, &root, sub);
/* array counters */
} else if (!strcmp(sub->name, "typedef")) {
YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, rpc->tpdf_size, "typedefs",
rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
c_tpdf++;
} else if (!strcmp(sub->name, "if-feature")) {
YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features",
rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
c_ftrs++;
} else {
LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
goto error;
}
}
/* middle part - process nodes with cardinality of 0..n except the data nodes */
if (c_tpdf) {
rpc->tpdf = calloc(c_tpdf, sizeof *rpc->tpdf);
LY_CHECK_ERR_GOTO(!rpc->tpdf, LOGMEM(ctx), error);
}
if (c_ftrs) {
rpc->iffeature = calloc(c_ftrs, sizeof *rpc->iffeature);
LY_CHECK_ERR_GOTO(!rpc->iffeature, LOGMEM(ctx), error);
}
if (c_ext) {
/* some extensions may be already present from the substatements */
reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
retval->ext = reallocated;
/* init memory */
memset(&retval->ext[retval->ext_size], 0, c_ext * sizeof *retval->ext);
}
LY_TREE_FOR_SAFE(yin->child, next, sub) {
if (strcmp(sub->ns->value, LY_NSYIN)) {
/* extension */
r = lyp_yin_fill_ext(retval, LYEXT_PAR_NODE, 0, 0, module, sub, &retval->ext, &retval->ext_size, unres);
if (r) {
goto error;
}
} else if (!strcmp(sub->name, "typedef")) {
r = fill_yin_typedef(module, retval, sub, &rpc->tpdf[rpc->tpdf_size], unres);
rpc->tpdf_size++;
if (r) {
goto error;
}
} else if (!strcmp(sub->name, "if-feature")) {
r = fill_yin_iffeature(retval, 0, sub, &rpc->iffeature[rpc->iffeature_size], unres);
rpc->iffeature_size++;
if (r) {
goto error;
}
}
}
lyp_reduce_ext_list(&retval->ext, retval->ext_size, c_ext + retval->ext_size);
/* last part - process data nodes */
LY_TREE_FOR_SAFE(root.child, next, sub) {
if (!strcmp(sub->name, "grouping")) {
node = read_yin_grouping(module, retval, sub, options, unres);
} else if (!strcmp(sub->name, "input") || !strcmp(sub->name, "output")) {
node = read_yin_input_output(module, retval, sub, options, unres);
}
if (!node) {
goto error;
}
lyxml_free(ctx, sub);
}
return retval;
error:
lys_node_free(retval, NULL, 0);
while (root.child) {
lyxml_free(ctx, root.child);
}
return NULL;
} | 1 | [
"CWE-617"
] | libyang | 5ce30801f9ccc372bbe9b7c98bb5324b15fb010a | 290,765,227,726,777,740,000,000,000,000,000,000,000 | 149 | schema tree BUGFIX freeing nodes with no module set
Context must be passed explicitly for these cases.
Fixes #1452 |
*/
void netdev_run_todo(void)
{
struct list_head list;
/* Snapshot list, allow later requests */
list_replace_init(&net_todo_list, &list);
__rtnl_unlock();
/* Wait for rcu callbacks to finish before next phase */
if (!list_empty(&list))
rcu_barrier();
while (!list_empty(&list)) {
struct net_device *dev
= list_first_entry(&list, struct net_device, todo_list);
list_del(&dev->todo_list);
if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
pr_err("network todo '%s' but state %d\n",
dev->name, dev->reg_state);
dump_stack();
continue;
}
dev->reg_state = NETREG_UNREGISTERED;
netdev_wait_allrefs(dev);
/* paranoia */
BUG_ON(netdev_refcnt_read(dev));
BUG_ON(!list_empty(&dev->ptype_all));
BUG_ON(!list_empty(&dev->ptype_specific));
WARN_ON(rcu_access_pointer(dev->ip_ptr));
WARN_ON(rcu_access_pointer(dev->ip6_ptr));
#if IS_ENABLED(CONFIG_DECNET)
WARN_ON(dev->dn_ptr);
#endif
if (dev->priv_destructor)
dev->priv_destructor(dev);
if (dev->needs_free_netdev)
free_netdev(dev);
/* Report a network device has been unregistered */
rtnl_lock();
dev_net(dev)->dev_unreg_count--;
__rtnl_unlock();
wake_up(&netdev_unregistering_wq);
/* Free network device */
kobject_put(&dev->dev.kobj);
} | 0 | [
"CWE-416"
] | linux | a4270d6795b0580287453ea55974d948393e66ef | 22,324,617,964,793,677,000,000,000,000,000,000,000 | 54 | net-gro: fix use-after-free read in napi_gro_frags()
If a network driver provides to napi_gro_frags() an
skb with a page fragment of exactly 14 bytes, the call
to gro_pull_from_frag0() will 'consume' the fragment
by calling skb_frag_unref(skb, 0), and the page might
be freed and reused.
Reading eth->h_proto at the end of napi_frags_skb() might
read mangled data, or crash under specific debugging features.
BUG: KASAN: use-after-free in napi_frags_skb net/core/dev.c:5833 [inline]
BUG: KASAN: use-after-free in napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
Read of size 2 at addr ffff88809366840c by task syz-executor599/8957
CPU: 1 PID: 8957 Comm: syz-executor599 Not tainted 5.2.0-rc1+ #32
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
__kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
kasan_report+0x12/0x20 mm/kasan/common.c:614
__asan_report_load_n_noabort+0xf/0x20 mm/kasan/generic_report.c:142
napi_frags_skb net/core/dev.c:5833 [inline]
napi_gro_frags+0xc6f/0xd10 net/core/dev.c:5841
tun_get_user+0x2f3c/0x3ff0 drivers/net/tun.c:1991
tun_chr_write_iter+0xbd/0x156 drivers/net/tun.c:2037
call_write_iter include/linux/fs.h:1872 [inline]
do_iter_readv_writev+0x5f8/0x8f0 fs/read_write.c:693
do_iter_write fs/read_write.c:970 [inline]
do_iter_write+0x184/0x610 fs/read_write.c:951
vfs_writev+0x1b3/0x2f0 fs/read_write.c:1015
do_writev+0x15b/0x330 fs/read_write.c:1058
Fixes: a50e233c50db ("net-gro: restore frag0 optimization")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net> |
_rsvg_node_rect_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
{
double x, y, w, h, rx, ry;
GString *d = NULL;
RsvgNodeRect *rect = (RsvgNodeRect *) self;
char buf[G_ASCII_DTOSTR_BUF_SIZE];
x = _rsvg_css_normalize_length (&rect->x, ctx, 'h');
y = _rsvg_css_normalize_length (&rect->y, ctx, 'v');
w = _rsvg_css_normalize_length (&rect->w, ctx, 'h');
h = _rsvg_css_normalize_length (&rect->h, ctx, 'v');
rx = _rsvg_css_normalize_length (&rect->rx, ctx, 'h');
ry = _rsvg_css_normalize_length (&rect->ry, ctx, 'v');
if (w == 0. || h == 0.)
return;
if (rect->got_rx)
rx = rx;
else
rx = ry;
if (rect->got_ry)
ry = ry;
else
ry = rx;
if (rx > fabs (w / 2.))
rx = fabs (w / 2.);
if (ry > fabs (h / 2.))
ry = fabs (h / 2.);
if (rx == 0)
ry = 0;
else if (ry == 0)
rx = 0;
/* emulate a rect using a path */
d = g_string_new ("M ");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y));
g_string_append (d, " H ");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + w - rx));
g_string_append (d, " A");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), ry));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 1.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + w));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y + ry));
g_string_append (d, " V ");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y + h - ry));
g_string_append (d, " A");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), ry));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 1.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + w - rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y + h));
g_string_append (d, " H ");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + rx));
g_string_append (d, " A");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), ry));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 1.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y + h - ry));
g_string_append (d, " V ");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y + ry));
g_string_append (d, " A");
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), ry));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 0.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), 1.));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x + rx));
g_string_append_c (d, ' ');
g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y));
g_string_append (d, " Z");
rsvg_state_reinherit_top (ctx, self->state, dominate);
rsvg_render_path (ctx, d->str);
g_string_free (d, TRUE);
} | 0 | [] | librsvg | 34c95743ca692ea0e44778e41a7c0a129363de84 | 333,641,024,300,082,000,000,000,000,000,000,000,000 | 120 | Store node type separately in RsvgNode
The node name (formerly RsvgNode:type) cannot be used to infer
the sub-type of RsvgNode that we're dealing with, since for unknown
elements we put type = node-name. This lead to a (potentially exploitable)
crash e.g. when the element name started with "fe" which tricked
the old code into considering it as a RsvgFilterPrimitive.
CVE-2011-3146
https://bugzilla.gnome.org/show_bug.cgi?id=658014 |
int main( int argc, char *argv[] )
{
((void) argc);
((void) argv);
printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
"POLARSSL_SHA1_C and/or POLARSSL_FS_IO "
"and/or POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C "
"not defined.\n");
return( 0 );
} | 0 | [
"CWE-310"
] | polarssl | 43f9799ce61c6392a014d0a2ea136b4b3a9ee194 | 90,466,284,684,496,110,000,000,000,000,000,000,000 | 11 | RSA blinding on CRT operations to counter timing attacks |
static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
/* reset data partitioning here, to ensure GetBitContexts from previous
* packets do not get used. */
h->data_partitioning = 0;
/* end of stream, output what is still in the buffers */
if (buf_size == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
// FIXME factorize this with the output code below
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f.key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
}
return buf_index;
}
if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (is_extra(side, side_size))
ff_h264_decode_extradata(h, side, side_size);
}
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
if (is_extra(buf, buf_size))
return ff_h264_decode_extradata(h, buf, buf_size);
}
buf_index = decode_nal_units(h, buf, buf_size, 0);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF ||
buf_size >= 4 && !memcmp("Q264", buf, 4))
return buf_size;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
ff_h264_field_end(h, 0);
/* Wait for second field. */
*got_frame = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f.flags |= AV_FRAME_FLAG_CORRUPT;
ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, h->er.mbskip_table,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
}
assert(pict->buf[0] || !*got_frame);
return get_consumed_bytes(buf_index, buf_size);
} | 0 | [
"CWE-703"
] | FFmpeg | e8714f6f93d1a32f4e4655209960afcf4c185214 | 50,742,525,884,772,620,000,000,000,000,000,000,000 | 111 | avcodec/h264: Clear delayed_pic on deallocation
Fixes use of freed memory
Fixes: case5_av_frame_copy_props.mp4
Found-by: Michal Zalewski <lcamtuf@coredump.cx>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> |
ephy_embed_constructed (GObject *object)
{
EphyEmbed *embed = (EphyEmbed*)object;
GtkWidget *scrolled_window;
WebKitWebView *web_view;
WebKitWebInspector *inspector;
GtkWidget *inspector_sw;
embed->priv->top_widgets_vbox = GTK_BOX (gtk_vbox_new (FALSE, 0));
gtk_box_pack_start (GTK_BOX (embed), GTK_WIDGET (embed->priv->top_widgets_vbox),
FALSE, FALSE, 0);
gtk_widget_show (GTK_WIDGET (embed->priv->top_widgets_vbox));
scrolled_window = GTK_WIDGET (embed->priv->scrolled_window);
gtk_container_add (GTK_CONTAINER (embed), scrolled_window);
gtk_widget_show (scrolled_window);
web_view = WEBKIT_WEB_VIEW (ephy_web_view_new ());
embed->priv->web_view = web_view;
gtk_container_add (GTK_CONTAINER (embed->priv->scrolled_window), GTK_WIDGET (web_view));
gtk_widget_show (GTK_WIDGET (web_view));
g_object_connect (web_view,
"signal::notify::load-status", G_CALLBACK (load_status_changed_cb), embed,
"signal::resource-request-starting", G_CALLBACK (resource_request_starting_cb), embed,
"signal::hovering-over-link", G_CALLBACK (hovering_over_link_cb), embed,
"signal::download-requested", G_CALLBACK (download_requested_cb), embed,
"signal::notify::zoom-level", G_CALLBACK (zoom_changed_cb), embed,
"signal::notify::title", G_CALLBACK (title_changed_cb), embed,
"signal::notify::uri", G_CALLBACK (uri_changed_cb), embed,
NULL);
embed->priv->inspector_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
inspector = webkit_web_view_get_inspector (web_view);
inspector_sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (inspector_sw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (embed->priv->inspector_window),
inspector_sw);
gtk_window_set_title (GTK_WINDOW (embed->priv->inspector_window),
_("Web Inspector"));
gtk_window_set_default_size (GTK_WINDOW (embed->priv->inspector_window),
600, 400);
g_signal_connect (embed->priv->inspector_window,
"delete-event", G_CALLBACK (gtk_widget_hide_on_delete),
NULL);
g_object_connect (inspector,
"signal::inspect-web-view", G_CALLBACK (ephy_embed_inspect_web_view_cb),
inspector_sw,
"signal::show-window", G_CALLBACK (ephy_embed_inspect_show_cb),
embed->priv->inspector_window,
"signal::close-window", G_CALLBACK (ephy_embed_inspect_close_cb),
embed->priv->inspector_window,
NULL);
ephy_embed_prefs_add_embed (embed);
embed->priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ()));
} | 0 | [] | epiphany | 3e0f7dea754381c5ad11a06ccc62eb153382b498 | 330,917,332,220,432,850,000,000,000,000,000,000,000 | 63 | Report broken certs through the padlock icon
This uses a new feature in libsoup that reports through a
SoupMessageFlag whether the message is talking to a server that has a
trusted server.
Bug #600663 |
static void label_wrapper(GtkWidget *widget, gpointer data_unused)
{
if (GTK_IS_CONTAINER(widget))
{
gtk_container_foreach((GtkContainer*)widget, label_wrapper, NULL);
return;
}
if (GTK_IS_LABEL(widget))
{
GtkLabel *label = (GtkLabel*)widget;
gtk_label_set_line_wrap(label, 1);
//const char *txt = gtk_label_get_label(label);
//log("label '%s' set to wrap", txt);
}
} | 0 | [
"CWE-200"
] | libreport | 257578a23d1537a2d235aaa2b1488ee4f818e360 | 322,904,341,619,545,800,000,000,000,000,000,000,000 | 15 | wizard: fix save users changes after reviewing dump dir files
If the user reviewed the dump dir's files during reporting the crash, the
changes was thrown away and original data was passed to the bugzilla bug
report.
report-gtk saves the first text view buffer and then reloads data from the
reported problem directory, which causes that the changes made to those text
views are thrown away.
Function save_text_if_changed(), except of saving text, also reload the files
from dump dir and update gui state from the dump dir. The commit moves the
reloading and updating gui functions away from this function.
Related to rhbz#1270235
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com> |
IntegrationCodecClient::makeHeaderOnlyRequest(const Http::HeaderMap& headers) {
auto response = std::make_unique<IntegrationStreamDecoder>(dispatcher_);
Http::StreamEncoder& encoder = newStream(*response);
encoder.getStream().addCallbacks(*response);
encoder.encodeHeaders(headers, true);
flushWrite();
return response;
} | 0 | [
"CWE-400",
"CWE-703"
] | envoy | afc39bea36fd436e54262f150c009e8d72db5014 | 166,477,898,120,565,630,000,000,000,000,000,000,000 | 8 | Track byteSize of HeaderMap internally.
Introduces a cached byte size updated internally in HeaderMap. The value
is stored as an optional, and is cleared whenever a non-const pointer or
reference to a HeaderEntry is accessed. The cached value can be set with
refreshByteSize() which performs an iteration over the HeaderMap to sum
the size of each key and value in the HeaderMap.
Signed-off-by: Asra Ali <asraa@google.com> |
compare_field_marshal (const void *a, const void *b)
{
const guint32 *a_values = a;
const guint32 *b_values = b;
return a_values [MONO_FIELD_MARSHAL_PARENT] - b_values [MONO_FIELD_MARSHAL_PARENT];
} | 0 | [
"CWE-20"
] | mono | 4905ef1130feb26c3150b28b97e4a96752e0d399 | 228,137,666,534,560,170,000,000,000,000,000,000,000 | 7 | Handle invalid instantiation of generic methods.
* verify.c: Add new function to internal verifier API to check
method instantiations.
* reflection.c (mono_reflection_bind_generic_method_parameters):
Check the instantiation before returning it.
Fixes #655847 |
rpc_C_DecryptUpdate (CK_X_FUNCTION_LIST *self,
p11_rpc_message *msg)
{
CK_SESSION_HANDLE session;
CK_BYTE_PTR encrypted_part;
CK_ULONG encrypted_part_len;
CK_BYTE_PTR part;
CK_ULONG part_len;
BEGIN_CALL (DecryptUpdate);
IN_ULONG (session);
IN_BYTE_ARRAY (encrypted_part, encrypted_part_len);
IN_BYTE_BUFFER (part, part_len);
PROCESS_CALL ((self, session, encrypted_part, encrypted_part_len, part, &part_len));
OUT_BYTE_ARRAY (part, part_len);
END_CALL;
} | 0 | [
"CWE-190"
] | p11-kit | 5307a1d21a50cacd06f471a873a018d23ba4b963 | 301,879,961,568,798,100,000,000,000,000,000,000,000 | 17 | Check for arithmetic overflows before allocating |
getsize_gnutar(
dle_t *dle,
int level,
time_t dumpsince,
char **errmsg)
{
int pipefd = -1, nullfd = -1;
pid_t dumppid;
off_t size = (off_t)-1;
FILE *dumpout = NULL;
char *incrname = NULL;
char *basename = NULL;
char *dirname = NULL;
char *inputname = NULL;
FILE *in = NULL;
FILE *out = NULL;
char *line = NULL;
char *cmd = NULL;
char *command = NULL;
char dumptimestr[80];
struct tm *gmtm;
int nb_exclude = 0;
int nb_include = 0;
GPtrArray *argv_ptr = g_ptr_array_new();
char *file_exclude = NULL;
char *file_include = NULL;
times_t start_time;
int infd, outfd;
ssize_t nb;
char buf[32768];
char *qdisk = quote_string(dle->disk);
char *gnutar_list_dir;
amwait_t wait_status;
char tmppath[PATH_MAX];
if (level > 9)
return -2; /* planner will not even consider this level */
if(dle->exclude_file) nb_exclude += dle->exclude_file->nb_element;
if(dle->exclude_list) nb_exclude += dle->exclude_list->nb_element;
if(dle->include_file) nb_include += dle->include_file->nb_element;
if(dle->include_list) nb_include += dle->include_list->nb_element;
if(nb_exclude > 0) file_exclude = build_exclude(dle, 0);
if(nb_include > 0) file_include = build_include(dle, 0);
gnutar_list_dir = getconf_str(CNF_GNUTAR_LIST_DIR);
if (strlen(gnutar_list_dir) == 0)
gnutar_list_dir = NULL;
if (gnutar_list_dir) {
char number[NUM_STR_SIZE];
int baselevel;
char *sdisk = sanitise_filename(dle->disk);
basename = vstralloc(gnutar_list_dir,
"/",
g_options->hostname,
sdisk,
NULL);
amfree(sdisk);
g_snprintf(number, SIZEOF(number), "%d", level);
incrname = vstralloc(basename, "_", number, ".new", NULL);
unlink(incrname);
/*
* Open the listed incremental file from the previous level. Search
* backward until one is found. If none are found (which will also
* be true for a level 0), arrange to read from /dev/null.
*/
baselevel = level;
infd = -1;
while (infd == -1) {
if (--baselevel >= 0) {
g_snprintf(number, SIZEOF(number), "%d", baselevel);
inputname = newvstralloc(inputname,
basename, "_", number, NULL);
} else {
inputname = newstralloc(inputname, "/dev/null");
}
if ((infd = open(inputname, O_RDONLY)) == -1) {
*errmsg = vstrallocf(_("gnutar: error opening %s: %s"),
inputname, strerror(errno));
dbprintf("%s\n", *errmsg);
if (baselevel < 0) {
goto common_exit;
}
amfree(*errmsg);
}
}
/*
* Copy the previous listed incremental file to the new one.
*/
if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) {
*errmsg = vstrallocf(_("opening %s: %s"),
incrname, strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) {
if (full_write(outfd, &buf, (size_t)nb) < (size_t)nb) {
*errmsg = vstrallocf(_("writing to %s: %s"),
incrname, strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
}
if (nb < 0) {
*errmsg = vstrallocf(_("reading from %s: %s"),
inputname, strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
if (close(infd) != 0) {
*errmsg = vstrallocf(_("closing %s: %s"),
inputname, strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
if (close(outfd) != 0) {
*errmsg = vstrallocf(_("closing %s: %s"),
incrname, strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
amfree(inputname);
amfree(basename);
}
gmtm = gmtime(&dumpsince);
g_snprintf(dumptimestr, SIZEOF(dumptimestr),
"%04d-%02d-%02d %2d:%02d:%02d GMT",
gmtm->tm_year + 1900, gmtm->tm_mon+1, gmtm->tm_mday,
gmtm->tm_hour, gmtm->tm_min, gmtm->tm_sec);
dirname = amname_to_dirname(dle->device);
cmd = vstralloc(amlibexecdir, "/", "runtar", NULL);
g_ptr_array_add(argv_ptr, stralloc("runtar"));
if (g_options->config)
g_ptr_array_add(argv_ptr, stralloc(g_options->config));
else
g_ptr_array_add(argv_ptr, stralloc("NOCONFIG"));
#ifdef GNUTAR
g_ptr_array_add(argv_ptr, stralloc(GNUTAR));
#else
g_ptr_array_add(argv_ptr, stralloc("tar"));
#endif
g_ptr_array_add(argv_ptr, stralloc("--create"));
g_ptr_array_add(argv_ptr, stralloc("--file"));
g_ptr_array_add(argv_ptr, stralloc("/dev/null"));
/* use --numeric-owner for estimates, to reduce the number of user/group
* lookups required */
g_ptr_array_add(argv_ptr, stralloc("--numeric-owner"));
g_ptr_array_add(argv_ptr, stralloc("--directory"));
canonicalize_pathname(dirname, tmppath);
g_ptr_array_add(argv_ptr, stralloc(tmppath));
g_ptr_array_add(argv_ptr, stralloc("--one-file-system"));
if (gnutar_list_dir) {
g_ptr_array_add(argv_ptr, stralloc("--listed-incremental"));
g_ptr_array_add(argv_ptr, stralloc(incrname));
} else {
g_ptr_array_add(argv_ptr, stralloc("--incremental"));
g_ptr_array_add(argv_ptr, stralloc("--newer"));
g_ptr_array_add(argv_ptr, stralloc(dumptimestr));
}
#ifdef ENABLE_GNUTAR_ATIME_PRESERVE
/* --atime-preserve causes gnutar to call
* utime() after reading files in order to
* adjust their atime. However, utime()
* updates the file's ctime, so incremental
* dumps will think the file has changed. */
g_ptr_array_add(argv_ptr, stralloc("--atime-preserve"));
#endif
g_ptr_array_add(argv_ptr, stralloc("--sparse"));
g_ptr_array_add(argv_ptr, stralloc("--ignore-failed-read"));
g_ptr_array_add(argv_ptr, stralloc("--totals"));
if(file_exclude) {
g_ptr_array_add(argv_ptr, stralloc("--exclude-from"));
g_ptr_array_add(argv_ptr, stralloc(file_exclude));
}
if(file_include) {
g_ptr_array_add(argv_ptr, stralloc("--files-from"));
g_ptr_array_add(argv_ptr, stralloc(file_include));
}
else {
g_ptr_array_add(argv_ptr, stralloc("."));
}
g_ptr_array_add(argv_ptr, NULL);
start_time = curclock();
if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
*errmsg = vstrallocf(_("Cannot access /dev/null : %s"),
strerror(errno));
dbprintf("%s\n", *errmsg);
goto common_exit;
}
command = (char *)g_ptr_array_index(argv_ptr, 0);
dumppid = pipespawnv(cmd, STDERR_PIPE, 0,
&nullfd, &nullfd, &pipefd, (char **)argv_ptr->pdata);
dumpout = fdopen(pipefd,"r");
if (!dumpout) {
error(_("Can't fdopen: %s"), strerror(errno));
/*NOTREACHED*/
}
for(size = (off_t)-1; (line = agets(dumpout)) != NULL; free(line)) {
if (line[0] == '\0')
continue;
dbprintf("%s\n", line);
size = handle_dumpline(line);
if(size > (off_t)-1) {
amfree(line);
while ((line = agets(dumpout)) != NULL) {
if (line[0] != '\0') {
break;
}
amfree(line);
}
if (line != NULL) {
dbprintf("%s\n", line);
break;
}
break;
}
}
amfree(line);
dbprintf(".....\n");
dbprintf(_("estimate time for %s level %d: %s\n"),
qdisk,
level,
walltime_str(timessub(curclock(), start_time)));
if(size == (off_t)-1) {
*errmsg = vstrallocf(_("no size line match in %s output"),
command);
dbprintf(_("%s for %s\n"), *errmsg, qdisk);
dbprintf(".....\n");
} else if(size == (off_t)0 && level == 0) {
dbprintf(_("possible %s problem -- is \"%s\" really empty?\n"),
command, dle->disk);
dbprintf(".....\n");
}
dbprintf(_("estimate size for %s level %d: %lld KB\n"),
qdisk,
level,
(long long)size);
kill(-dumppid, SIGTERM);
dbprintf(_("waiting for %s \"%s\" child\n"),
command, qdisk);
waitpid(dumppid, &wait_status, 0);
if (WIFSIGNALED(wait_status)) {
*errmsg = vstrallocf(_("%s terminated with signal %d: see %s"),
cmd, WTERMSIG(wait_status), dbfn());
} else if (WIFEXITED(wait_status)) {
if (WEXITSTATUS(wait_status) != 0) {
*errmsg = vstrallocf(_("%s exited with status %d: see %s"),
cmd, WEXITSTATUS(wait_status), dbfn());
} else {
/* Normal exit */
}
} else {
*errmsg = vstrallocf(_("%s got bad exit: see %s"),
cmd, dbfn());
}
dbprintf(_("after %s %s wait\n"), command, qdisk);
common_exit:
if (incrname) {
unlink(incrname);
}
amfree(incrname);
amfree(basename);
amfree(dirname);
amfree(inputname);
g_ptr_array_free_full(argv_ptr);
amfree(qdisk);
amfree(cmd);
amfree(file_exclude);
amfree(file_include);
aclose(nullfd);
afclose(dumpout);
afclose(in);
afclose(out);
return size;
} | 1 | [
"CWE-264"
] | amanda | 4bf5b9b356848da98560ffbb3a07a9cb5c4ea6d7 | 280,849,713,252,082,280,000,000,000,000,000,000,000 | 303 | * Add a /etc/amanda-security.conf file
git-svn-id: https://svn.code.sf.net/p/amanda/code/amanda/branches/3_3@6486 a8d146d6-cc15-0410-8900-af154a0219e0 |
static void remove_driver(gpointer data, gpointer user_data)
{
struct btd_adapter_driver *driver = data;
struct btd_adapter *adapter = user_data;
if (driver->remove)
driver->remove(adapter);
} | 0 | [
"CWE-862",
"CWE-863"
] | bluez | b497b5942a8beb8f89ca1c359c54ad67ec843055 | 90,547,164,310,594,600,000,000,000,000,000,000,000 | 8 | adapter: Fix storing discoverable setting
discoverable setting shall only be store when changed via Discoverable
property and not when discovery client set it as that be considered
temporary just for the lifetime of the discovery. |
void __audit_syscall_exit(int success, long return_code)
{
struct task_struct *tsk = current;
struct audit_context *context;
if (success)
success = AUDITSC_SUCCESS;
else
success = AUDITSC_FAILURE;
context = audit_take_context(tsk, success, return_code);
if (!context)
return;
if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT)
audit_log_exit(context, tsk);
context->in_syscall = 0;
context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
if (!list_empty(&context->killed_trees))
audit_kill_trees(&context->killed_trees);
audit_free_names(context);
unroll_tree_refs(context, NULL, 0);
audit_free_aux(context);
context->aux = NULL;
context->aux_pids = NULL;
context->target_pid = 0;
context->target_sid = 0;
context->sockaddr_len = 0;
context->type = 0;
context->fds[0] = -1;
if (context->state != AUDIT_RECORD_CONTEXT) {
kfree(context->filterkey);
context->filterkey = NULL;
}
tsk->audit_context = context;
} | 0 | [
"CWE-362"
] | linux | 43761473c254b45883a64441dd0bc85a42f3645c | 48,568,783,940,998,030,000,000,000,000,000,000,000 | 39 | audit: fix a double fetch in audit_log_single_execve_arg()
There is a double fetch problem in audit_log_single_execve_arg()
where we first check the execve(2) argumnets for any "bad" characters
which would require hex encoding and then re-fetch the arguments for
logging in the audit record[1]. Of course this leaves a window of
opportunity for an unsavory application to munge with the data.
This patch reworks things by only fetching the argument data once[2]
into a buffer where it is scanned and logged into the audit
records(s). In addition to fixing the double fetch, this patch
improves on the original code in a few other ways: better handling
of large arguments which require encoding, stricter record length
checking, and some performance improvements (completely unverified,
but we got rid of some strlen() calls, that's got to be a good
thing).
As part of the development of this patch, I've also created a basic
regression test for the audit-testsuite, the test can be tracked on
GitHub at the following link:
* https://github.com/linux-audit/audit-testsuite/issues/25
[1] If you pay careful attention, there is actually a triple fetch
problem due to a strnlen_user() call at the top of the function.
[2] This is a tiny white lie, we do make a call to strnlen_user()
prior to fetching the argument data. I don't like it, but due to the
way the audit record is structured we really have no choice unless we
copy the entire argument at once (which would require a rather
wasteful allocation). The good news is that with this patch the
kernel no longer relies on this strnlen_user() value for anything
beyond recording it in the log, we also update it with a trustworthy
value whenever possible.
Reported-by: Pengfei Wang <wpengfeinudt@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Paul Moore <paul@paul-moore.com> |
static void burl_append_encode_psnde (buffer * const b, const char * const str, const size_t len)
{
/* percent-encodes everything except unreserved - . 0-9 A-Z _ a-z ~ plus /
* unless already percent-encoded (does not double-encode) */
/* Note: not checking for invalid UTF-8 */
char * const p = buffer_string_prepare_append(b, len*3);
unsigned int n1, n2;
int j = 0;
for (unsigned int i = 0; i < len; ++i, ++j) {
if (str[i]=='%' && li_cton(str[i+1], n1) && li_cton(str[i+2], n2)) {
const unsigned int x = (n1 << 4) | n2;
if (burl_is_unreserved((int)x)) {
p[j] = (char)x;
}
else { /* leave UTF-8, control chars, and required chars encoded */
p[j] = '%';
p[++j] = str[i+1];
p[++j] = str[i+2];
}
i+=2;
}
else if (burl_is_unreserved(str[i]) || str[i] == '/') {
p[j] = str[i];
}
else {
p[j] = '%';
p[++j] = hex_chars_uc[(str[i] >> 4) & 0xF];
p[++j] = hex_chars_uc[str[i] & 0xF];
}
}
buffer_commit(b, j);
} | 0 | [
"CWE-190"
] | lighttpd1.4 | 32120d5b8b3203fc21ccb9eafb0eaf824bb59354 | 166,366,569,464,953,420,000,000,000,000,000,000,000 | 32 | [core] fix abort in http-parseopts (fixes #2945)
fix abort in server.http-parseopts with url-path-2f-decode enabled
(thx stze)
x-ref:
"Security - SIGABRT during GET request handling with url-path-2f-decode enabled"
https://redmine.lighttpd.net/issues/2945 |
connection_worker (void *data)
{
struct worker_data *worker = data;
struct connection *conn = worker->conn;
char *name = worker->name;
debug ("starting worker thread %s", name);
threadlocal_new_server_thread ();
threadlocal_set_name (name);
free (worker);
while (!quit && connection_get_status (conn) > 0)
protocol_recv_request_send_reply (conn);
debug ("exiting worker thread %s", threadlocal_get_name ());
free (name);
return NULL;
} | 0 | [
"CWE-406"
] | nbdkit | 22b30adb796bb6dca264a38598f80b8a234ff978 | 23,646,936,490,584,070,000,000,000,000,000,000,000 | 17 | server: Wait until handshake complete before calling .open callback
Currently we call the plugin .open callback as soon as we receive a
TCP connection:
$ nbdkit -fv --tls=require --tls-certificates=tests/pki null \
--run "telnet localhost 10809"
[...]
Trying ::1...
Connected to localhost.
Escape character is '^]'.
nbdkit: debug: accepted connection
nbdkit: debug: null: open readonly=0 ◀ NOTE
nbdkit: null[1]: debug: newstyle negotiation: flags: global 0x3
NBDMAGICIHAVEOPT
In plugins such as curl, guestfs, ssh, vddk and others we do a
considerable amount of work in the .open callback (such as making a
remote connection or launching an appliance). Therefore we are
providing an easy Denial of Service / Amplification Attack for
unauthorized clients to cause a lot of work to be done for only the
cost of a simple TCP 3 way handshake.
This commit moves the call to the .open callback after the NBD
handshake has mostly completed. In particular TLS authentication must
be complete before we will call into the plugin.
It is unlikely that there are plugins which really depend on the
current behaviour of .open (which I found surprising even though I
guess I must have written it). If there are then we could add a new
.connect callback or similar to allow plugins to get control at the
earlier point in the connection.
After this change you can see that the .open callback is not called
from just a simple TCP connection:
$ ./nbdkit -fv --tls=require --tls-certificates=tests/pki null \
--run "telnet localhost 10809"
[...]
Trying ::1...
Connected to localhost.
Escape character is '^]'.
nbdkit: debug: accepted connection
nbdkit: null[1]: debug: newstyle negotiation: flags: global 0x3
NBDMAGICIHAVEOPT
xx
nbdkit: null[1]: debug: newstyle negotiation: client flags: 0xd0a7878
nbdkit: null[1]: error: client requested unknown flags 0xd0a7878
Connection closed by foreign host.
nbdkit: debug: null: unload plugin
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit c05686f9577fa91b6a3a4d8c065954ca6fc3fd62)
(cherry picked from commit e06cde00659ff97182173d0e33fff784041bcb4a) |
TPMI_RH_HIERARCHY_POLICY_Unmarshal(TPMI_RH_HIERARCHY_POLICY *target, BYTE **buffer, INT32 *size)
{
TPM_RC rc = TPM_RC_SUCCESS;
TPMI_RH_HIERARCHY_POLICY orig_target = *target; // libtpms added
if (rc == TPM_RC_SUCCESS) {
rc = TPM_HANDLE_Unmarshal(target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
switch (*target) {
case TPM_RH_OWNER:
case TPM_RH_PLATFORM:
case TPM_RH_ENDORSEMENT:
case TPM_RH_LOCKOUT:
break;
default:
{
BOOL isNotHP = (*target < TPM_RH_ACT_0) || (*target > TPM_RH_ACT_F);
if (isNotHP) {
rc = TPM_RC_VALUE;
*target = orig_target; // libtpms added
}
}
}
}
return rc;
} | 0 | [
"CWE-787"
] | libtpms | 5cc98a62dc6f204dcf5b87c2ee83ac742a6a319b | 179,377,473,036,452,500,000,000,000,000,000,000,000 | 27 | tpm2: Restore original value if unmarshalled value was illegal
Restore the original value of the memory location where data from
a stream was unmarshalled and the unmarshalled value was found to
be illegal. The goal is to not keep illegal values in memory.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> |
static int parse_events(ASS_Renderer *render_priv, ASS_Event *event)
{
TextInfo *text_info = &render_priv->text_info;
ASS_Drawing *drawing = NULL;
unsigned code;
char *p, *q;
int i;
p = event->Text;
// Event parsing.
while (1) {
// get next char, executing style override
// this affects render_context
code = 0;
while (*p) {
if ((*p == '{') && (q = strchr(p, '}'))) {
while (p < q)
p = parse_tag(render_priv, p, q, 1.);
assert(*p == '}');
p++;
} else if (render_priv->state.drawing_scale) {
q = p;
if (*p == '{')
q++;
while ((*q != '{') && (*q != 0))
q++;
if (!drawing) {
drawing = ass_drawing_new(render_priv->library,
render_priv->ftlibrary);
if (!drawing)
return 1;
}
ass_drawing_set_text(drawing, p, q - p);
code = 0xfffc; // object replacement character
p = q;
break;
} else {
code = get_next_char(render_priv, &p);
break;
}
}
if (code == 0)
break;
// face could have been changed in get_next_char
if (!render_priv->state.font) {
free_render_context(render_priv);
ass_drawing_free(drawing);
return 1;
}
if (text_info->length >= text_info->max_glyphs) {
// Raise maximum number of glyphs
text_info->max_glyphs *= 2;
text_info->glyphs =
realloc(text_info->glyphs,
sizeof(GlyphInfo) * text_info->max_glyphs);
}
GlyphInfo *info = &text_info->glyphs[text_info->length];
// Clear current GlyphInfo
memset(info, 0, sizeof(GlyphInfo));
// Parse drawing
if (drawing && drawing->text) {
drawing->scale_x = render_priv->state.scale_x *
render_priv->font_scale;
drawing->scale_y = render_priv->state.scale_y *
render_priv->font_scale;
drawing->scale = render_priv->state.drawing_scale;
drawing->pbo = render_priv->state.pbo;
info->drawing = drawing;
drawing = NULL;
}
// Fill glyph information
info->symbol = code;
info->font = render_priv->state.font;
if (!info->drawing)
ass_cache_inc_ref(info->font);
for (i = 0; i < 4; ++i) {
uint32_t clr = render_priv->state.c[i];
// VSFilter compatibility: apply fade only when it's positive
if (render_priv->state.fade > 0)
change_alpha(&clr,
mult_alpha(_a(clr), render_priv->state.fade), 1.);
info->c[i] = clr;
}
info->effect_type = render_priv->state.effect_type;
info->effect_timing = render_priv->state.effect_timing;
info->effect_skip_timing = render_priv->state.effect_skip_timing;
info->font_size =
render_priv->state.font_size * render_priv->font_scale;
info->be = render_priv->state.be;
info->blur = render_priv->state.blur;
info->shadow_x = render_priv->state.shadow_x;
info->shadow_y = render_priv->state.shadow_y;
info->scale_x = info->orig_scale_x = render_priv->state.scale_x;
info->scale_y = info->orig_scale_y = render_priv->state.scale_y;
info->border_style = render_priv->state.border_style;
info->border_x= render_priv->state.border_x;
info->border_y = render_priv->state.border_y;
info->hspacing = render_priv->state.hspacing;
info->bold = render_priv->state.bold;
info->italic = render_priv->state.italic;
info->flags = render_priv->state.flags;
info->frx = render_priv->state.frx;
info->fry = render_priv->state.fry;
info->frz = render_priv->state.frz;
info->fax = render_priv->state.fax;
info->fay = render_priv->state.fay;
if (!info->drawing)
fix_glyph_scaling(render_priv, info);
text_info->length++;
render_priv->state.effect_type = EF_NONE;
render_priv->state.effect_timing = 0;
render_priv->state.effect_skip_timing = 0;
}
ass_drawing_free(drawing);
return 0;
} | 0 | [
"CWE-125"
] | libass | f4f48950788b91c6a30029cc28a240b834713ea7 | 5,011,780,649,530,983,300,000,000,000,000,000,000 | 130 | Fix line wrapping mode 0/3 bugs
This fixes two separate bugs:
a) Don't move a linebreak into the first symbol. This results in a empty
line at the front, which does not help to equalize line lengths at all.
Instead, merge line with the second one.
b) When moving a linebreak into a symbol that already is a break, the
number of lines must be decremented. Otherwise, uninitialized memory
is possibly used for later layout operations.
Found by fuzzer test case
id:000085,sig:11,src:003377+003350,op:splice,rep:8.
This might also affect and hopefully fix libass#229.
v2: change semantics according to review |
int args_from_file(char *file, int *argc, char **argv[])
{
FILE *fp;
int num,i;
unsigned int len;
static char *buf=NULL;
static char **arg=NULL;
char *p;
fp=fopen(file,"r");
if (fp == NULL)
return(0);
if (fseek(fp,0,SEEK_END)==0)
len=ftell(fp), rewind(fp);
else len=-1;
if (len<=0)
{
fclose(fp);
return(0);
}
*argc=0;
*argv=NULL;
if (buf != NULL) OPENSSL_free(buf);
buf=(char *)OPENSSL_malloc(len+1);
if (buf == NULL) return(0);
len=fread(buf,1,len,fp);
if (len <= 1) return(0);
buf[len]='\0';
i=0;
for (p=buf; *p; p++)
if (*p == '\n') i++;
if (arg != NULL) OPENSSL_free(arg);
arg=(char **)OPENSSL_malloc(sizeof(char *)*(i*2));
*argv=arg;
num=0;
p=buf;
for (;;)
{
if (!*p) break;
if (*p == '#') /* comment line */
{
while (*p && (*p != '\n')) p++;
continue;
}
/* else we have a line */
*(arg++)=p;
num++;
while (*p && ((*p != ' ') && (*p != '\t') && (*p != '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
*(p++)='\0';
continue;
}
/* else it is a tab or space */
p++;
while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
p++;
continue;
}
*(arg++)=p++;
num++;
while (*p && (*p != '\n')) p++;
if (!*p) break;
/* else *p == '\n' */
*(p++)='\0';
}
*argc=num;
return(1);
} | 0 | [] | openssl | a70da5b3ecc3160368529677006801c58cb369db | 123,889,054,148,728,440,000,000,000,000,000,000,000 | 81 | New functions to check a hostname email or IP address against a
certificate. Add options to s_client, s_server and x509 utilities
to print results of checks. |
GF_Err gf_seng_encode_from_string(GF_SceneEngine *seng, u16 ESID, Bool disable_aggregation, char *auString, gf_seng_callback callback)
{
GF_StreamContext *sc;
u32 i;
GF_Err e;
i = 0;
while ((sc = (GF_StreamContext*)gf_list_enum(seng->ctx->streams, &i))) {
sc->current_au_count = gf_list_count(sc->AUs);
sc->disable_aggregation = disable_aggregation;
}
seng->loader.flags |= GF_SM_LOAD_CONTEXT_READY;
seng->loader.force_es_id = ESID;
/* We need to create an empty AU for the parser to correctly parse a LASeR Command without SceneUnit */
sc = gf_list_get(seng->ctx->streams, 0);
if (sc->codec_id == GF_CODECID_DIMS) {
gf_seng_create_new_au(sc, 0);
}
e = gf_sm_load_string(&seng->loader, auString, 0);
if (e) goto exit;
i = 0;
while ((sc = (GF_StreamContext*)gf_list_enum(seng->ctx->streams, &i))) {
sc->disable_aggregation = 0;
}
e = gf_sm_live_encode_scene_au(seng, callback, 0);
exit:
return e;
} | 0 | [
"CWE-787"
] | gpac | ea1eca00fd92fa17f0e25ac25652622924a9a6a0 | 204,152,504,287,730,500,000,000,000,000,000,000,000 | 31 | fixed #2138 |
unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
LodePNGState* state,
const unsigned char* in, size_t insize)
{
*out = 0;
decodeGeneric(out, w, h, state, in, insize);
if(state->error) return state->error;
if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color))
{
/*same color type, no copying or converting of data needed*/
/*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype
the raw image has to the end user*/
if(!state->decoder.color_convert)
{
state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);
if(state->error) return state->error;
}
}
else
{
/*color conversion needed; sort of copy of the data*/
unsigned char* data = *out;
size_t outsize;
/*TODO: check if this works according to the statement in the documentation: "The converter can convert
from greyscale input color type, to 8-bit greyscale or greyscale with alpha"*/
if(!(state->info_raw.colortype == LCT_RGB || state->info_raw.colortype == LCT_RGBA)
&& !(state->info_raw.bitdepth == 8))
{
return 56; /*unsupported color mode conversion*/
}
outsize = lodepng_get_raw_size(*w, *h, &state->info_raw);
*out = (unsigned char*)calloc(outsize, sizeof(unsigned char));
if(!(*out))
{
state->error = 83; /*alloc fail*/
}
else state->error = lodepng_convert(*out, data, &state->info_raw,
&state->info_png.color, *w, *h);
free(data);
}
return state->error;
} | 0 | [
"CWE-401"
] | FreeRDP | 9fee4ae076b1ec97b97efb79ece08d1dab4df29a | 308,047,229,401,259,540,000,000,000,000,000,000,000 | 44 | Fixed #5645: realloc return handling |
theme_adium_append_message (EmpathyChatView *view,
EmpathyMessage *msg)
{
EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (view);
EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
EmpathyContact *sender;
TpMessage *tp_msg;
TpAccount *account;
gchar *body_escaped;
const gchar *name;
const gchar *contact_id;
EmpathyAvatar *avatar;
const gchar *avatar_filename = NULL;
gint64 timestamp;
const gchar *html = NULL;
const gchar *func;
const gchar *service_name;
GString *message_classes = NULL;
gboolean is_backlog;
gboolean consecutive;
gboolean action;
if (priv->pages_loading != 0) {
queue_item (&priv->message_queue, QUEUED_MESSAGE, msg, NULL);
return;
}
/* Get information */
sender = empathy_message_get_sender (msg);
account = empathy_contact_get_account (sender);
service_name = empathy_protocol_name_to_display_name
(tp_account_get_protocol (account));
if (service_name == NULL)
service_name = tp_account_get_protocol (account);
timestamp = empathy_message_get_timestamp (msg);
body_escaped = theme_adium_parse_body (theme,
empathy_message_get_body (msg),
empathy_message_get_token (msg));
name = empathy_contact_get_logged_alias (sender);
contact_id = empathy_contact_get_id (sender);
action = (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION);
/* If this is a /me probably */
if (action) {
gchar *str;
if (priv->data->version >= 4 || !priv->data->custom_template) {
str = g_strdup_printf ("<span class='actionMessageUserName'>%s</span>"
"<span class='actionMessageBody'>%s</span>",
name, body_escaped);
} else {
str = g_strdup_printf ("*%s*", body_escaped);
}
g_free (body_escaped);
body_escaped = str;
}
/* Get the avatar filename, or a fallback */
avatar = empathy_contact_get_avatar (sender);
if (avatar) {
avatar_filename = avatar->filename;
}
if (!avatar_filename) {
if (empathy_contact_is_user (sender)) {
avatar_filename = priv->data->default_outgoing_avatar_filename;
} else {
avatar_filename = priv->data->default_incoming_avatar_filename;
}
if (!avatar_filename) {
if (!priv->data->default_avatar_filename) {
priv->data->default_avatar_filename =
empathy_filename_from_icon_name (EMPATHY_IMAGE_AVATAR_DEFAULT,
GTK_ICON_SIZE_DIALOG);
}
avatar_filename = priv->data->default_avatar_filename;
}
}
/* We want to join this message with the last one if
* - senders are the same contact,
* - last message was recieved recently,
* - last message and this message both are/aren't backlog, and
* - DisableCombineConsecutive is not set in theme's settings */
is_backlog = empathy_message_is_backlog (msg);
consecutive = empathy_contact_equal (priv->last_contact, sender) &&
(timestamp - priv->last_timestamp < MESSAGE_JOIN_PERIOD) &&
(is_backlog == priv->last_is_backlog) &&
!tp_asv_get_boolean (priv->data->info,
"DisableCombineConsecutive", NULL);
/* Define message classes */
message_classes = g_string_new ("message");
if (!priv->has_focus && !is_backlog) {
if (!priv->has_unread_message) {
g_string_append (message_classes, " firstFocus");
priv->has_unread_message = TRUE;
}
g_string_append (message_classes, " focus");
}
if (is_backlog) {
g_string_append (message_classes, " history");
}
if (consecutive) {
g_string_append (message_classes, " consecutive");
}
if (empathy_contact_is_user (sender)) {
g_string_append (message_classes, " outgoing");
} else {
g_string_append (message_classes, " incoming");
}
if (empathy_message_should_highlight (msg)) {
g_string_append (message_classes, " mention");
}
if (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY) {
g_string_append (message_classes, " autoreply");
}
if (action) {
g_string_append (message_classes, " action");
}
/* FIXME: other classes:
* status - the message is a status change
* event - the message is a notification of something happening
* (for example, encryption being turned on)
* %status% - See %status% in theme_adium_append_html ()
*/
/* This is slightly a hack, but it's the only way to add
* arbitrary data to messages in the HTML. We add another
* class called "x-empathy-message-id-*" to the message. This
* way, we can remove the unread marker for this specific
* message later. */
tp_msg = empathy_message_get_tp_message (msg);
if (tp_msg != NULL) {
guint32 id;
gboolean valid;
id = tp_message_get_pending_message_id (tp_msg, &valid);
if (valid) {
g_string_append_printf (message_classes,
" x-empathy-message-id-%u", id);
}
}
/* Define javascript function to use */
if (consecutive) {
func = priv->allow_scrolling ? "appendNextMessage" : "appendNextMessageNoScroll";
} else {
func = priv->allow_scrolling ? "appendMessage" : "appendMessageNoScroll";
}
if (empathy_contact_is_user (sender)) {
/* out */
if (is_backlog) {
/* context */
html = consecutive ? priv->data->out_nextcontext_html : priv->data->out_context_html;
} else {
/* content */
html = consecutive ? priv->data->out_nextcontent_html : priv->data->out_content_html;
}
/* remove all the unread marks when we are sending a message */
theme_adium_remove_all_focus_marks (theme);
} else {
/* in */
if (is_backlog) {
/* context */
html = consecutive ? priv->data->in_nextcontext_html : priv->data->in_context_html;
} else {
/* content */
html = consecutive ? priv->data->in_nextcontent_html : priv->data->in_content_html;
}
}
theme_adium_append_html (theme, func, html, body_escaped,
avatar_filename, name, contact_id,
service_name, message_classes->str,
timestamp, is_backlog, empathy_contact_is_user (sender));
/* Keep the sender of the last displayed message */
if (priv->last_contact) {
g_object_unref (priv->last_contact);
}
priv->last_contact = g_object_ref (sender);
priv->last_timestamp = timestamp;
priv->last_is_backlog = is_backlog;
g_free (body_escaped);
g_string_free (message_classes, TRUE);
} | 1 | [
"CWE-79"
] | empathy | 739aca418457de752be13721218aaebc74bd9d36 | 254,126,956,197,139,700,000,000,000,000,000,000,000 | 189 | theme_adium_append_message: escape alias before displaying it
Not doing so can lead to nasty HTML injection from hostile users.
https://bugzilla.gnome.org/show_bug.cgi?id=662035 |
int jpc_mqenc_dump(jpc_mqenc_t *mqenc, FILE *out)
{
fprintf(out, "AREG = %08x, CREG = %08x, CTREG = %d\n",
mqenc->areg, mqenc->creg, mqenc->ctreg);
fprintf(out, "IND = %02d, MPS = %d, QEVAL = %04x\n",
*mqenc->curctx - jpc_mqstates, (*mqenc->curctx)->mps,
(*mqenc->curctx)->qeval);
return 0;
} | 0 | [
"CWE-189"
] | jasper | 3c55b399c36ef46befcb21e4ebc4799367f89684 | 279,512,385,696,181,100,000,000,000,000,000,000,000 | 9 | At many places in the code, jas_malloc or jas_recalloc was being
invoked with the size argument being computed in a manner that would not
allow integer overflow to be detected. Now, these places in the code
have been modified to use special-purpose memory allocation functions
(e.g., jas_alloc2, jas_alloc3, jas_realloc2) that check for overflow.
This should fix many security problems. |
void gf_bs_get_content_no_truncate(GF_BitStream *bs, u8 **output, u32 *outSize, u32 *alloc_size)
{
/*only in WRITE MEM mode*/
if (!bs || bs->bsmode != GF_BITSTREAM_WRITE_DYN) return;
if (bs->on_block_out && bs->position>bs->bytes_out) {
bs->on_block_out(bs->usr_data, bs->original, (u32) (bs->position - bs->bytes_out) );
}
if (!bs->position && !bs->nbBits) {
if (!alloc_size) {
*output = NULL;
gf_free(bs->original);
} else {
*alloc_size = (u32) bs->size;
*output = bs->original;
}
*outSize = 0;
} else {
if (alloc_size) {
/*Align our buffer or we're dead!*/
gf_bs_align(bs);
*alloc_size = (u32) bs->size;
*outSize = (u32) bs->position;
*output = bs->original;
} else {
s32 copy = BS_CutBuffer(bs);
if (copy < 0) {
*output = NULL;
} else
*output = bs->original;
*outSize = (u32) bs->size;
}
}
bs->original = NULL;
bs->size = 0;
bs->position = 0;
} | 0 | [
"CWE-617",
"CWE-703"
] | gpac | 9ea93a2ec8f555ceed1ee27294cf94822f14f10f | 59,916,282,446,479,570,000,000,000,000,000,000,000 | 38 | fixed #2165 |
ConnectionImpl::Http2Options::~Http2Options() { nghttp2_option_del(options_); } | 0 | [
"CWE-400",
"CWE-703"
] | envoy | afc39bea36fd436e54262f150c009e8d72db5014 | 198,459,834,070,422,160,000,000,000,000,000,000,000 | 1 | Track byteSize of HeaderMap internally.
Introduces a cached byte size updated internally in HeaderMap. The value
is stored as an optional, and is cleared whenever a non-const pointer or
reference to a HeaderEntry is accessed. The cached value can be set with
refreshByteSize() which performs an iteration over the HeaderMap to sum
the size of each key and value in the HeaderMap.
Signed-off-by: Asra Ali <asraa@google.com> |
HttpConnectionManagerFilterConfigFactory::createFilterFactoryFromProtoTyped(
const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
proto_config,
Server::Configuration::FactoryContext& context) {
Utility::Singletons singletons = Utility::createSingletons(context);
auto filter_config = Utility::createConfig(
proto_config, context, *singletons.date_provider_, *singletons.route_config_provider_manager_,
*singletons.scoped_routes_config_provider_manager_, *singletons.http_tracer_manager_,
*singletons.filter_config_provider_manager_);
// This lambda captures the shared_ptrs created above, thus preserving the
// reference count.
// Keep in mind the lambda capture list **doesn't** determine the destruction order, but it's fine
// as these captured objects are also global singletons.
return [singletons, filter_config, &context](Network::FilterManager& filter_manager) -> void {
filter_manager.addReadFilter(Network::ReadFilterSharedPtr{new Http::ConnectionManagerImpl(
*filter_config, context.drainDecision(), context.api().randomGenerator(),
context.httpContext(), context.runtime(), context.localInfo(), context.clusterManager(),
context.overloadManager(), context.dispatcher().timeSource())});
};
} | 0 | [
"CWE-22"
] | envoy | 5333b928d8bcffa26ab19bf018369a835f697585 | 104,434,376,709,652,400,000,000,000,000,000,000,000 | 22 | Implement handling of escaped slash characters in URL path
Fixes: CVE-2021-29492
Signed-off-by: Yan Avlasov <yavlasov@google.com> |
bool Smb4KGlobal::removeHost( Smb4KHost *host )
{
Q_ASSERT( host );
bool removed = false;
mutex.lock();
int index = p->hostsList.indexOf( host );
if ( index != -1 )
{
// The host was found. Remove it.
delete p->hostsList.takeAt( index );
removed = true;
}
else
{
// Try harder to find the host.
Smb4KHost *h = findHost( host->hostName(), host->workgroupName() );
if ( h )
{
index = p->hostsList.indexOf( h );
if ( index != -1 )
{
delete p->hostsList.takeAt( index );
removed = true;
}
else
{
// Do nothing
}
}
else
{
// Do nothing
}
delete host;
}
mutex.unlock();
return removed;
} | 0 | [
"CWE-20"
] | smb4k | 71554140bdaede27b95dbe4c9b5a028a83c83cce | 31,771,744,220,585,670,000,000,000,000,000,000,000 | 47 | Find the mount/umount commands in the helper
Instead of trusting what we get passed in
CVE-2017-8849 |
static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
const char *link)
{
int err;
err = ovl_want_write(dentry);
if (!err) {
err = ovl_create_or_link(dentry, mode, rdev, link, NULL);
ovl_drop_write(dentry);
}
return err;
} | 0 | [
"CWE-20"
] | linux | 11f3710417d026ea2f4fcf362d866342c5274185 | 318,524,285,698,415,850,000,000,000,000,000,000,000 | 13 | ovl: verify upper dentry before unlink and rename
Unlink and rename in overlayfs checked the upper dentry for staleness by
verifying upper->d_parent against upperdir. However the dentry can go
stale also by being unhashed, for example.
Expand the verification to actually look up the name again (under parent
lock) and check if it matches the upper dentry. This matches what the VFS
does before passing the dentry to filesytem's unlink/rename methods, which
excludes any inconsistency caused by overlayfs.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> |
static int __init gadget_cfs_init(void)
{
int ret;
config_group_init(&gadget_subsys.su_group);
ret = configfs_register_subsystem(&gadget_subsys);
return ret;
} | 0 | [
"CWE-125"
] | linux | 15753588bcd4bbffae1cca33c8ced5722477fe1f | 248,131,798,148,840,600,000,000,000,000,000,000,000 | 9 | USB: gadget: fix illegal array access in binding with UDC
FuzzUSB (a variant of syzkaller) found an illegal array access
using an incorrect index while binding a gadget with UDC.
Reference: https://www.spinics.net/lists/linux-usb/msg194331.html
This bug occurs when a size variable used for a buffer
is misused to access its strcpy-ed buffer.
Given a buffer along with its size variable (taken from user input),
from which, a new buffer is created using kstrdup().
Due to the original buffer containing 0 value in the middle,
the size of the kstrdup-ed buffer becomes smaller than that of the original.
So accessing the kstrdup-ed buffer with the same size variable
triggers memory access violation.
The fix makes sure no zero value in the buffer,
by comparing the strlen() of the orignal buffer with the size variable,
so that the access to the kstrdup-ed buffer is safe.
BUG: KASAN: slab-out-of-bounds in gadget_dev_desc_UDC_store+0x1ba/0x200
drivers/usb/gadget/configfs.c:266
Read of size 1 at addr ffff88806a55dd7e by task syz-executor.0/17208
CPU: 2 PID: 17208 Comm: syz-executor.0 Not tainted 5.6.8 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xce/0x128 lib/dump_stack.c:118
print_address_description.constprop.4+0x21/0x3c0 mm/kasan/report.c:374
__kasan_report+0x131/0x1b0 mm/kasan/report.c:506
kasan_report+0x12/0x20 mm/kasan/common.c:641
__asan_report_load1_noabort+0x14/0x20 mm/kasan/generic_report.c:132
gadget_dev_desc_UDC_store+0x1ba/0x200 drivers/usb/gadget/configfs.c:266
flush_write_buffer fs/configfs/file.c:251 [inline]
configfs_write_file+0x2f1/0x4c0 fs/configfs/file.c:283
__vfs_write+0x85/0x110 fs/read_write.c:494
vfs_write+0x1cd/0x510 fs/read_write.c:558
ksys_write+0x18a/0x220 fs/read_write.c:611
__do_sys_write fs/read_write.c:623 [inline]
__se_sys_write fs/read_write.c:620 [inline]
__x64_sys_write+0x73/0xb0 fs/read_write.c:620
do_syscall_64+0x9e/0x510 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Signed-off-by: Kyungtae Kim <kt0755@gmail.com>
Reported-and-tested-by: Kyungtae Kim <kt0755@gmail.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200510054326.GA19198@pizza01
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |