code
stringlengths 14
2.05k
| label
int64 0
1
| programming_language
stringclasses 7
values | cwe_id
stringlengths 6
14
| cwe_name
stringlengths 5
98
⌀ | description
stringlengths 36
379
⌀ | url
stringlengths 36
48
⌀ | label_name
stringclasses 2
values |
---|---|---|---|---|---|---|---|
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
name: input.name,
description: input.description,
permissions: input.permissions
};
await rolesCollection.insertOne(role);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: {
...input,
id: `${role._id}`
}
});
return { id: `${role._id}` };
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
},
{
$set: {
name: input.name,
description: input.description,
permissions: input.permissions
}
}
);
updateSessionRole(ctx, input.id);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
...input
}
});
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
},
{
$set: {
name: input.name,
description: input.description,
permissions: input.permissions
}
}
);
updateSessionRole(ctx, input.id);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
...input
}
});
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
},
{
$set: {
name: input.name,
description: input.description,
permissions: input.permissions
}
}
);
updateSessionRole(ctx, input.id);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
...input
}
});
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(id)
},
{
$set: tagUpdate
}
);
if (!matchedCount) throw errors.notFound("tag");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: input
});
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(id)
},
{
$set: tagUpdate
}
);
if (!matchedCount) throw errors.notFound("tag");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: input
});
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(id)
},
{
$set: tagUpdate
}
);
if (!matchedCount) throw errors.notFound("tag");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: input
});
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
value: (input.label || "").toLowerCase().replace(/\s/g, "_")
};
await tagsCollection.insertOne(tag);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: {
...input,
id: `${tag._id}`
}
});
return { id: `${tag._id}` };
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
value: (input.label || "").toLowerCase().replace(/\s/g, "_")
};
await tagsCollection.insertOne(tag);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: {
...input,
id: `${tag._id}`
}
});
return { id: `${tag._id}` };
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
value: (input.label || "").toLowerCase().replace(/\s/g, "_")
};
await tagsCollection.insertOne(tag);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: {
...input,
id: `${tag._id}`
}
});
return { id: `${tag._id}` };
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(id),
workspaceId: ctx.auth.workspaceId
},
{
$set: update
}
);
if (matchedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id,
...update
}
});
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(id),
workspaceId: ctx.auth.workspaceId
},
{
$set: update
}
);
if (matchedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id,
...update
}
});
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(id),
workspaceId: ctx.auth.workspaceId
},
{
$set: update
}
);
if (matchedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id,
...update
}
});
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
const { deletedCount } = await tokensCollection.deleteOne({ _id: new ObjectId(input.id) });
if (deletedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: {
id: input.id
}
});
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
const { deletedCount } = await tokensCollection.deleteOne({ _id: new ObjectId(input.id) });
if (deletedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: {
id: input.id
}
});
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
const { deletedCount } = await tokensCollection.deleteOne({ _id: new ObjectId(input.id) });
if (deletedCount === 0) throw errors.notFound("token");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: {
id: input.id
}
});
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await transformersCollection.insertOne(transformer);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${transformer._id}` }
});
return { id: `${transformer._id}` };
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await transformersCollection.insertOne(transformer);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${transformer._id}` }
});
return { id: `${transformer._id}` };
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await transformersCollection.insertOne(transformer);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${transformer._id}` }
});
return { id: `${transformer._id}` };
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("transformer");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "delete", data: input });
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("transformer");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "delete", data: input });
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("transformer");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "delete", data: input });
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
{ _id: new ObjectId(id), workspaceId: ctx.auth.workspaceId },
{ $set: update }
);
if (!matchedCount) throw errors.notFound("variant");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "update", data: input });
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
{ _id: new ObjectId(id), workspaceId: ctx.auth.workspaceId },
{ $set: update }
);
if (!matchedCount) throw errors.notFound("variant");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "update", data: input });
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
{ _id: new ObjectId(id), workspaceId: ctx.auth.workspaceId },
{ $set: update }
);
if (!matchedCount) throw errors.notFound("variant");
publishEvent(ctx, `${ctx.auth.workspaceId}`, { action: "update", data: input });
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await variantsCollection.insertOne(variant);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${variant._id}` }
});
return { id: `${variant._id}` };
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await variantsCollection.insertOne(variant);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${variant._id}` }
});
return { id: `${variant._id}` };
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(),
workspaceId: ctx.auth.workspaceId,
...input
};
await variantsCollection.insertOne(variant);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "create",
data: { ...input, id: `${variant._id}` }
});
return { id: `${variant._id}` };
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(),
userId: user._id,
codeEditorTheme: "dark",
uiTheme: "auto",
accentColor: "energy",
currentWorkspaceId: workspaceId
});
await createSession(ctx, `${user._id}`);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
return "/";
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(),
userId: user._id,
codeEditorTheme: "dark",
uiTheme: "auto",
accentColor: "energy",
currentWorkspaceId: workspaceId
});
await createSession(ctx, `${user._id}`);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
return "/";
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(),
userId: user._id,
codeEditorTheme: "dark",
uiTheme: "auto",
accentColor: "energy",
currentWorkspaceId: workspaceId
});
await createSession(ctx, `${user._id}`);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
return "/";
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("webhook");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: input
});
}) | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("webhook");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: input
});
}) | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
_id: new ObjectId(input.id),
workspaceId: ctx.auth.workspaceId
});
if (!deletedCount) throw errors.notFound("webhook");
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "delete",
data: input
});
}) | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
roleId: new ObjectId(input.roleId)
}
}
);
await updateSessionUser(ctx, `${membership.userId}`);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id: input.id,
userId: `${membership.userId}`,
roleId: `${role._id}`,
role: {
id: `${role._id}`,
name: role.name,
permissions: role.permissions,
description: role.description
}
}
});
}), | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
roleId: new ObjectId(input.roleId)
}
}
);
await updateSessionUser(ctx, `${membership.userId}`);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id: input.id,
userId: `${membership.userId}`,
roleId: `${role._id}`,
role: {
id: `${role._id}`,
name: role.name,
permissions: role.permissions,
description: role.description
}
}
});
}), | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
roleId: new ObjectId(input.roleId)
}
}
);
await updateSessionUser(ctx, `${membership.userId}`);
publishEvent(ctx, `${ctx.auth.workspaceId}`, {
action: "update",
data: {
id: input.id,
userId: `${membership.userId}`,
roleId: `${role._id}`,
role: {
id: `${role._id}`,
name: role.name,
permissions: role.permissions,
description: role.description
}
}
});
}), | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
wrappers: (workspaceSettings.wrappers || []).map((item, index) => {
if (index === sameKeyWrapperIndex) {
return {
...item,
...input,
...(extensionId && { extension: item.extension || true })
};
}
return item;
})
}
}
);
} else { | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
wrappers: (workspaceSettings.wrappers || []).map((item, index) => {
if (index === sameKeyWrapperIndex) {
return {
...item,
...input,
...(extensionId && { extension: item.extension || true })
};
}
return item;
})
}
}
);
} else { | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
wrappers: (workspaceSettings.wrappers || []).map((item, index) => {
if (index === sameKeyWrapperIndex) {
return {
...item,
...input,
...(extensionId && { extension: item.extension || true })
};
}
return item;
})
}
}
);
} else { | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
...(extensionId && { extension: item.extension || true })
};
}
return item;
}) | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
...(extensionId && { extension: item.extension || true })
};
}
return item;
}) | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
...(extensionId && { extension: item.extension || true })
};
}
return item;
}) | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
schema: zodToJsonSchema(envSchema.extend(envSchemaExtension || {}))
}) | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
schema: zodToJsonSchema(envSchema.extend(envSchemaExtension || {}))
}) | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
schema: zodToJsonSchema(envSchema.extend(envSchemaExtension || {}))
}) | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
renderHTML({ node, HTMLAttributes }) {
return [
"pre",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
[
"code",
{
class: node.attrs.lang ? `language-${node.attrs.lang}` : null
},
0
]
];
}, | 0 | TypeScript | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
renderHTML({ node, HTMLAttributes }) {
return [
"pre",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
[
"code",
{
class: node.attrs.lang ? `language-${node.attrs.lang}` : null
},
0
]
];
}, | 0 | TypeScript | CWE-918 | Server-Side Request Forgery (SSRF) | The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. | https://cwe.mitre.org/data/definitions/918.html | vulnerable |
renderHTML({ node, HTMLAttributes }) {
return [
"pre",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
[
"code",
{
class: node.attrs.lang ? `language-${node.attrs.lang}` : null
},
0
]
];
}, | 0 | TypeScript | CWE-770 | Allocation of Resources Without Limits or Throttling | The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor. | https://cwe.mitre.org/data/definitions/770.html | vulnerable |
constructor(
tracker: IWidgetTracker<MarkdownDocument>,
protected parser: IMarkdownParser | null
) {
super(tracker);
} | 0 | TypeScript | NVD-CWE-noinfo | null | null | null | vulnerable |
const onHeadingsChanged = () => {
if (!this.parser) {
return;
}
// Clear all numbering items
TableOfContentsUtils.clearNumbering(widget.content.node);
// Create a new mapping
headingToElement = new WeakMap<IMarkdownViewerHeading, Element | null>();
model.headings.forEach(async heading => {
const elementId = await TableOfContentsUtils.Markdown.getHeadingId(
this.parser!,
heading.raw,
heading.level
);
if (!elementId) {
return;
}
const selector = `h${heading.level}[id="${elementId}"]`;
headingToElement.set(
heading,
TableOfContentsUtils.addPrefix(
widget.content.node,
selector,
heading.prefix ?? ''
)
);
});
}; | 0 | TypeScript | NVD-CWE-noinfo | null | null | null | vulnerable |
export async function getIdForHeading(
heading: INotebookHeading,
parser: IRenderMime.IMarkdownParser
) {
let elementId: string | null = null;
if (heading.type === Cell.HeadingType.Markdown) {
elementId = await TableOfContentsUtils.Markdown.getHeadingId(
parser,
// Type from TableOfContentsUtils.Markdown.IMarkdownHeading
(heading as any).raw,
heading.level
);
} else if (heading.type === Cell.HeadingType.HTML) {
// Type from TableOfContentsUtils.IHTMLHeading
elementId = (heading as any).id;
}
return elementId;
} | 0 | TypeScript | NVD-CWE-noinfo | null | null | null | vulnerable |
const findHeadingElement = (cell: Cell): void => {
model.getCellHeadings(cell).forEach(async heading => {
const elementId = await getIdForHeading(heading, this.parser!);
const selector = elementId
? `h${heading.level}[id="${elementId}"]`
: `h${heading.level}`;
if (heading.outputIndex !== undefined) {
// Code cell
headingToElement.set(
heading,
TableOfContentsUtils.addPrefix(
(heading.cellRef as CodeCell).outputArea.widgets[
heading.outputIndex
].node,
selector,
heading.prefix ?? ''
)
);
} else {
headingToElement.set(
heading,
TableOfContentsUtils.addPrefix(
heading.cellRef.node,
selector,
heading.prefix ?? ''
)
);
}
});
}; | 0 | TypeScript | NVD-CWE-noinfo | null | null | null | vulnerable |
export async function getHeadingId(
parser: IMarkdownParser,
raw: string,
level: number
): Promise<string | null> {
try {
const innerHTML = await parser.render(raw);
if (!innerHTML) {
return null;
}
const container = document.createElement('div');
container.innerHTML = innerHTML;
const header = container.querySelector(`h${level}`);
if (!header) {
return null;
}
return renderMarkdown.createHeaderId(header);
} catch (reason) {
console.error('Failed to parse a heading.', reason);
}
return null;
} | 0 | TypeScript | NVD-CWE-noinfo | null | null | null | vulnerable |
void context.ready.then(async () => {
const file = context.model;
const workspace = file.toJSON() as unknown as Workspace.IWorkspace;
const path = context.path;
const id = workspace.metadata.id;
// Save the file contents as a workspace.
await this._workspaces.save(id, workspace);
// Save last save location for the save command.
await this._state.save(LAST_SAVE_ID, path);
// Navigate to new workspace.
const url = URLExt.join(this._application, 'workspaces', id);
if (this._router) {
this._router.navigate(url, { hard: true });
} else {
document.location.href = url;
}
}); | 0 | TypeScript | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
void context.ready.then(async () => {
const file = context.model;
const workspace = file.toJSON() as unknown as Workspace.IWorkspace;
const path = context.path;
const id = workspace.metadata.id;
// Save the file contents as a workspace.
await this._workspaces.save(id, workspace);
// Save last save location for the save command.
await this._state.save(LAST_SAVE_ID, path);
// Navigate to new workspace.
const url = URLExt.join(this._application, 'workspaces', id);
if (this._router) {
this._router.navigate(url, { hard: true });
} else {
document.location.href = url;
}
}); | 0 | TypeScript | CWE-23 | Relative Path Traversal | The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. | https://cwe.mitre.org/data/definitions/23.html | vulnerable |
export function getSessionUrl(baseUrl: string, id: string): string {
return URLExt.join(baseUrl, SESSION_SERVICE_URL, id);
} | 0 | TypeScript | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
export function getSessionUrl(baseUrl: string, id: string): string {
return URLExt.join(baseUrl, SESSION_SERVICE_URL, id);
} | 0 | TypeScript | CWE-23 | Relative Path Traversal | The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. | https://cwe.mitre.org/data/definitions/23.html | vulnerable |
export async function requestTranslationsAPI<T>(
translationsUrl: string = '',
locale = '',
init: RequestInit = {},
serverSettings: ServerConnection.ISettings | undefined = undefined
): Promise<T> {
// Make request to Jupyter API
const settings = serverSettings ?? ServerConnection.makeSettings();
translationsUrl =
translationsUrl || `${settings.appUrl}/${TRANSLATIONS_SETTINGS_URL}`;
const requestUrl = URLExt.join(settings.baseUrl, translationsUrl, locale);
let response: Response;
try {
response = await ServerConnection.makeRequest(requestUrl, init, settings);
} catch (error) {
throw new ServerConnection.NetworkError(error);
}
let data: any = await response.text();
if (data.length > 0) {
try {
data = JSON.parse(data);
} catch (error) {
console.error('Not a JSON response body.', response);
}
}
if (!response.ok) {
throw new ServerConnection.ResponseError(response, data.message || data);
}
return data;
} | 0 | TypeScript | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
export async function requestTranslationsAPI<T>(
translationsUrl: string = '',
locale = '',
init: RequestInit = {},
serverSettings: ServerConnection.ISettings | undefined = undefined
): Promise<T> {
// Make request to Jupyter API
const settings = serverSettings ?? ServerConnection.makeSettings();
translationsUrl =
translationsUrl || `${settings.appUrl}/${TRANSLATIONS_SETTINGS_URL}`;
const requestUrl = URLExt.join(settings.baseUrl, translationsUrl, locale);
let response: Response;
try {
response = await ServerConnection.makeRequest(requestUrl, init, settings);
} catch (error) {
throw new ServerConnection.NetworkError(error);
}
let data: any = await response.text();
if (data.length > 0) {
try {
data = JSON.parse(data);
} catch (error) {
console.error('Not a JSON response body.', response);
}
}
if (!response.ok) {
throw new ServerConnection.ResponseError(response, data.message || data);
}
return data;
} | 0 | TypeScript | CWE-23 | Relative Path Traversal | The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. | https://cwe.mitre.org/data/definitions/23.html | vulnerable |
headers: baseHeaders(),
})
.then((res) => res.json())
.then((res) => res)
.catch((e) => {
console.error(e);
return { filename: null, error: e.message };
});
}, | 0 | TypeScript | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
exportImport: () => {
return "/settings/export-import";
}, | 0 | TypeScript | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
exports: () => {
return `${API_BASE.replace("/api", "")}/system/data-exports`;
}, | 0 | TypeScript | CWE-754 | Improper Check for Unusual or Exceptional Conditions | The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. | https://cwe.mitre.org/data/definitions/754.html | vulnerable |
get url() {
return `http://${this[incomingKey].headers.host}${this[incomingKey].url}`
}, | 0 | TypeScript | CWE-22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. | https://cwe.mitre.org/data/definitions/22.html | vulnerable |
msg_puts_printf(char_u *str, int maxlen)
{
char_u *s = str;
char_u *buf = NULL;
char_u *p = s;
#ifdef MSWIN
if (!(silent_mode && p_verbose == 0))
mch_settmode(TMODE_COOK); // handle CR and NL correctly
#endif
while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
{
if (!(silent_mode && p_verbose == 0))
{
// NL --> CR NL translation (for Unix, not for "--version")
if (*s == NL)
{
int n = (int)(s - p);
buf = alloc(n + 3);
if (buf != NULL)
{
memcpy(buf, p, n);
if (!info_message)
buf[n++] = CAR;
buf[n++] = NL;
buf[n++] = NUL;
if (info_message) // informative message, not an error
mch_msg((char *)buf);
else
mch_errmsg((char *)buf);
vim_free(buf);
}
p = s + 1;
}
}
// primitive way to compute the current column
#ifdef FEAT_RIGHTLEFT
if (cmdmsg_rl)
{
if (*s == CAR || *s == NL)
msg_col = Columns - 1;
else
--msg_col;
}
else
#endif
{
if (*s == CAR || *s == NL)
msg_col = 0;
else
++msg_col;
}
++s;
}
if (*p != NUL && !(silent_mode && p_verbose == 0))
{
char_u *tofree = NULL;
if (maxlen > 0 && vim_strlen_maxlen((char *)p, (size_t)maxlen)
>= (size_t)maxlen)
{
tofree = vim_strnsave(p, (size_t)maxlen);
p = tofree;
}
if (p != NULL)
{
if (info_message)
mch_msg((char *)p);
else
mch_errmsg((char *)p);
vim_free(tofree);
}
}
msg_didout = TRUE; // assume that line is not empty
#ifdef MSWIN
if (!(silent_mode && p_verbose == 0))
mch_settmode(TMODE_RAW);
#endif
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
vim_strlen_maxlen(char *s, size_t maxlen)
{
size_t i;
for (i = 0; i < maxlen; ++i)
if (s[i] == NUL)
break;
return i;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
get_register(
int name,
int copy) // make a copy, if FALSE make register empty.
{
yankreg_T *reg;
int i;
#ifdef FEAT_CLIPBOARD
// When Visual area changed, may have to update selection. Obtain the
// selection too.
if (name == '*' && clip_star.available)
{
if (clip_isautosel_star())
clip_update_selection(&clip_star);
may_get_selection(name);
}
if (name == '+' && clip_plus.available)
{
if (clip_isautosel_plus())
clip_update_selection(&clip_plus);
may_get_selection(name);
}
#endif
get_yank_register(name, 0);
reg = ALLOC_ONE(yankreg_T);
if (reg == NULL)
return (void *)NULL;
*reg = *y_current;
if (copy)
{
// If we run out of memory some or all of the lines are empty.
if (reg->y_size == 0 || y_current->y_array == NULL)
reg->y_array = NULL;
else
reg->y_array = ALLOC_MULT(char_u *, reg->y_size);
if (reg->y_array != NULL)
{
for (i = 0; i < reg->y_size; ++i)
reg->y_array[i] = vim_strsave(y_current->y_array[i]);
}
}
else
y_current->y_array = NULL;
return (void *)reg;
} | 1 | C | CWE-476 | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | https://cwe.mitre.org/data/definitions/476.html | safe |
regtilde(char_u *source, int magic)
{
char_u *newsub = source;
char_u *p;
for (p = newsub; *p; ++p)
{
if ((*p == '~' && magic) || (*p == '\\' && *(p + 1) == '~' && !magic))
{
if (reg_prev_sub != NULL)
{
// length = len(newsub) - 1 + len(prev_sub) + 1
// Avoid making the text longer than MAXCOL, it will cause
// trouble at some point.
size_t prevsublen = STRLEN(reg_prev_sub);
size_t newsublen = STRLEN(newsub);
if (prevsublen > MAXCOL || newsublen > MAXCOL
|| newsublen + prevsublen > MAXCOL)
{
emsg(_(e_resulting_text_too_long));
break;
}
char_u *tmpsub = alloc(newsublen + prevsublen);
if (tmpsub != NULL)
{
// copy prefix
size_t prefixlen = p - newsub; // not including ~
mch_memmove(tmpsub, newsub, prefixlen);
// interpret tilde
mch_memmove(tmpsub + prefixlen, reg_prev_sub,
prevsublen);
// copy postfix
if (!magic)
++p; // back off backslash
STRCPY(tmpsub + prefixlen + prevsublen, p + 1);
if (newsub != source) // allocated newsub before
vim_free(newsub);
newsub = tmpsub;
p = newsub + prefixlen + prevsublen;
}
}
else if (magic)
STRMOVE(p, p + 1); // remove '~'
else
STRMOVE(p, p + 2); // remove '\~'
--p;
}
else
{
if (*p == '\\' && p[1]) // skip escaped characters
++p;
if (has_mbyte)
p += (*mb_ptr2len)(p) - 1;
}
}
// Store a copy of newsub in reg_prev_sub. It is always allocated,
// because recursive calls may make the returned string invalid.
vim_free(reg_prev_sub);
reg_prev_sub = vim_strsave(newsub);
return newsub;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
is_qf_win(win_T *win, qf_info_T *qi)
{
// A window displaying the quickfix buffer will have the w_llist_ref field
// set to NULL.
// A window displaying a location list buffer will have the w_llist_ref
// pointing to the location list.
if (buf_valid(win->w_buffer) && bt_quickfix(win->w_buffer))
if ((IS_QF_STACK(qi) && win->w_llist_ref == NULL)
|| (IS_LL_STACK(qi) && win->w_llist_ref == qi))
return TRUE;
return FALSE;
} | 1 | C | CWE-416 | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. | https://cwe.mitre.org/data/definitions/416.html | safe |
buf_contents_changed(buf_T *buf)
{
buf_T *newbuf;
int differ = TRUE;
linenr_T lnum;
aco_save_T aco;
exarg_T ea;
// Allocate a buffer without putting it in the buffer list.
newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
if (newbuf == NULL)
return TRUE;
// Force the 'fileencoding' and 'fileformat' to be equal.
if (prep_exarg(&ea, buf) == FAIL)
{
wipe_buffer(newbuf, FALSE);
return TRUE;
}
// Set curwin/curbuf to buf and save a few things.
aucmd_prepbuf(&aco, newbuf);
if (curbuf != newbuf)
{
// Failed to find a window for "newbuf".
wipe_buffer(newbuf, FALSE);
return TRUE;
}
// We don't want to trigger autocommands now, they may have nasty
// side-effects like wiping buffers
block_autocmds();
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
&ea, READ_NEW | READ_DUMMY) == OK)
{
// compare the two files line by line
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count)
{
differ = FALSE;
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
if (STRCMP(ml_get_buf(buf, lnum, FALSE), ml_get(lnum)) != 0)
{
differ = TRUE;
break;
}
}
}
vim_free(ea.cmd);
// restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
if (curbuf != newbuf) // safety check
wipe_buffer(newbuf, FALSE);
unblock_autocmds();
return differ;
} | 1 | C | CWE-416 | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. | https://cwe.mitre.org/data/definitions/416.html | safe |
get_list_range(char_u **str, int *num1, int *num2)
{
int len;
int first = FALSE;
varnumber_T num;
*str = skipwhite(*str);
if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range
{
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL);
*str += len;
// overflow
if (num > INT_MAX)
return FAIL;
*num1 = (int)num;
first = TRUE;
}
*str = skipwhite(*str);
if (**str == ',') // parse "to" part of range
{
*str = skipwhite(*str + 1);
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL);
if (len > 0)
{
*str = skipwhite(*str + len);
// overflow
if (num > INT_MAX)
return FAIL;
*num2 = (int)num;
}
else if (!first) // no number given at all
return FAIL;
}
else if (first) // only one number given
*num2 = *num1;
return OK;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
get_list_range(char_u **str, int *num1, int *num2)
{
int len;
int first = FALSE;
varnumber_T num;
*str = skipwhite(*str);
if (**str == '-' || vim_isdigit(**str)) // parse "from" part of range
{
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL);
*str += len;
// overflow
if (num > INT_MAX)
return FAIL;
*num1 = (int)num;
first = TRUE;
}
*str = skipwhite(*str);
if (**str == ',') // parse "to" part of range
{
*str = skipwhite(*str + 1);
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, FALSE, NULL);
if (len > 0)
{
*str = skipwhite(*str + len);
// overflow
if (num > INT_MAX)
return FAIL;
*num2 = (int)num;
}
else if (!first) // no number given at all
return FAIL;
}
else if (first) // only one number given
*num2 = *num1;
return OK;
} | 1 | C | CWE-416 | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. | https://cwe.mitre.org/data/definitions/416.html | safe |
nv_z_get_count(cmdarg_T *cap, int *nchar_arg)
{
int nchar = *nchar_arg;
long n;
// "z123{nchar}": edit the count before obtaining {nchar}
if (checkclearop(cap->oap))
return FALSE;
n = nchar - '0';
for (;;)
{
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; // disallow scrolling here
#endif
++no_mapping;
++allow_keys; // no mapping for nchar, but allow key codes
nchar = plain_vgetc();
LANGMAP_ADJUST(nchar, TRUE);
--no_mapping;
--allow_keys;
(void)add_to_showcmd(nchar);
if (nchar == K_DEL || nchar == K_KDEL)
n /= 10;
else if (VIM_ISDIGIT(nchar))
{
if (n > LONG_MAX / 10)
{
clearopbeep(cap->oap);
break;
}
n = n * 10 + (nchar - '0');
}
else if (nchar == CAR)
{
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
win_setheight((int)n);
break;
}
else if (nchar == 'l'
|| nchar == 'h'
|| nchar == K_LEFT
|| nchar == K_RIGHT)
{
cap->count1 = n ? n * cap->count1 : cap->count1;
*nchar_arg = nchar;
return TRUE;
}
else
{
clearopbeep(cap->oap);
break;
}
}
cap->oap->op_type = OP_NOP;
return FALSE;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
get_number(
int colon, // allow colon to abort
int *mouse_used)
{
int n = 0;
int c;
int typed = 0;
if (mouse_used != NULL)
*mouse_used = FALSE;
// When not printing messages, the user won't know what to type, return a
// zero (as if CR was hit).
if (msg_silent != 0)
return 0;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = TRUE; // disallow scrolling here
#endif
++no_mapping;
++allow_keys; // no mapping here, but recognize keys
for (;;)
{
windgoto(msg_row, msg_col);
c = safe_vgetc();
if (VIM_ISDIGIT(c))
{
if (n > INT_MAX / 10)
return 0;
n = n * 10 + c - '0';
msg_putchar(c);
++typed;
}
else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H)
{
if (typed > 0)
{
msg_puts("\b \b");
--typed;
}
n /= 10;
}
else if (mouse_used != NULL && c == K_LEFTMOUSE)
{
*mouse_used = TRUE;
n = mouse_row + 1;
break;
}
else if (n == 0 && c == ':' && colon)
{
stuffcharReadbuff(':');
if (!exmode_active)
cmdline_row = msg_row;
skip_redraw = TRUE; // skip redraw once
do_redraw = FALSE;
break;
}
else if (c == Ctrl_C || c == ESC || c == 'q')
{
n = 0;
break;
}
else if (c == CAR || c == NL )
break;
}
--no_mapping;
--allow_keys;
return n;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
shift_line(
int left,
int round,
int amount,
int call_changed_bytes) // call changed_bytes()
{
long long count;
int i, j;
int sw_val = (int)get_sw_value_indent(curbuf);
count = (long long)get_indent(); // get current indent
if (round) // round off indent
{
i = count / sw_val; // number of 'shiftwidth' rounded down
j = count % sw_val; // extra spaces
if (j && left) // first remove extra spaces
--amount;
if (left)
{
i -= amount;
if (i < 0)
i = 0;
}
else
i += amount;
count = i * sw_val;
}
else // original vi indent
{
if (left)
{
count -= sw_val * amount;
if (count < 0)
count = 0;
}
else
{
if ((long long)sw_val * (long long)amount > INT_MAX - count)
count = INT_MAX;
else
count += (long long)sw_val * (long long)amount;
}
}
// Set new indent
if (State & VREPLACE_FLAG)
change_indent(INDENT_SET, (int)count, FALSE, NUL, call_changed_bytes);
else
(void)set_indent((int)count, call_changed_bytes ? SIN_CHANGED : 0);
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
static bool meta_set(RAnal *a, RAnalMetaType type, int subtype, ut64 from, ut64 to, const char *str) {
if (to < from) {
return false;
}
RSpace *space = r_spaces_current (&a->meta_spaces);
RIntervalNode *node = find_node_at (a, type, space, from);
RAnalMetaItem *item = node ? node->data : R_NEW0 (RAnalMetaItem);
if (!item) {
return false;
}
item->type = type;
item->subtype = subtype;
item->space = space;
free (item->str);
if (R_STR_ISNOTEMPTY (str)) {
item->str = strdup (str);
// this breaks the `ecHw` command
// (highlights word in current instruction, which uses ansi
// r_str_ansi_strip (item->str);
} else {
item->str = NULL;
}
R_DIRTY (a);
if (!node) {
r_interval_tree_insert (&a->meta, from, to, item);
} else if (node->end != to) {
r_interval_tree_resize (&a->meta, node, from, to);
}
return true;
} | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
R_API char *r_cons_hud_string(const char *s) {
if (!r_cons_is_interactive ()) {
R_LOG_ERROR ("Hud mode requires scr.interactive=true");
return NULL;
}
char *os, *track, *ret, *o = strdup (s);
if (!o) {
return NULL;
}
r_str_ansi_strip (o);
r_str_replace_ch (o, '\r', 0, true);
r_str_replace_ch (o, '\t', 0, true);
RList *fl = r_list_new ();
int i;
if (!fl) {
free (o);
return NULL;
}
fl->free = free;
for (os = o, i = 0; o[i]; i++) {
if (o[i] == '\n') {
o[i] = 0;
if (*os && *os != '#') {
track = strdup (os);
if (!r_list_append (fl, track)) {
free (track);
break;
}
}
os = o + i + 1;
}
}
ret = r_cons_hud (fl, NULL);
free (o);
r_list_free (fl);
return ret;
} | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
R_API char *r_cons_hud_line_string(const char *s) {
if (!r_cons_is_interactive ()) {
R_LOG_ERROR ("Hud mode requires scr.interactive=true");
return NULL;
}
char *os, *track, *ret, *o = strdup (s);
if (!o) {
return NULL;
}
r_str_replace_ch (o, '\r', 0, true);
r_str_replace_ch (o, '\t', 0, true);
r_str_ansi_strip (o);
RList *fl = r_list_new ();
int i;
if (!fl) {
free (o);
return NULL;
}
fl->free = free;
for (os = o, i = 0; o[i]; i++) {
if (o[i] == '\n') {
o[i] = 0;
if (*os && *os != '#') {
track = strdup (os);
if (!r_list_append (fl, track)) {
free (track);
break;
}
}
os = o + i + 1;
}
}
ret = r_cons_hud_line (fl, NULL);
free (o);
r_list_free (fl);
return ret;
} | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
R_API char *r_cons_hud_file(const char *f) {
char *s = r_file_slurp (f, NULL);
if (s) {
r_str_ansi_strip (s);
char *ret = r_cons_hud_string (s);
free (s);
return ret;
}
return NULL;
} | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
R_API size_t r_str_ansi_strip(char *str) {
size_t i = 0;
while (str[i]) {
size_t chlen = __str_ansi_length (str + i);
if (chlen > 1) {
r_str_cpy (str + i, str + i + chlen);
} else {
i++;
}
}
return i;
} | 1 | C | CWE-74 | Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') | The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/74.html | safe |
static RList *patch_relocs(RBin *b) {
r_return_val_if_fail (b && b->iob.io && b->iob.io->desc, NULL);
RBinObject *bo = r_bin_cur_object (b);
RIO *io = b->iob.io;
if (!bo || !bo->bin_obj) {
return NULL;
}
struct r_bin_coff_obj *bin = (struct r_bin_coff_obj*)bo->bin_obj;
if (bin->hdr.f_flags & COFF_FLAGS_TI_F_EXEC) {
return NULL;
}
if (!(io->cached & R_PERM_W)) {
eprintf (
"Warning: please run r2 with -e io.cache=true to patch "
"relocations\n");
return NULL;
}
size_t nimports = 0;
int i;
if (bin->symbols) {
for (i = 0; i < bin->hdr.f_nsyms; i++) {
if (is_imported_symbol (&bin->symbols[i])) {
nimports++;
}
i += bin->symbols[i].n_numaux;
}
}
ut64 m_vaddr = UT64_MAX;
if (nimports) {
ut64 offset = 0;
RIOBank *bank = b->iob.bank_get (io, io->bank);
RListIter *iter;
RIOMapRef *mapref;
r_list_foreach (bank->maprefs, iter, mapref) {
RIOMap *map = b->iob.map_get (io, mapref->id);
if (r_io_map_end (map) > offset) {
offset = r_io_map_end (map);
}
}
m_vaddr = R_ROUND (offset, 16);
ut64 size = nimports * BYTES_PER_IMP_RELOC;
char *muri = r_str_newf ("malloc://%" PFMT64u, size);
RIODesc *desc = b->iob.open_at (io, muri, R_PERM_R, 0664, m_vaddr);
free (muri);
if (!desc) {
return NULL;
}
RIOMap *map = b->iob.map_get_at (io, m_vaddr);
if (!map) {
return NULL;
}
map->name = strdup (".imports.r2");
}
return _relocs_list (b, bin, true, m_vaddr);
} | 1 | C | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
static int getid(char ch) {
const char *const keys = "[]<>+-,.";
const char *const cidx = strchr (keys, ch);
return cidx? cidx - keys + 1: 0;
} | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
static void process_constructors(RKernelCacheObj *obj, struct MACH0_(obj_t) *mach0, RList *ret, ut64 paddr, bool is_first, int mode, const char *prefix) {
const RVector *sections = MACH0_(load_sections) (mach0);
if (!sections) {
return;
}
int type;
struct section_t *section;
r_vector_foreach (sections, section) {
if (section->size == 0) {
continue;
}
if (strstr (section->name, "_mod_fini_func") || strstr (section->name, "_mod_term_func")) {
type = R_BIN_ENTRY_TYPE_FINI;
} else if (strstr (section->name, "_mod_init_func")) {
type = is_first ? 0 : R_BIN_ENTRY_TYPE_INIT;
is_first = false;
} else {
continue;
}
ut8 *buf = calloc (section->size, 1);
if (!buf) {
break;
}
if (r_buf_read_at (obj->cache_buf, section->paddr + paddr, buf, section->size) < section->size) {
free (buf);
break;
}
int j;
int count = 0;
for (j = 0; j + 7 < section->size; j += 8) {
ut64 addr64 = K_RPTR (buf + j);
ut64 paddr64 = section->paddr + paddr + j;
if (mode == R_K_CONSTRUCTOR_TO_ENTRY) {
RBinAddr *ba = newEntry (paddr64, addr64, type);
r_list_append (ret, ba);
} else if (mode == R_K_CONSTRUCTOR_TO_SYMBOL) {
RBinSymbol *sym = R_NEW0 (RBinSymbol);
if (!sym) {
break;
}
sym->name = r_str_newf ("%s.%s.%d", prefix, (type == R_BIN_ENTRY_TYPE_INIT) ? "init" : "fini", count++);
sym->vaddr = addr64;
sym->paddr = paddr64;
sym->size = 0;
sym->forwarder = "NONE";
sym->bind = "GLOBAL";
sym->type = "FUNC";
r_list_append (ret, sym);
}
}
free (buf);
}
} | 1 | C | CWE-787 | Out-of-bounds Write | The product writes data past the end, or before the beginning, of the intended buffer. | https://cwe.mitre.org/data/definitions/787.html | safe |
Bool gf_sg_proto_field_is_sftime_offset(GF_Node *node, GF_FieldInfo *field)
{
u32 i;
GF_Route *r;
GF_ProtoInstance *inst;
GF_FieldInfo inf;
if (node->sgprivate->tag != TAG_ProtoNode) return 0;
if (field->fieldType != GF_SG_VRML_SFTIME) return 0;
inst = (GF_ProtoInstance *) node;
/*check in interface if this is ISed */
i=0;
while ((r = (GF_Route*)gf_list_enum(inst->proto_interface->sub_graph->Routes, &i))) {
if (!r->IS_route) continue;
/*only check eventIn/field/exposedField*/
if (r->FromNode || (r->FromField.fieldIndex != field->fieldIndex)) continue;
gf_node_get_field(r->ToNode, r->ToField.fieldIndex, &inf);
/*IS to another proto*/
if (r->ToNode->sgprivate->tag == TAG_ProtoNode) {
if (r->ToNode==node) continue;
return gf_sg_proto_field_is_sftime_offset(r->ToNode, &inf);
}
/*IS to a startTime/stopTime field*/
if (!stricmp(inf.name, "startTime") || !stricmp(inf.name, "stopTime")) return 1;
}
return 0;
} | 1 | C | CWE-121 | Stack-based Buffer Overflow | A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function). | https://cwe.mitre.org/data/definitions/121.html | safe |
static s32 svc_parse_slice(GF_BitStream *bs, AVCState *avc, AVCSliceInfo *si)
{
s32 pps_id;
/*s->current_picture.reference= h->nal_ref_idc != 0;*/
gf_bs_read_ue_log(bs, "first_mb_in_slice");
si->slice_type = gf_bs_read_ue_log(bs, "slice_type");
if (si->slice_type > 9) return -1;
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if ((pps_id<0) || (pps_id >= 255))
return -1;
si->pps = &avc->pps[pps_id];
si->pps->id = pps_id;
if (!si->pps->slice_group_count)
return -2;
si->sps = &avc->sps[si->pps->sps_id + GF_SVC_SSPS_ID_SHIFT];
if (!si->sps->log2_max_frame_num)
return -2;
si->frame_num = gf_bs_read_int_log(bs, si->sps->log2_max_frame_num, "frame_num");
si->field_pic_flag = 0;
if (si->sps->frame_mbs_only_flag) {
/*s->picture_structure= PICT_FRAME;*/
}
else {
si->field_pic_flag = gf_bs_read_int_log(bs, 1, "field_pic_flag");
if (si->field_pic_flag) si->bottom_field_flag = gf_bs_read_int_log(bs, 1, "bottom_field_flag");
}
if (si->nal_unit_type == GF_AVC_NALU_IDR_SLICE || si->svc_nalhdr.idr_pic_flag)
si->idr_pic_id = gf_bs_read_ue_log(bs, "idr_pic_id");
if (si->sps->poc_type == 0) {
si->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, "poc_lsb");
if (si->pps->pic_order_present && !si->field_pic_flag) {
si->delta_poc_bottom = gf_bs_read_se_log(bs, "delta_poc_bottom");
}
}
else if ((si->sps->poc_type == 1) && !si->sps->delta_pic_order_always_zero_flag) {
si->delta_poc[0] = gf_bs_read_se_log(bs, "delta_poc0");
if ((si->pps->pic_order_present == 1) && !si->field_pic_flag)
si->delta_poc[1] = gf_bs_read_se_log(bs, "delta_poc1");
}
if (si->pps->redundant_pic_cnt_present) {
si->redundant_pic_cnt = gf_bs_read_ue_log(bs, "redundant_pic_cnt");
}
return 0;
} | 1 | C | CWE-120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | https://cwe.mitre.org/data/definitions/120.html | safe |
GF_Err Q_DecCoordOnUnitSphere(GF_BifsDecoder *codec, GF_BitStream *bs, u32 NbBits, u32 NbComp, Fixed *m_ft)
{
u32 i, orient, sign;
s32 value;
Fixed tang[4], delta;
s32 dir;
if (NbBits>32) return GF_NON_COMPLIANT_BITSTREAM;
if (NbComp != 2 && NbComp != 3) return GF_BAD_PARAM;
//only 2 or 3 comp in the quantized version
dir = 1;
if(NbComp == 2) dir -= 2 * gf_bs_read_int(bs, 1);
orient = gf_bs_read_int(bs, 2);
if ((orient==3) && (NbComp==2)) return GF_NON_COMPLIANT_BITSTREAM;
for(i=0; i<NbComp; i++) {
value = gf_bs_read_int(bs, NbBits) - (1 << (NbBits-1) );
sign = (value >= 0) ? 1 : -1;
m_ft[i] = sign * Q_InverseQuantize(0, 1, NbBits-1, sign*value);
}
delta = 1;
for (i=0; i<NbComp; i++) {
tang[i] = gf_tan(gf_mulfix(GF_PI/4, m_ft[i]) );
delta += gf_mulfix(tang[i], tang[i]);
}
delta = gf_divfix(INT2FIX(dir), gf_sqrt(delta) );
m_ft[orient] = delta;
for (i=0; i<NbComp; i++) {
m_ft[ (orient + i+1) % (NbComp+1) ] = gf_mulfix(tang[i], delta);
}
return GF_OK;
} | 1 | C | CWE-190 | Integer Overflow or Wraparound | The product performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | https://cwe.mitre.org/data/definitions/190.html | safe |
GF_Err dac3_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;
if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DEC3;
e = gf_isom_box_write_header(s, bs);
if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DAC3;
if (e) return e;
e = gf_odf_ac3_cfg_write_bs(&ptr->cfg, bs);
if (e) return e;
if (ptr->cfg.atmos_ec3_ext || ptr->cfg.complexity_index_type) {
gf_bs_write_int(bs, 0, 7);
gf_bs_write_int(bs, ptr->cfg.atmos_ec3_ext, 1);
gf_bs_write_u8(bs, ptr->cfg.complexity_index_type);
}
return GF_OK;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
GF_Err video_sample_entry_box_size(GF_Box *s)
{
GF_Box *b;
u32 pos=0;
GF_MPEGVisualSampleEntryBox *ptr = (GF_MPEGVisualSampleEntryBox *)s;
gf_isom_video_sample_entry_size((GF_VisualSampleEntryBox *)s);
/*make sure we write the config box first, we don't care about the rest*/
/*mp4v*/
gf_isom_check_position(s, (GF_Box *)ptr->esd, &pos);
gf_isom_check_position(s, (GF_Box *)ptr->cfg_3gpp, &pos);
/*avc / SVC + MVC*/
gf_isom_check_position(s, (GF_Box *)ptr->avc_config, &pos);
gf_isom_check_position(s, (GF_Box *)ptr->svc_config, &pos);
if (ptr->mvc_config) {
gf_isom_check_position(s, gf_isom_box_find_child(s->child_boxes, GF_ISOM_BOX_TYPE_VWID), &pos);
gf_isom_check_position(s, (GF_Box *)ptr->mvc_config, &pos);
}
/*HEVC*/
gf_isom_check_position(s, (GF_Box *)ptr->hevc_config, &pos);
gf_isom_check_position(s, (GF_Box *)ptr->lhvc_config, &pos);
/*VVC*/
gf_isom_check_position(s, (GF_Box *)ptr->vvc_config, &pos);
/*AV1*/
gf_isom_check_position(s, (GF_Box *)ptr->av1_config, &pos);
/*VPx*/
gf_isom_check_position(s, (GF_Box *)ptr->vp_config, &pos);
/*JP2H*/
gf_isom_check_position(s, (GF_Box *)ptr->jp2h, &pos);
/*DolbyVision*/
gf_isom_check_position(s, (GF_Box *)ptr->dovi_config, &pos);
b = gf_isom_box_find_child(ptr->child_boxes, GF_ISOM_BOX_TYPE_ST3D);
if (b) gf_isom_check_position(s, b, &pos);
b = gf_isom_box_find_child(ptr->child_boxes, GF_ISOM_BOX_TYPE_SV3D);
if (b) gf_isom_check_position(s, b, &pos);
return GF_OK;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
void gf_isom_check_position(GF_Box *s, GF_Box *child, u32 *pos)
{
if (!s || !s->child_boxes || !child || !pos) return;
if (s->internal_flags & GF_ISOM_ORDER_FREEZE)
return;
s32 cur_pos = gf_list_find(s->child_boxes, child);
//happens when partially cloning boxes
if (cur_pos < 0) return;
if (cur_pos != (s32) *pos) {
gf_list_del_item(s->child_boxes, child);
gf_list_insert(s->child_boxes, child, *pos);
}
(*pos)++; | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
GF_EXPORT
GF_Err gf_isom_box_write(GF_Box *a, GF_BitStream *bs)
{
GF_Err e;
u64 pos = gf_bs_get_position(bs);
if (!a) return GF_BAD_PARAM;
//box has been disabled, do not write
if (!a->size) return GF_OK;
if (a->registry->disabled) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s disabled registry, skip write\n", gf_4cc_to_str(a->type)));
return GF_OK;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box %s size %d write\n", gf_4cc_to_str(a->type), a->size));
e = gf_isom_box_write_listing(a, bs);
if (e) return e;
if (a->child_boxes) {
e = gf_isom_box_array_write(a, a->child_boxes, bs);
}
pos = gf_bs_get_position(bs) - pos;
if (pos != a->size) {
if (a->type != GF_ISOM_BOX_TYPE_MDAT) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box %s wrote "LLU" bytes but size is "LLU"\n", gf_4cc_to_str(a->type), pos, a->size ));
}
}
return e; | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
const u32 *gf_isom_get_track_switch_parameter(GF_ISOFile *movie, u32 trackNumber, u32 group_index, u32 *switchGroupID, u32 *criteriaListSize)
{
GF_TrackBox *trak;
GF_UserDataMap *map;
GF_TrackSelectionBox *tsel;
trak = gf_isom_get_track_from_file(movie, trackNumber);
if (!group_index || !trak || !trak->udta) return NULL;
map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_TSEL, NULL);
if (!map) return NULL;
tsel = (GF_TrackSelectionBox*)gf_list_get(map->boxes, group_index-1);
if (!tsel) return NULL;
*switchGroupID = tsel->switchGroup;
*criteriaListSize = tsel->attributeListCount;
return (const u32 *) tsel->attributeList;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
void gf_bs_skip_bytes(GF_BitStream *bs, u64 nbBytes)
{
if (!bs || !nbBytes) return;
gf_bs_align(bs);
/*special case for file skipping...*/
if ((bs->bsmode == GF_BITSTREAM_FILE_WRITE) || (bs->bsmode == GF_BITSTREAM_FILE_READ)) {
if (bs->cache_write)
bs_flush_write_cache(bs);
if (bs->cache_read) {
u32 csize = bs->cache_read_size - bs->cache_read_pos;
if (csize>=nbBytes) {
bs->cache_read_pos += (u32) nbBytes;
bs->position += nbBytes;
return;
}
nbBytes -= csize;
bs->position += csize;
bs->cache_read_pos = bs->cache_read_size;
}
//weird msys2 bug resulting in broken seek on some files ?!? -the bug is not happening when doing absolute seek
// gf_fseek(bs->stream, nbBytes, SEEK_CUR);
bs->position += nbBytes;
if (bs->bsmode == GF_BITSTREAM_FILE_READ) {
if (bs->position > bs->size) bs->position = bs->size;
}
gf_fseek(bs->stream, bs->position, SEEK_SET);
return;
}
/*special case for reading*/
if (bs->bsmode == GF_BITSTREAM_READ) {
if (bs->remove_emul_prevention_byte) {
while (nbBytes) {
gf_bs_read_u8(bs);
nbBytes--;
}
} else {
bs->position += nbBytes;
if (bs->position>bs->size) {
bs->position = bs->size;
bs->overflow_state = 1;
}
}
return;
}
/*for writing we must do it this way, otherwise pb in dynamic buffers*/
while (nbBytes) {
gf_bs_write_int(bs, 0, 8);
nbBytes--;
}
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
void gf_filter_pid_inst_del(GF_FilterPidInst *pidinst)
{
assert(pidinst);
gf_filter_pid_inst_reset(pidinst);
gf_fq_del(pidinst->packets, (gf_destruct_fun) pcki_del);
gf_mx_del(pidinst->pck_mx);
gf_list_del(pidinst->pck_reassembly);
if (pidinst->props) {
assert(pidinst->props->reference_count);
gf_mx_p(pidinst->pid->filter->tasks_mx);
//not in parent pid, may happen when reattaching a pid inst to a different pid
//in this case do NOT delete the props
if (gf_list_find(pidinst->pid->properties, pidinst->props)>=0) {
if (safe_int_dec(&pidinst->props->reference_count) == 0) {
//see \ref gf_filter_pid_merge_properties_internal for mutex
gf_list_del_item(pidinst->pid->properties, pidinst->props);
gf_props_del(pidinst->props);
}
}
gf_mx_v(pidinst->pid->filter->tasks_mx);
}
gf_free(pidinst);
} | 1 | C | CWE-400 | Uncontrolled Resource Consumption | The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
static GF_Err xml_sax_append_string(GF_SAXParser *parser, char *string)
{
u32 size = parser->line_size;
u32 nl_size = string ? (u32) strlen(string) : 0;
if (!nl_size) return GF_OK;
if ( (parser->alloc_size < size+nl_size+1)
/* || (parser->alloc_size / 2 ) > size+nl_size+1 */
)
{
parser->alloc_size = size+nl_size+1;
parser->alloc_size = 3 * parser->alloc_size / 2;
parser->buffer = (char*)gf_realloc(parser->buffer, sizeof(char) * parser->alloc_size);
if (!parser->buffer ) return GF_OUT_OF_MEM;
}
memcpy(parser->buffer+size, string, sizeof(char)*nl_size);
parser->buffer[size+nl_size] = 0;
parser->line_size = size+nl_size;
return GF_OK;
} | 1 | C | CWE-476 | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | https://cwe.mitre.org/data/definitions/476.html | safe |
static void xml_sax_parse_entity(GF_SAXParser *parser)
{
char szC[2];
char *ent_name=NULL;
u32 i = 0;
XML_Entity *ent = (XML_Entity *)gf_list_last(parser->entities);
char *skip_chars = " \t\n\r";
i=0;
if (ent && ent->value) ent = NULL;
if (ent) skip_chars = NULL;
szC[1]=0;
while (parser->current_pos+i < parser->line_size) {
u8 c = parser->buffer[parser->current_pos+i];
if (skip_chars && strchr(skip_chars, c)) {
if (c=='\n') parser->line++;
parser->current_pos++;
continue;
}
if (!ent && (c=='%')) {
parser->current_pos+=i+1;
parser->sax_state = SAX_STATE_SKIP_DOCTYPE;
if (ent_name) gf_free(ent_name);
return;
}
else if (!ent && ((c=='\"') || (c=='\'')) ) {
GF_SAFEALLOC(ent, XML_Entity);
if (!ent) {
parser->sax_state = SAX_STATE_ALLOC_ERROR;
if (ent_name) gf_free(ent_name);
return;
}
if (!ent_name) gf_dynstrcat(&ent_name, "", NULL);
ent->name = ent_name;
ent_name=NULL;
ent->namelen = (u32) strlen(ent->name);
ent->sep = c;
parser->current_pos += 1+i;
assert(parser->current_pos < parser->line_size);
xml_sax_swap(parser);
i=0;
gf_list_add(parser->entities, ent);
skip_chars = NULL;
} else if (ent && c==ent->sep) {
if (ent_name) gf_free(ent_name);
xml_sax_store_text(parser, i);
ent->value = xml_get_current_text(parser);
if (!ent->value) ent->value = gf_strdup("");
parser->current_pos += 1;
assert(parser->current_pos < parser->line_size);
xml_sax_swap(parser);
parser->sax_state = SAX_STATE_SKIP_DOCTYPE;
return;
} else if (!ent) {
szC[0] = c;
gf_dynstrcat(&ent_name, szC, NULL);
i++;
} else {
i++;
}
}
if (ent_name) gf_free(ent_name);
if (ent && !ent->value)
parser->sax_state = SAX_STATE_SYNTAX_ERROR;
xml_sax_store_text(parser, i);
} | 1 | C | CWE-476 | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | https://cwe.mitre.org/data/definitions/476.html | safe |
int AVI_read_audio(avi_t *AVI, u8 *audbuf, int bytes, int *continuous)
{
int nr, todo;
s64 pos;
if(AVI->mode==AVI_MODE_WRITE) {
AVI_errno = AVI_ERR_NOT_PERM;
return -1;
}
if(!AVI->track[AVI->aptr].audio_index) {
AVI_errno = AVI_ERR_NO_IDX;
return -1;
}
nr = 0; /* total number of bytes read */
if (bytes==0) {
AVI->track[AVI->aptr].audio_posc++;
AVI->track[AVI->aptr].audio_posb = 0;
}
*continuous = 1;
while(bytes>0)
{
s64 ret;
int left = (int) (AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].len - AVI->track[AVI->aptr].audio_posb);
if(left==0)
{
if(AVI->track[AVI->aptr].audio_posc>=AVI->track[AVI->aptr].audio_chunks-1) return nr;
AVI->track[AVI->aptr].audio_posc++;
AVI->track[AVI->aptr].audio_posb = 0;
*continuous = 0;
continue;
}
if(bytes<left)
todo = bytes;
else
todo = left;
pos = AVI->track[AVI->aptr].audio_index[AVI->track[AVI->aptr].audio_posc].pos + AVI->track[AVI->aptr].audio_posb;
gf_fseek(AVI->fdes, pos, SEEK_SET);
AVI->track[AVI->aptr].audio_posb += todo;
if ( (ret = avi_read(AVI->fdes,audbuf+nr,todo)) != todo)
{
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[avilib] XXX pos = %"LLD", ret = %"LLD", todo = %ld\n", pos, ret, todo));
AVI_errno = AVI_ERR_READ;
return -1;
}
bytes -= todo;
nr += todo;
}
return nr;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
int AVI_read_frame(avi_t *AVI, u8 *vidbuf, int *keyframe)
{
int n;
if(AVI->mode==AVI_MODE_WRITE) {
AVI_errno = AVI_ERR_NOT_PERM;
return -1;
}
if(!AVI->video_index) {
AVI_errno = AVI_ERR_NO_IDX;
return -1;
}
if(AVI->video_pos < 0 || AVI->video_pos >= AVI->video_frames) return -1;
n = (u32) AVI->video_index[AVI->video_pos].len;
*keyframe = (AVI->video_index[AVI->video_pos].key==0x10) ? 1:0;
if (vidbuf == NULL) {
AVI->video_pos++;
return n;
}
gf_fseek(AVI->fdes, AVI->video_index[AVI->video_pos].pos, SEEK_SET);
AVI->video_pos++;
if (avi_read(AVI->fdes,vidbuf,n) != (u32) n)
{
AVI_errno = AVI_ERR_READ;
return -1;
}
return n;
} | 1 | C | CWE-122 | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | safe |
static void get_info_from_frame (mpeg2ps_stream_t *sptr,
u8 *buffer,
u32 buflen)
{
if (sptr->is_video) {
if (MPEG12_ParseSeqHdr(buffer, buflen,
&sptr->have_mpeg2,
&sptr->h,
&sptr->w,
&sptr->frame_rate,
&sptr->bit_rate,
&sptr->par) < 0) {
sptr->m_stream_id = 0;
sptr->m_fd = FDNULL;
return;
}
sptr->ticks_per_frame = (u64)(90000.0 / sptr->frame_rate);
return;
}
if (sptr->m_stream_id >= 0xc0) {
// mpeg audio
u32 hdr = GF_4CC((u32)buffer[0],buffer[1],buffer[2],buffer[3]);
sptr->channels = gf_mp3_num_channels(hdr);
sptr->freq = gf_mp3_sampling_rate(hdr);
sptr->samples_per_frame = gf_mp3_window_size(hdr);
sptr->bitrate = gf_mp3_bit_rate(hdr) * 1000; // give bps, not kbps
sptr->layer = gf_mp3_layer(hdr);
} else if (sptr->m_stream_id == 0xbd) {
if (sptr->m_substream_id >= 0xa0) {
// PCM - ???
} else if (sptr->m_substream_id >= 0x80) {
u32 pos;
GF_AC3Config hdr;
memset(&hdr, 0, sizeof(GF_AC3Config));
gf_ac3_parser(buffer, buflen, &pos, &hdr, 0);
sptr->bitrate = gf_ac3_get_bitrate(hdr.brcode);
sptr->freq = hdr.sample_rate;
sptr->channels = hdr.streams[0].channels;
sptr->samples_per_frame = 256 * 6;
} else {
return;
}
} else {
return;
}
} | 1 | C | CWE-476 | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | https://cwe.mitre.org/data/definitions/476.html | safe |
GF_Err gf_swf_read_header(SWFReader *read)
{
SWFRec rc;
u8 sig[3];
/*get signature*/
sig[0] = gf_bs_read_u8(read->bs);
sig[1] = gf_bs_read_u8(read->bs);
sig[2] = gf_bs_read_u8(read->bs);
/*"FWS" or "CWS"*/
if ( ((sig[0] != 'F') && (sig[0] != 'C')) || (sig[1] != 'W') || (sig[2] != 'S') ) {
return GF_NON_COMPLIANT_BITSTREAM;
}
/*version = */gf_bs_read_u8(read->bs);
read->length = swf_get_32(read);
/*if compressed decompress the whole file*/
if (sig[0] == 'C') {
swf_init_decompress(read);
if (!read->bs) return GF_NON_COMPLIANT_BITSTREAM;
}
swf_get_rec(read, &rc);
read->width = rc.w;
read->height = rc.h;
swf_align(read);
read->frame_rate = swf_get_16(read)>>8;
read->frame_count = swf_get_16(read);
GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("SWF Import - Scene Size %gx%g - %d frames @ %d FPS\n", read->width, read->height, read->frame_count, read->frame_rate));
if (!read->frame_rate) read->frame_rate = 1;
return GF_OK;
} | 1 | C | CWE-369 | Divide By Zero | The product divides a value by zero. | https://cwe.mitre.org/data/definitions/369.html | safe |
static u32 swf_get_32(SWFReader *read)
{
return gf_bs_read_u32_le(read->bs);
} | 1 | C | CWE-1077 | Floating Point Comparison with Incorrect Operator | The code performs a comparison such as an
equality test between two float (floating point) values, but
it uses comparison operators that do not account for the
possibility of loss of precision. | https://cwe.mitre.org/data/definitions/1077.html | safe |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.