func
stringlengths 0
484k
| target
int64 0
1
| cwe
listlengths 0
4
| project
stringclasses 799
values | 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
|
---|---|---|---|---|---|---|---|
lyd_wd_default(struct lyd_node_leaf_list *node)
{
struct lys_node_leaf *leaf;
struct lys_node_leaflist *llist;
struct lyd_node *iter;
struct lys_tpdf *tpdf;
const char *dflt = NULL, **dflts = NULL;
uint8_t dflts_size = 0, c, i;
if (!node || !(node->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
return 0;
}
if (node->dflt) {
return 1;
}
if (node->schema->nodetype == LYS_LEAF) {
leaf = (struct lys_node_leaf *)node->schema;
/* get know if there is a default value */
if (leaf->dflt) {
/* leaf has a default value */
dflt = leaf->dflt;
} else if (!(leaf->flags & LYS_MAND_TRUE)) {
/* get the default value from the type */
for (tpdf = leaf->type.der; tpdf && !dflt; tpdf = tpdf->type.der) {
dflt = tpdf->dflt;
}
}
if (!dflt) {
/* no default value */
return 0;
}
/* compare the default value with the value of the leaf */
if (!ly_strequal(dflt, node->value_str, 1)) {
return 0;
}
} else if (node->schema->module->version >= LYS_VERSION_1_1) { /* LYS_LEAFLIST */
llist = (struct lys_node_leaflist *)node->schema;
/* get know if there is a default value */
if (llist->dflt_size) {
/* there are default values */
dflts_size = llist->dflt_size;
dflts = llist->dflt;
} else if (!llist->min) {
/* get the default value from the type */
for (tpdf = llist->type.der; tpdf && !dflts; tpdf = tpdf->type.der) {
if (tpdf->dflt) {
dflts = &tpdf->dflt;
dflts_size = 1;
break;
}
}
}
if (!dflts_size) {
/* no default values to use */
return 0;
}
/* compare the default value with the value of the leaf */
/* first, find the first leaf-list's sibling */
iter = (struct lyd_node *)node;
if (iter->parent) {
iter = iter->parent->child;
} else {
for (; iter->prev->next; iter = iter->prev);
}
for (c = 0; iter; iter = iter->next) {
if (iter->schema != node->schema) {
continue;
}
if (c == dflts_size) {
/* to many leaf-list instances */
return 0;
}
if (llist->flags & LYS_USERORDERED) {
/* we have strict order */
if (!ly_strequal(dflts[c], ((struct lyd_node_leaf_list *)iter)->value_str, 1)) {
return 0;
}
} else {
/* node's value is supposed to match with one of the default values */
for (i = 0; i < dflts_size; i++) {
if (ly_strequal(dflts[i], ((struct lyd_node_leaf_list *)iter)->value_str, 1)) {
break;
}
}
if (i == dflts_size) {
/* values do not match */
return 0;
}
}
c++;
}
if (c != dflts_size) {
/* different sets of leaf-list instances */
return 0;
}
} else {
return 0;
}
/* all checks ok */
return 1;
}
| 0 |
[
"CWE-119"
] |
libyang
|
32fb4993bc8bb49e93e84016af3c10ea53964be5
| 320,693,286,108,187,500,000,000,000,000,000,000,000 | 110 |
schema tree BUGFIX do not check features while still resolving schema
Fixes #723
|
static int em_rdpmc(struct x86_emulate_ctxt *ctxt)
{
u64 pmc;
if (ctxt->ops->read_pmc(ctxt, ctxt->regs[VCPU_REGS_RCX], &pmc))
return emulate_gp(ctxt, 0);
ctxt->regs[VCPU_REGS_RAX] = (u32)pmc;
ctxt->regs[VCPU_REGS_RDX] = pmc >> 32;
return X86EMUL_CONTINUE;
}
| 0 |
[] |
kvm
|
e28ba7bb020f07193bc000453c8775e9d2c0dda7
| 41,213,839,657,130,733,000,000,000,000,000,000,000 | 10 |
KVM: x86: fix missing checks in syscall emulation
On hosts without this patch, 32bit guests will crash (and 64bit guests
may behave in a wrong way) for example by simply executing following
nasm-demo-application:
[bits 32]
global _start
SECTION .text
_start: syscall
(I tested it with winxp and linux - both always crashed)
Disassembly of section .text:
00000000 <_start>:
0: 0f 05 syscall
The reason seems a missing "invalid opcode"-trap (int6) for the
syscall opcode "0f05", which is not available on Intel CPUs
within non-longmodes, as also on some AMD CPUs within legacy-mode.
(depending on CPU vendor, MSR_EFER and cpuid)
Because previous mentioned OSs may not engage corresponding
syscall target-registers (STAR, LSTAR, CSTAR), they remain
NULL and (non trapping) syscalls are leading to multiple
faults and finally crashs.
Depending on the architecture (AMD or Intel) pretended by
guests, various checks according to vendor's documentation
are implemented to overcome the current issue and behave
like the CPUs physical counterparts.
[mtosatti: cleanup/beautify code]
Signed-off-by: Stephan Baerwolf <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]>
|
int js_pcall(js_State *J, int n)
{
int savetop = TOP - n - 2;
if (js_try(J)) {
/* clean up the stack to only hold the error object */
STACK[savetop] = STACK[TOP-1];
TOP = savetop + 1;
return 1;
}
js_call(J, n);
js_endtry(J);
return 0;
}
| 0 |
[
"CWE-476"
] |
mujs
|
77ab465f1c394bb77f00966cd950650f3f53cb24
| 307,349,336,255,863,400,000,000,000,000,000,000,000 | 13 |
Fix 697401: Error when dropping extra arguments to lightweight functions.
|
static int default_task_finished(int result,
struct strbuf *out,
void *pp_cb,
void *pp_task_cb)
{
return 0;
}
| 0 |
[] |
git
|
321fd82389742398d2924640ce3a61791fd27d60
| 217,458,498,447,260,600,000,000,000,000,000,000,000 | 7 |
run-command: mark path lookup errors with ENOENT
Since commit e3a434468f (run-command: use the
async-signal-safe execv instead of execvp, 2017-04-19),
prepare_cmd() does its own PATH lookup for any commands we
run (on non-Windows platforms).
However, its logic does not match the old execvp call when
we fail to find a matching entry in the PATH. Instead of
feeding the name directly to execv, execvp would consider
that an ENOENT error. By continuing and passing the name
directly to execv, we effectively behave as if "." was
included at the end of the PATH. This can have confusing and
even dangerous results.
The fix itself is pretty straight-forward. There's a new
test in t0061 to cover this explicitly, and I've also added
a duplicate of the ENOENT test to ensure that we return the
correct errno for this case.
Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
|
DeepTiledInputFile::Data::~Data ()
{
delete [] numXTiles;
delete [] numYTiles;
for (size_t i = 0; i < tileBuffers.size(); i++)
delete tileBuffers[i];
if (multiPartBackwardSupport)
delete multiPartFile;
for (size_t i = 0; i < slices.size(); i++)
delete slices[i];
}
| 1 |
[
"CWE-125"
] |
openexr
|
e79d2296496a50826a15c667bf92bdc5a05518b4
| 192,721,349,196,138,450,000,000,000,000,000,000,000 | 14 |
fix memory leaks and invalid memory accesses
Signed-off-by: Peter Hillman <[email protected]>
|
static bool acl_group_override(connection_struct *conn,
SMB_STRUCT_STAT *psbuf,
const char *fname)
{
if ((errno != EPERM) && (errno != EACCES)) {
return false;
}
/* file primary group == user primary or supplementary group */
if (lp_acl_group_control(SNUM(conn)) &&
current_user_in_group(psbuf->st_gid)) {
return true;
}
/* user has writeable permission */
if (lp_dos_filemode(SNUM(conn)) &&
can_write_to_file(conn, fname, psbuf)) {
return true;
}
return false;
}
| 0 |
[
"CWE-264"
] |
samba
|
d6c28913f3109d1327a3d1369b6eafd3874b2dca
| 98,370,203,701,003,000,000,000,000,000,000,000,000 | 22 |
Bug 6488: acl_group_override() call in posix acls references an uninitialized variable.
(cherry picked from commit f92195e3a1baaddda47a5d496f9488c8445b41ad)
|
TEST_F(OptimizePipeline, MixedMatchPushedDown) {
auto unpack = fromjson(
"{$_internalUnpackBucket: { exclude: [], timeField: 'time', metaField: 'myMeta', "
"bucketMaxSpanSeconds: 3600}}");
auto pipeline = Pipeline::parse(
makeVector(unpack, fromjson("{$match: {myMeta: {$gte: 0, $lte: 5}, a: {$lte: 4}}}")),
getExpCtx());
ASSERT_EQ(2u, pipeline->getSources().size());
pipeline->optimizePipeline();
// To get the optimized $match from the pipeline, we have to serialize with explain.
auto stages = pipeline->writeExplainOps(ExplainOptions::Verbosity::kQueryPlanner);
ASSERT_EQ(3u, stages.size());
// We should push down the $match on the metaField and the predicates on the control field.
// The created $match stages should be added before $_internalUnpackBucket and merged.
ASSERT_BSONOBJ_EQ(fromjson("{$match: {$and: [{'control.min.a': {$_internalExprLte: 4}}, {meta: "
"{$gte: 0}}, {meta: {$lte: 5}}]}}"),
stages[0].getDocument().toBson());
ASSERT_BSONOBJ_EQ(unpack, stages[1].getDocument().toBson());
ASSERT_BSONOBJ_EQ(fromjson("{$match: {a: {$lte: 4}}}"), stages[2].getDocument().toBson());
}
| 1 |
[] |
mongo
|
b3107d73a2c58d7e016b834dae0acfd01c0db8d7
| 64,275,006,503,360,730,000,000,000,000,000,000,000 | 23 |
SERVER-59299: Flatten top-level nested $match stages in doOptimizeAt
(cherry picked from commit 4db5eceda2cff697f35c84cd08232bac8c33beec)
|
void ListenerImpl::initialize() {
last_updated_ = listener_factory_context_->timeSource().systemTime();
// If workers have already started, we shift from using the global init manager to using a local
// per listener init manager. See ~ListenerImpl() for why we gate the onListenerWarmed() call
// by resetting the watcher.
if (workers_started_) {
ENVOY_LOG_MISC(debug, "Initialize listener {} local-init-manager.", name_);
// If workers_started_ is true, dynamic_init_manager_ should be initialized by listener
// manager directly.
dynamic_init_manager_->initialize(local_init_watcher_);
}
}
| 0 |
[
"CWE-400"
] |
envoy
|
dfddb529e914d794ac552e906b13d71233609bf7
| 202,602,784,923,836,000,000,000,000,000,000,000,000 | 12 |
listener: Add configurable accepted connection limits (#153)
Add support for per-listener limits on accepted connections.
Signed-off-by: Tony Allen <[email protected]>
|
static int socket_from_display(const char *display, char **path) {
size_t k;
char *f, *c;
assert(display);
assert(path);
if (!display_is_local(display))
return -EINVAL;
k = strspn(display+1, "0123456789");
f = new(char, STRLEN("/tmp/.X11-unix/X") + k + 1);
if (!f)
return -ENOMEM;
c = stpcpy(f, "/tmp/.X11-unix/X");
memcpy(c, display+1, k);
c[k] = 0;
*path = f;
return 0;
}
| 0 |
[
"CWE-863"
] |
systemd
|
83d4ab55336ff8a0643c6aa627b31e351a24040a
| 310,526,234,996,084,300,000,000,000,000,000,000,000 | 24 |
pam-systemd: use secure_getenv() rather than getenv()
And explain why in a comment.
|
static void pcnet_rdte_poll(PCNetState *s)
{
s->csr[28] = s->csr[29] = 0;
if (s->rdra) {
int bad = 0;
#if 1
hwaddr crda = pcnet_rdra_addr(s, CSR_RCVRC(s));
hwaddr nrda = pcnet_rdra_addr(s, -1 + CSR_RCVRC(s));
hwaddr nnrd = pcnet_rdra_addr(s, -2 + CSR_RCVRC(s));
#else
hwaddr crda = s->rdra +
(CSR_RCVRL(s) - CSR_RCVRC(s)) *
(BCR_SWSTYLE(s) ? 16 : 8 );
int nrdc = CSR_RCVRC(s)<=1 ? CSR_RCVRL(s) : CSR_RCVRC(s)-1;
hwaddr nrda = s->rdra +
(CSR_RCVRL(s) - nrdc) *
(BCR_SWSTYLE(s) ? 16 : 8 );
int nnrc = nrdc<=1 ? CSR_RCVRL(s) : nrdc-1;
hwaddr nnrd = s->rdra +
(CSR_RCVRL(s) - nnrc) *
(BCR_SWSTYLE(s) ? 16 : 8 );
#endif
CHECK_RMD(crda, bad);
if (!bad) {
CHECK_RMD(nrda, bad);
if (bad || (nrda == crda)) nrda = 0;
CHECK_RMD(nnrd, bad);
if (bad || (nnrd == crda)) nnrd = 0;
s->csr[28] = crda & 0xffff;
s->csr[29] = crda >> 16;
s->csr[26] = nrda & 0xffff;
s->csr[27] = nrda >> 16;
s->csr[36] = nnrd & 0xffff;
s->csr[37] = nnrd >> 16;
#ifdef PCNET_DEBUG
if (bad) {
printf("pcnet: BAD RMD RECORDS AFTER 0x" TARGET_FMT_plx "\n",
crda);
}
} else {
printf("pcnet: BAD RMD RDA=0x" TARGET_FMT_plx "\n", crda);
#endif
}
}
if (CSR_CRDA(s)) {
struct pcnet_RMD rmd;
RMDLOAD(&rmd, PHYSADDR(s,CSR_CRDA(s)));
CSR_CRBC(s) = GET_FIELD(rmd.buf_length, RMDL, BCNT);
CSR_CRST(s) = rmd.status;
#ifdef PCNET_DEBUG_RMD_X
printf("CRDA=0x%08x CRST=0x%04x RCVRC=%d RMDL=0x%04x RMDS=0x%04x RMDM=0x%08x\n",
PHYSADDR(s,CSR_CRDA(s)), CSR_CRST(s), CSR_RCVRC(s),
rmd.buf_length, rmd.status, rmd.msg_length);
PRINT_RMD(&rmd);
#endif
} else {
CSR_CRBC(s) = CSR_CRST(s) = 0;
}
if (CSR_NRDA(s)) {
struct pcnet_RMD rmd;
RMDLOAD(&rmd, PHYSADDR(s,CSR_NRDA(s)));
CSR_NRBC(s) = GET_FIELD(rmd.buf_length, RMDL, BCNT);
CSR_NRST(s) = rmd.status;
} else {
CSR_NRBC(s) = CSR_NRST(s) = 0;
}
}
| 0 |
[
"CWE-835"
] |
qemu
|
99ccfaa1edafd79f7a3a0ff7b58ae4da7c514928
| 39,211,450,988,372,280,000,000,000,000,000,000,000 | 72 |
pcnet: switch to use qemu_receive_packet() for loopback
This patch switches to use qemu_receive_packet() which can detect
reentrancy and return early.
This is intended to address CVE-2021-3416.
Cc: Prasad J Pandit <[email protected]>
Cc: [email protected]
Buglink: https://bugs.launchpad.net/qemu/+bug/1917085
Reviewed-by: Philippe Mathieu-Daudé <[email protected]
Signed-off-by: Alexander Bulekov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
|
lys_ingrouping(const struct lys_node *node)
{
const struct lys_node *iter = node;
assert(node);
for(iter = node; iter && iter->nodetype != LYS_GROUPING; iter = lys_parent(iter));
if (!iter) {
return 0;
} else {
return 1;
}
}
| 0 |
[
"CWE-119"
] |
libyang
|
32fb4993bc8bb49e93e84016af3c10ea53964be5
| 55,099,566,141,686,270,000,000,000,000,000,000,000 | 12 |
schema tree BUGFIX do not check features while still resolving schema
Fixes #723
|
static int execute_decode_slices(H264Context *h, int context_count)
{
AVCodecContext *const avctx = h->avctx;
H264Context *hx;
int i;
av_assert0(h->mb_y < h->mb_height);
if (h->avctx->hwaccel ||
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
return 0;
if (context_count == 1) {
return decode_slice(avctx, &h);
} else {
av_assert0(context_count > 0);
for (i = 1; i < context_count; i++) {
hx = h->thread_context[i];
if (CONFIG_ERROR_RESILIENCE) {
hx->er.error_count = 0;
}
hx->x264_build = h->x264_build;
}
avctx->execute(avctx, decode_slice, h->thread_context,
NULL, context_count, sizeof(void *));
/* pull back stuff from slices to master context */
hx = h->thread_context[context_count - 1];
h->mb_x = hx->mb_x;
h->mb_y = hx->mb_y;
h->droppable = hx->droppable;
h->picture_structure = hx->picture_structure;
if (CONFIG_ERROR_RESILIENCE) {
for (i = 1; i < context_count; i++)
h->er.error_count += h->thread_context[i]->er.error_count;
}
}
return 0;
}
| 0 |
[
"CWE-703"
] |
FFmpeg
|
8a3b85f3a7952c54a2c36ba1797f7e0cde9f85aa
| 270,886,298,238,122,650,000,000,000,000,000,000,000 | 40 |
avcodec/h264: update current_sps & sps->new only after the whole slice header decoder and init code finished
This avoids them being cleared before the full initialization finished
Fixes out of array read
Fixes: asan_heap-oob_f0c5e6_7071_cov_1605985132_mov_h264_aac__Demo_FlagOfOurFathers.mov
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <[email protected]>
|
bool check_grant_db(THD *thd,const char *db)
{
Security_context *sctx= thd->security_ctx;
char helping [NAME_LEN+USERNAME_LENGTH+2];
uint len;
bool error= TRUE;
size_t copy_length;
copy_length= (size_t) (strlen(sctx->priv_user) +
strlen(db ? db : "")) + 1; /* Added 1 at the end to avoid
buffer overflow at strmov()*/
/*
Make sure that strmov() operations do not result in buffer overflow.
*/
if (copy_length >= (NAME_LEN+USERNAME_LENGTH+2))
return 1;
len= (uint) (strmov(strmov(helping, sctx->priv_user) + 1, db) - helping) + 1;
mysql_rwlock_rdlock(&LOCK_grant);
for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
{
GRANT_TABLE *grant_table= (GRANT_TABLE*)
my_hash_element(&column_priv_hash,
idx);
if (len < grant_table->key_length &&
!memcmp(grant_table->hash_key,helping,len) &&
grant_table->host.compare_hostname(sctx->get_host()->ptr(),
sctx->get_ip()->ptr()))
{
error= FALSE; /* Found match. */
break;
}
}
if (error)
error= check_grant_db_routine(thd, db, &proc_priv_hash) &&
check_grant_db_routine(thd, db, &func_priv_hash);
mysql_rwlock_unlock(&LOCK_grant);
return error;
}
| 0 |
[] |
mysql-server
|
25d1b7e03b9b375a243fabdf0556c063c7282361
| 207,279,446,827,649,950,000,000,000,000,000,000,000 | 45 |
Bug #22722946: integer overflow may lead to wrong results in get_56_lenc_string
|
static BOOL rdp_write_window_list_capability_set(wStream* s, const rdpSettings* settings)
{
size_t header;
if (!Stream_EnsureRemainingCapacity(s, 32))
return FALSE;
header = rdp_capability_set_start(s);
Stream_Write_UINT32(s, settings->RemoteWndSupportLevel); /* wndSupportLevel (4 bytes) */
Stream_Write_UINT8(s, settings->RemoteAppNumIconCaches); /* numIconCaches (1 byte) */
Stream_Write_UINT16(s,
settings->RemoteAppNumIconCacheEntries); /* numIconCacheEntries (2 bytes) */
rdp_capability_set_finish(s, header, CAPSET_TYPE_WINDOW);
return TRUE;
}
| 0 |
[
"CWE-119",
"CWE-125"
] |
FreeRDP
|
3627aaf7d289315b614a584afb388f04abfb5bbf
| 269,751,178,337,666,000,000,000,000,000,000,000,000 | 15 |
Fixed #6011: Bounds check in rdp_read_font_capability_set
|
usm_set_usmStateReference_auth_protocol(struct usmStateReference *ref,
oid * auth_protocol,
size_t auth_protocol_len)
{
MAKE_ENTRY(ref, oid, auth_protocol, auth_protocol_len,
usr_auth_protocol, usr_auth_protocol_length);
}
| 0 |
[
"CWE-415"
] |
net-snmp
|
5f881d3bf24599b90d67a45cae7a3eb099cd71c9
| 68,938,668,970,766,910,000,000,000,000,000,000,000 | 7 |
libsnmp, USM: Introduce a reference count in struct usmStateReference
This patch fixes https://sourceforge.net/p/net-snmp/bugs/2956/.
|
static void string_list_free(string_list* list)
{
/* Note: we don't free the contents of the strings array: this */
/* is handled by the caller, either by returning this */
/* content, or freeing it itself. */
free(list->strings);
}
| 0 |
[
"CWE-787"
] |
FreeRDP
|
8305349a943c68b1bc8c158f431dc607655aadea
| 20,158,190,027,491,407,000,000,000,000,000,000,000 | 7 |
Fixed GHSL-2020-102 heap overflow
(cherry picked from commit 197b16cc15a12813c2e4fa2d6ae9cd9c4a57e581)
|
jas_image_t *jas_image_chclrspc(jas_image_t *image, jas_cmprof_t *outprof,
int intent)
{
jas_image_t *inimage;
int minhstep;
int minvstep;
int i;
int j;
int k;
int n;
int hstep;
int vstep;
int numinauxchans;
int numoutauxchans;
int numinclrchans;
int numoutclrchans;
int prec;
jas_image_t *outimage;
int cmpttype;
int numoutchans;
jas_cmprof_t *inprof;
jas_cmprof_t *tmpprof;
jas_image_cmptparm_t cmptparm;
int width;
int height;
jas_cmxform_t *xform;
jas_cmpixmap_t inpixmap;
jas_cmpixmap_t outpixmap;
jas_cmcmptfmt_t *incmptfmts;
jas_cmcmptfmt_t *outcmptfmts;
#if 0
jas_eprintf("IMAGE\n");
jas_image_dump(image, stderr);
#endif
if (!(inimage = jas_image_copy(image)))
goto error;
image = 0;
if (!jas_image_ishomosamp(inimage)) {
minhstep = jas_image_cmpthstep(inimage, 0);
minvstep = jas_image_cmptvstep(inimage, 0);
for (i = 1; i < jas_image_numcmpts(inimage); ++i) {
hstep = jas_image_cmpthstep(inimage, i);
vstep = jas_image_cmptvstep(inimage, i);
if (hstep < minhstep)
minhstep = hstep;
if (vstep < minvstep)
minvstep = vstep;
}
n = jas_image_numcmpts(inimage);
for (i = 0; i < n; ++i) {
cmpttype = jas_image_cmpttype(inimage, i);
if (jas_image_sampcmpt(inimage, i, i + 1, 0, 0, minhstep, minvstep, jas_image_cmptsgnd(inimage, i), jas_image_cmptprec(inimage, i)))
goto error;
jas_image_setcmpttype(inimage, i + 1, cmpttype);
jas_image_delcmpt(inimage, i);
}
}
width = jas_image_cmptwidth(inimage, 0);
height = jas_image_cmptheight(inimage, 0);
hstep = jas_image_cmpthstep(inimage, 0);
vstep = jas_image_cmptvstep(inimage, 0);
inprof = jas_image_cmprof(inimage);
assert(inprof);
numinclrchans = jas_clrspc_numchans(jas_cmprof_clrspc(inprof));
numinauxchans = jas_image_numcmpts(inimage) - numinclrchans;
numoutclrchans = jas_clrspc_numchans(jas_cmprof_clrspc(outprof));
numoutauxchans = 0;
numoutchans = numoutclrchans + numoutauxchans;
prec = 8;
if (!(outimage = jas_image_create0()))
goto error;
/* Create a component for each of the colorants. */
for (i = 0; i < numoutclrchans; ++i) {
cmptparm.tlx = 0;
cmptparm.tly = 0;
cmptparm.hstep = hstep;
cmptparm.vstep = vstep;
cmptparm.width = width;
cmptparm.height = height;
cmptparm.prec = prec;
cmptparm.sgnd = 0;
if (jas_image_addcmpt(outimage, -1, &cmptparm))
goto error;
jas_image_setcmpttype(outimage, i, JAS_IMAGE_CT_COLOR(i));
}
#if 0
/* Copy the auxiliary components without modification. */
for (i = 0; i < jas_image_numcmpts(inimage); ++i) {
if (!ISCOLOR(jas_image_cmpttype(inimage, i))) {
jas_image_copycmpt(outimage, -1, inimage, i);
/* XXX - need to specify laydown of component on ref. grid */
}
}
#endif
if (!(tmpprof = jas_cmprof_copy(outprof)))
goto error;
assert(!jas_image_cmprof(outimage));
jas_image_setcmprof(outimage, tmpprof);
tmpprof = 0;
jas_image_setclrspc(outimage, jas_cmprof_clrspc(outprof));
if (!(xform = jas_cmxform_create(inprof, outprof, 0, JAS_CMXFORM_OP_FWD, intent, 0)))
goto error;
inpixmap.numcmpts = numinclrchans;
incmptfmts = malloc(numinclrchans * sizeof(jas_cmcmptfmt_t));
assert(incmptfmts);
inpixmap.cmptfmts = incmptfmts;
for (i = 0; i < numinclrchans; ++i) {
j = jas_image_getcmptbytype(inimage, JAS_IMAGE_CT_COLOR(i));
assert(j >= 0);
if (!(incmptfmts[i].buf = malloc(width * sizeof(long))))
goto error;
incmptfmts[i].prec = jas_image_cmptprec(inimage, j);
incmptfmts[i].sgnd = jas_image_cmptsgnd(inimage, j);
incmptfmts[i].width = width;
incmptfmts[i].height = 1;
}
outpixmap.numcmpts = numoutclrchans;
outcmptfmts = malloc(numoutclrchans * sizeof(jas_cmcmptfmt_t));
assert(outcmptfmts);
outpixmap.cmptfmts = outcmptfmts;
for (i = 0; i < numoutclrchans; ++i) {
j = jas_image_getcmptbytype(outimage, JAS_IMAGE_CT_COLOR(i));
assert(j >= 0);
if (!(outcmptfmts[i].buf = malloc(width * sizeof(long))))
goto error;
outcmptfmts[i].prec = jas_image_cmptprec(outimage, j);
outcmptfmts[i].sgnd = jas_image_cmptsgnd(outimage, j);
outcmptfmts[i].width = width;
outcmptfmts[i].height = 1;
}
for (i = 0; i < height; ++i) {
for (j = 0; j < numinclrchans; ++j) {
k = jas_image_getcmptbytype(inimage, JAS_IMAGE_CT_COLOR(j));
if (jas_image_readcmpt2(inimage, k, 0, i, width, 1, incmptfmts[j].buf))
goto error;
}
jas_cmxform_apply(xform, &inpixmap, &outpixmap);
for (j = 0; j < numoutclrchans; ++j) {
k = jas_image_getcmptbytype(outimage, JAS_IMAGE_CT_COLOR(j));
if (jas_image_writecmpt2(outimage, k, 0, i, width, 1, outcmptfmts[j].buf))
goto error;
}
}
for (i = 0; i < numoutclrchans; ++i)
jas_free(outcmptfmts[i].buf);
jas_free(outcmptfmts);
for (i = 0; i < numinclrchans; ++i)
jas_free(incmptfmts[i].buf);
jas_free(incmptfmts);
jas_cmxform_destroy(xform);
jas_image_destroy(inimage);
#if 0
jas_eprintf("INIMAGE\n");
jas_image_dump(inimage, stderr);
jas_eprintf("OUTIMAGE\n");
jas_image_dump(outimage, stderr);
#endif
return outimage;
error:
return 0;
}
| 0 |
[
"CWE-189"
] |
jasper
|
3c55b399c36ef46befcb21e4ebc4799367f89684
| 291,120,294,607,828,320,000,000,000,000,000,000,000 | 176 |
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.
|
static void add_static_types(struct cli_bc *bc)
{
unsigned i;
for (i=0;i<NUM_STATIC_TYPES;i++) {
bc->types[i].kind = DPointerType;
bc->types[i].numElements = 1;
bc->types[i].containedTypes = &containedTy[i];
bc->types[i].size = bc->types[i].align = 8;
}
}
| 0 |
[
"CWE-189"
] |
clamav-devel
|
3d664817f6ef833a17414a4ecea42004c35cc42f
| 138,967,419,496,378,890,000,000,000,000,000,000,000 | 10 |
fix recursion level crash (bb #3706).
Thanks to Stephane Chazelas for the analysis.
|
void CLASS samsung_load_raw()
{
int row, col, c, i, dir, op[4], len[4];
order = 0x4949;
for (row=0; row < raw_height; row++) {
#ifdef LIBRAW_LIBRARY_BUILD
checkCancel();
#endif
fseek (ifp, strip_offset+row*4, SEEK_SET);
fseek (ifp, data_offset+get4(), SEEK_SET);
ph1_bits(-1);
FORC4 len[c] = row < 2 ? 7:4;
for (col=0; col < raw_width; col+=16) {
dir = ph1_bits(1);
FORC4 op[c] = ph1_bits(2);
FORC4 switch (op[c]) {
case 3: len[c] = ph1_bits(4); break;
case 2: len[c]--; break;
case 1: len[c]++;
}
for (c=0; c < 16; c+=2) {
i = len[((c & 1) << 1) | (c >> 3)];
RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) +
(dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128);
if (c == 14) c = -1;
}
}
}
for (row=0; row < raw_height-1; row+=2)
for (col=0; col < raw_width-1; col+=2)
SWAP (RAW(row,col+1), RAW(row+1,col));
}
| 1 |
[
"CWE-125",
"CWE-787"
] |
LibRaw
|
fd6330292501983ac75fe4162275794b18445bd9
| 317,099,516,662,178,270,000,000,000,000,000,000,000 | 33 |
Secunia 81800#1: samsumg_load_raw
Secunia 81800#2: find_green
Secunia 81800#3: rollei_load_raw
remove_trailing_spaces: isspace() does not works right with signed non-latin chars
Secunia 81800#5/6: nikon_coolscan_load_raw
Secunia 81800#4: rollei_load_raw
|
prefix_cmd(int midi_dev, unsigned char status)
{
if ((char *) midi_devs[midi_dev]->prefix_cmd == NULL)
return 1;
return midi_devs[midi_dev]->prefix_cmd(midi_dev, status);
}
| 0 |
[
"CWE-703",
"CWE-189"
] |
linux
|
b769f49463711205d57286e64cf535ed4daf59e9
| 256,281,315,757,449,640,000,000,000,000,000,000,000 | 7 |
sound/oss: remove offset from load_patch callbacks
Was: [PATCH] sound/oss/midi_synth: prevent underflow, use of
uninitialized value, and signedness issue
The offset passed to midi_synth_load_patch() can be essentially
arbitrary. If it's greater than the header length, this will result in
a copy_from_user(dst, src, negative_val). While this will just return
-EFAULT on x86, on other architectures this may cause memory corruption.
Additionally, the length field of the sysex_info structure may not be
initialized prior to its use. Finally, a signed comparison may result
in an unintentionally large loop.
On suggestion by Takashi Iwai, version two removes the offset argument
from the load_patch callbacks entirely, which also resolves similar
issues in opl3. Compile tested only.
v3 adjusts comments and hopefully gets copy offsets right.
Signed-off-by: Dan Rosenberg <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
|
static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len)
{
struct xdr_buf *buf = xdr->buf;
unsigned int nwords = XDR_QUADLEN(len);
unsigned int copied;
if (xdr->nwords == 0)
return 0;
xdr_realign_pages(xdr);
if (nwords > xdr->nwords) {
nwords = xdr->nwords;
len = nwords << 2;
}
if (buf->page_len <= len)
len = buf->page_len;
else if (nwords < xdr->nwords) {
/* Truncate page data and move it into the tail */
copied = xdr_shrink_pagelen(buf, len);
trace_rpc_xdr_alignment(xdr, len, copied);
}
return len;
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
linux
|
6d1c0f3d28f98ea2736128ed3e46821496dc3a8c
| 294,959,836,612,056,900,000,000,000,000,000,000,000 | 23 |
sunrpc: Avoid a KASAN slab-out-of-bounds bug in xdr_set_page_base()
This seems to happen fairly easily during READ_PLUS testing on NFS v4.2.
I found that we could end up accessing xdr->buf->pages[pgnr] with a pgnr
greater than the number of pages in the array. So let's just return
early if we're setting base to a point at the end of the page data and
let xdr_set_tail_base() handle setting up the buffer pointers instead.
Signed-off-by: Anna Schumaker <[email protected]>
Fixes: 8d86e373b0ef ("SUNRPC: Clean up helpers xdr_set_iov() and xdr_set_page_base()")
Signed-off-by: Trond Myklebust <[email protected]>
|
QByteArray Database::blob(const QByteArray &hash) {
QSqlQuery query;
query.prepare(QLatin1String("SELECT `data` FROM `blobs` WHERE `hash` = ?"));
query.addBindValue(hash);
query.exec();
if (query.next()) {
QByteArray qba = query.value(0).toByteArray();
query.prepare(QLatin1String("UPDATE `blobs` SET `seen` = datetime('now') WHERE `hash` = ?"));
query.addBindValue(hash);
query.exec();
return qba;
}
return QByteArray();
}
| 0 |
[
"CWE-310"
] |
mumble
|
5632c35d6759f5e13a7dfe78e4ee6403ff6a8e3e
| 114,576,711,945,376,200,000,000,000,000,000,000,000 | 17 |
Explicitly remove file permissions for settings and DB
|
cmsBool CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu,
cmsUInt32Number idx,
char LanguageCode[3],
char CountryCode[3])
{
_cmsMLUentry *entry;
if (mlu == NULL) return FALSE;
if (idx >= (cmsUInt32Number) mlu->UsedEntries) return FALSE;
entry = &mlu->Entries[idx];
*(cmsUInt16Number *)LanguageCode = _cmsAdjustEndianess16(entry->Language);
*(cmsUInt16Number *)CountryCode = _cmsAdjustEndianess16(entry->Country);
return TRUE;
}
| 0 |
[
"CWE-703"
] |
Little-CMS
|
91c2db7f2559be504211b283bc3a2c631d6f06d9
| 269,613,767,904,983,500,000,000,000,000,000,000,000 | 18 |
Non happy-path fixes
|
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
{
const struct ether_header *ep;
u_int orig_length;
u_short length_type;
u_int hdrlen;
int llc_hdrlen;
struct lladdr_info src, dst;
if (caplen < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
return (caplen);
}
if (length < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
return (length);
}
if (ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, p, length);
}
orig_length = length;
length -= ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
ep = (const struct ether_header *)p;
p += ETHER_HDRLEN;
hdrlen = ETHER_HDRLEN;
src.addr = ESRC(ep);
src.addr_string = etheraddr_string;
dst.addr = EDST(ep);
dst.addr_string = etheraddr_string;
length_type = EXTRACT_16BITS(&ep->ether_length_type);
recurse:
/*
* Is it (gag) an 802.3 encapsulation?
*/
if (length_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
if (llc_hdrlen < 0) {
/* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
llc_hdrlen = -llc_hdrlen;
}
hdrlen += llc_hdrlen;
} else if (length_type == ETHERTYPE_8021Q ||
length_type == ETHERTYPE_8021Q9100 ||
length_type == ETHERTYPE_8021Q9200 ||
length_type == ETHERTYPE_8021QinQ) {
/*
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
if (caplen < 4) {
ND_PRINT((ndo, "[|vlan]"));
return (hdrlen + caplen);
}
if (length < 4) {
ND_PRINT((ndo, "[|vlan]"));
return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
}
length_type = EXTRACT_16BITS(p + 2);
if (ndo->ndo_eflag && length_type > ETHERMTU)
ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", length_type)));
p += 4;
length -= 4;
caplen -= 4;
hdrlen += 4;
goto recurse;
} else if (length_type == ETHERTYPE_JUMBO) {
/*
* Alteon jumbo frames.
* See
*
* http://tools.ietf.org/html/draft-ietf-isis-ext-eth-01
*
* which indicates that, following the type field,
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
if (llc_hdrlen < 0) {
/* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
llc_hdrlen = -llc_hdrlen;
}
hdrlen += llc_hdrlen;
} else {
if (ethertype_print(ndo, length_type, p, length, caplen, &src, &dst) == 0) {
/* type not known, print raw packet */
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
ether_hdr_print(ndo, (const u_char *)ep, orig_length);
}
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
}
return (hdrlen);
}
| 0 |
[
"CWE-125",
"CWE-787"
] |
tcpdump
|
1dcd10aceabbc03bf571ea32b892c522cbe923de
| 222,945,533,581,212,800,000,000,000,000,000,000,000 | 117 |
CVE-2017-12897/ISO CLNS: Use ND_TTEST() for the bounds checks in isoclns_print().
This fixes a buffer over-read discovered by Kamil Frankowicz.
Don't pass the remaining caplen - that's too hard to get right, and we
were getting it wrong in at least one case; just use ND_TTEST().
Add a test using the capture file supplied by the reporter(s).
|
static char *plist_utf16_to_utf8(uint16_t *unistr, long len, long *items_read, long *items_written)
{
if (!unistr || (len <= 0)) return NULL;
char *outbuf = (char*)malloc(4*(len+1));
int p = 0;
int i = 0;
uint16_t wc;
uint32_t w;
int read_lead_surrogate = 0;
while (i < len) {
wc = unistr[i++];
if (wc >= 0xD800 && wc <= 0xDBFF) {
if (!read_lead_surrogate) {
read_lead_surrogate = 1;
w = 0x010000 + ((wc & 0x3FF) << 10);
} else {
// This is invalid, the next 16 bit char should be a trail surrogate.
// Handling error by skipping.
read_lead_surrogate = 0;
}
} else if (wc >= 0xDC00 && wc <= 0xDFFF) {
if (read_lead_surrogate) {
read_lead_surrogate = 0;
w = w | (wc & 0x3FF);
outbuf[p++] = (char)(0xF0 + ((w >> 18) & 0x7));
outbuf[p++] = (char)(0x80 + ((w >> 12) & 0x3F));
outbuf[p++] = (char)(0x80 + ((w >> 6) & 0x3F));
outbuf[p++] = (char)(0x80 + (w & 0x3F));
} else {
// This is invalid. A trail surrogate should always follow a lead surrogate.
// Handling error by skipping
}
} else if (wc >= 0x800) {
outbuf[p++] = (char)(0xE0 + ((wc >> 12) & 0xF));
outbuf[p++] = (char)(0x80 + ((wc >> 6) & 0x3F));
outbuf[p++] = (char)(0x80 + (wc & 0x3F));
} else if (wc >= 0x80) {
outbuf[p++] = (char)(0xC0 + ((wc >> 6) & 0x1F));
outbuf[p++] = (char)(0x80 + (wc & 0x3F));
} else {
outbuf[p++] = (char)(wc & 0x7F);
}
}
if (items_read) {
*items_read = i;
}
if (items_written) {
*items_written = p;
}
outbuf[p] = 0;
return outbuf;
}
| 0 |
[
"CWE-125"
] |
libplist
|
4765d9a60ca4248a8f89289271ac69cbffcc29bc
| 69,681,277,101,011,400,000,000,000,000,000,000,000 | 55 |
bplist: Fix possible out-of-bounds read in parse_array_node() with proper bounds checking
|
plperl_sv_to_literal(SV *sv, char *fqtypename)
{
Datum str = CStringGetDatum(fqtypename);
Oid typid = DirectFunctionCall1(regtypein, str);
Oid typoutput;
Datum datum;
bool typisvarlena,
isnull;
if (!OidIsValid(typid))
elog(ERROR, "lookup failed for type %s", fqtypename);
datum = plperl_sv_to_datum(sv,
typid, -1,
NULL, NULL, InvalidOid,
&isnull);
if (isnull)
return NULL;
getTypeOutputInfo(typid,
&typoutput, &typisvarlena);
return OidOutputFunctionCall(typoutput, datum);
}
| 0 |
[
"CWE-264"
] |
postgres
|
537cbd35c893e67a63c59bc636c3e888bd228bc7
| 278,828,729,304,680,480,000,000,000,000,000,000,000 | 25 |
Prevent privilege escalation in explicit calls to PL validators.
The primary role of PL validators is to be called implicitly during
CREATE FUNCTION, but they are also normal functions that a user can call
explicitly. Add a permissions check to each validator to ensure that a
user cannot use explicit validator calls to achieve things he could not
otherwise achieve. Back-patch to 8.4 (all supported versions).
Non-core procedural language extensions ought to make the same two-line
change to their own validators.
Andres Freund, reviewed by Tom Lane and Noah Misch.
Security: CVE-2014-0061
|
R_API int r_bin_object_delete(RBin *bin, ut32 binfile_id, ut32 binobj_id) {
RBinFile *binfile = NULL; //, *cbinfile = r_bin_cur (bin);
RBinObject *obj = NULL;
int res = false;
#if 0
if (binfile_id == UT32_MAX && binobj_id == UT32_MAX) {
return false;
}
#endif
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;
}
// lazy way out, always leaving at least 1 bin object loaded
if (binfile && (r_list_length (binfile->objs) > 1)) {
binfile->o = NULL;
r_list_delete_data (binfile->objs, obj);
obj = (RBinObject *)r_list_get_n (binfile->objs, 0);
res = obj && binfile &&
r_bin_file_set_cur_binfile_obj (bin, binfile, obj);
}
return res;
}
| 0 |
[
"CWE-125"
] |
radare2
|
d31c4d3cbdbe01ea3ded16a584de94149ecd31d9
| 44,965,966,041,993,670,000,000,000,000,000,000,000 | 31 |
Fix #8748 - Fix oobread on string search
|
static void rtrs_clt_reconnect_work(struct work_struct *work)
{
struct rtrs_clt_path *clt_path;
struct rtrs_clt_sess *clt;
unsigned int delay_ms;
int err;
clt_path = container_of(to_delayed_work(work), struct rtrs_clt_path,
reconnect_dwork);
clt = clt_path->clt;
if (READ_ONCE(clt_path->state) != RTRS_CLT_RECONNECTING)
return;
if (clt_path->reconnect_attempts >= clt->max_reconnect_attempts) {
/* Close a path completely if max attempts is reached */
rtrs_clt_close_conns(clt_path, false);
return;
}
clt_path->reconnect_attempts++;
/* Stop everything */
rtrs_clt_stop_and_destroy_conns(clt_path);
msleep(RTRS_RECONNECT_BACKOFF);
if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING, NULL)) {
err = init_path(clt_path);
if (err)
goto reconnect_again;
}
return;
reconnect_again:
if (rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_RECONNECTING, NULL)) {
clt_path->stats->reconnects.fail_cnt++;
delay_ms = clt->reconnect_delay_sec * 1000;
queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork,
msecs_to_jiffies(delay_ms +
prandom_u32() %
RTRS_RECONNECT_SEED));
}
}
| 0 |
[
"CWE-415"
] |
linux
|
8700af2cc18c919b2a83e74e0479038fd113c15d
| 261,612,753,623,271,700,000,000,000,000,000,000,000 | 42 |
RDMA/rtrs-clt: Fix possible double free in error case
Callback function rtrs_clt_dev_release() for put_device() calls kfree(clt)
to free memory. We shouldn't call kfree(clt) again, and we can't use the
clt after kfree too.
Replace device_register() with device_initialize() and device_add() so that
dev_set_name can() be used appropriately.
Move mutex_destroy() to the release function so it can be called in
the alloc_clt err path.
Fixes: eab098246625 ("RDMA/rtrs-clt: Refactor the failure cases in alloc_clt")
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Miaoqian Lin <[email protected]>
Signed-off-by: Md Haris Iqbal <[email protected]>
Reviewed-by: Jack Wang <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
|
backend_can_multi_conn (struct backend *b, struct connection *conn)
{
struct b_conn_handle *h = &conn->handles[b->i];
debug ("%s: can_multi_conn", b->name);
if (h->can_multi_conn == -1)
h->can_multi_conn = b->can_multi_conn (b, conn);
return h->can_multi_conn;
}
| 0 |
[
"CWE-406"
] |
nbdkit
|
a6b88b195a959b17524d1c8353fd425d4891dc5f
| 134,558,175,372,573,170,000,000,000,000,000,000,000 | 10 |
server: Fix regression for NBD_OPT_INFO before NBD_OPT_GO
Most known NBD clients do not bother with NBD_OPT_INFO (except for
clients like 'qemu-nbd --list' that don't ever intend to connect), but
go straight to NBD_OPT_GO. However, it's not too hard to hack up qemu
to add in an extra client step (whether info on the same name, or more
interestingly, info on a different name), as a patch against qemu
commit 6f214b30445:
| diff --git i/nbd/client.c w/nbd/client.c
| index f6733962b49b..425292ac5ea9 100644
| --- i/nbd/client.c
| +++ w/nbd/client.c
| @@ -1038,6 +1038,14 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc,
| * TLS). If it is not available, fall back to
| * NBD_OPT_LIST for nicer error messages about a missing
| * export, then use NBD_OPT_EXPORT_NAME. */
| + if (getenv ("HACK"))
| + info->name[0]++;
| + result = nbd_opt_info_or_go(ioc, NBD_OPT_INFO, info, errp);
| + if (getenv ("HACK"))
| + info->name[0]--;
| + if (result < 0) {
| + return -EINVAL;
| + }
| result = nbd_opt_info_or_go(ioc, NBD_OPT_GO, info, errp);
| if (result < 0) {
| return -EINVAL;
This works just fine in 1.14.0, where we call .open only once (so the
INFO and GO repeat calls into the same plugin handle), but in 1.14.1
it regressed into causing an assertion failure: we are now calling
.open a second time on a connection that is already opened:
$ nbdkit -rfv null &
$ hacked-qemu-io -f raw -r nbd://localhost -c quit
...
nbdkit: null[1]: debug: null: open readonly=1
nbdkit: backend.c:179: backend_open: Assertion `h->handle == NULL' failed.
Worse, on the mainline development, we have recently made it possible
for plugins to actively report different information for different
export names; for example, a plugin may choose to report different
answers for .can_write on export A than for export B; but if we share
cached handles, then an NBD_OPT_INFO on one export prevents correct
answers for NBD_OPT_GO on the second export name. (The HACK envvar in
my qemu modifications can be used to demonstrate cross-name requests,
which are even less likely in a real client).
The solution is to call .close after NBD_OPT_INFO, coupled with enough
glue logic to reset cached connection handles back to the state
expected by .open. This in turn means factoring out another backend_*
function, but also gives us an opportunity to change
backend_set_handle to no longer accept NULL.
The assertion failure is, to some extent, a possible denial of service
attack (one client can force nbdkit to exit by merely sending OPT_INFO
before OPT_GO, preventing the next client from connecting), although
this is mitigated by using TLS to weed out untrusted clients. Still,
the fact that we introduced a potential DoS attack while trying to fix
a traffic amplification security bug is not very nice.
Sadly, as there are no known clients that easily trigger this mode of
operation (OPT_INFO before OPT_GO), there is no easy way to cover this
via a testsuite addition. I may end up hacking something into libnbd.
Fixes: c05686f957
Signed-off-by: Eric Blake <[email protected]>
|
static int mongo_check_is_master( mongo *conn ) {
bson out;
bson_iterator it;
bson_bool_t ismaster = 0;
int max_bson_size = MONGO_DEFAULT_MAX_BSON_SIZE;
out.data = NULL;
if ( mongo_simple_int_command( conn, "admin", "ismaster", 1, &out ) == MONGO_OK ) {
if( bson_find( &it, &out, "ismaster" ) )
ismaster = bson_iterator_bool( &it );
if( bson_find( &it, &out, "maxBsonObjectSize" ) ) {
max_bson_size = bson_iterator_int( &it );
}
conn->max_bson_size = max_bson_size;
}
else {
return MONGO_ERROR;
}
bson_destroy( &out );
if( ismaster )
return MONGO_OK;
else {
conn->err = MONGO_CONN_NOT_MASTER;
return MONGO_ERROR;
}
}
| 0 |
[
"CWE-190"
] |
mongo-c-driver-legacy
|
1a1f5e26a4309480d88598913f9eebf9e9cba8ca
| 28,250,810,300,449,054,000,000,000,000,000,000,000 | 29 |
don't mix up int and size_t (first pass to fix that)
|
void Virtual_tmp_table::setup_field_pointers()
{
uchar *null_pos= record[0];
uchar *field_pos= null_pos + s->null_bytes;
uint null_bit= 1;
for (Field **cur_ptr= field; *cur_ptr; ++cur_ptr)
{
Field *cur_field= *cur_ptr;
if ((cur_field->flags & NOT_NULL_FLAG))
cur_field->move_field(field_pos);
else
{
cur_field->move_field(field_pos, (uchar*) null_pos, null_bit);
null_bit<<= 1;
if (null_bit == (uint)1 << 8)
{
++null_pos;
null_bit= 1;
}
}
if (cur_field->type() == MYSQL_TYPE_BIT &&
cur_field->key_type() == HA_KEYTYPE_BIT)
{
/* This is a Field_bit since key_type is HA_KEYTYPE_BIT */
static_cast<Field_bit*>(cur_field)->set_bit_ptr(null_pos, null_bit);
null_bit+= cur_field->field_length & 7;
if (null_bit > 7)
{
null_pos++;
null_bit-= 8;
}
}
cur_field->reset();
field_pos+= cur_field->pack_length();
}
}
| 0 |
[] |
server
|
ff77a09bda884fe6bf3917eb29b9d3a2f53f919b
| 80,918,430,059,169,140,000,000,000,000,000,000,000 | 37 |
MDEV-22464 Server crash on UPDATE with nested subquery
Uninitialized ref_pointer_array[] because setup_fields() got empty
fields list. mysql_multi_update() for some reason does that by
substituting the fields list with empty total_list for the
mysql_select() call (looks like wrong merge since total_list is not
used anywhere else and is always empty). The fix would be to return
back the original fields list. But this fails update_use_source.test
case:
--error ER_BAD_FIELD_ERROR
update v1 set t1c1=2 order by 1;
Actually not failing the above seems to be ok.
The other fix would be to keep resolve_in_select_list false (and that
keeps outer context from being resolved in
Item_ref::fix_fields()). This fix is more consistent with how SELECT
behaves:
--error ER_SUBQUERY_NO_1_ROW
select a from t1 where a= (select 2 from t1 having (a = 3));
So this patch implements this fix.
|
static int udf_readpage(struct file *file, struct page *page)
{
return mpage_readpage(page, udf_get_block);
}
| 0 |
[
"CWE-476"
] |
linux
|
7fc3b7c2981bbd1047916ade327beccb90994eee
| 287,506,999,260,303,230,000,000,000,000,000,000,000 | 4 |
udf: Fix NULL ptr deref when converting from inline format
udf_expand_file_adinicb() calls directly ->writepage to write data
expanded into a page. This however misses to setup inode for writeback
properly and so we can crash on inode->i_wb dereference when submitting
page for IO like:
BUG: kernel NULL pointer dereference, address: 0000000000000158
#PF: supervisor read access in kernel mode
...
<TASK>
__folio_start_writeback+0x2ac/0x350
__block_write_full_page+0x37d/0x490
udf_expand_file_adinicb+0x255/0x400 [udf]
udf_file_write_iter+0xbe/0x1b0 [udf]
new_sync_write+0x125/0x1c0
vfs_write+0x28e/0x400
Fix the problem by marking the page dirty and going through the standard
writeback path to write the page. Strictly speaking we would not even
have to write the page but we want to catch e.g. ENOSPC errors early.
Reported-by: butt3rflyh4ck <[email protected]>
CC: [email protected]
Fixes: 52ebea749aae ("writeback: make backing_dev_info host cgroup-specific bdi_writebacks")
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
|
void qemu_set_vnet_hdr_len(NetClientState *nc, int len)
{
if (!nc || !nc->info->set_vnet_hdr_len) {
return;
}
nc->vnet_hdr_len = len;
nc->info->set_vnet_hdr_len(nc, len);
}
| 0 |
[
"CWE-190"
] |
qemu
|
25c01bd19d0e4b66f357618aeefda1ef7a41e21a
| 205,531,127,938,865,960,000,000,000,000,000,000,000 | 9 |
net: drop too large packet early
We try to detect and drop too large packet (>INT_MAX) in 1592a9947036
("net: ignore packet size greater than INT_MAX") during packet
delivering. Unfortunately, this is not sufficient as we may hit
another integer overflow when trying to queue such large packet in
qemu_net_queue_append_iov():
- size of the allocation may overflow on 32bit
- packet->size is integer which may overflow even on 64bit
Fixing this by moving the check to qemu_sendv_packet_async() which is
the entrance of all networking codes and reduce the limit to
NET_BUFSIZE to be more conservative. This works since:
- For the callers that call qemu_sendv_packet_async() directly, they
only care about if zero is returned to determine whether to prevent
the source from producing more packets. A callback will be triggered
if peer can accept more then source could be enabled. This is
usually used by high speed networking implementation like virtio-net
or netmap.
- For the callers that call qemu_sendv_packet() that calls
qemu_sendv_packet_async() indirectly, they often ignore the return
value. In this case qemu will just the drop packets if peer can't
receive.
Qemu will copy the packet if it was queued. So it was safe for both
kinds of the callers to assume the packet was sent.
Since we move the check from qemu_deliver_packet_iov() to
qemu_sendv_packet_async(), it would be safer to make
qemu_deliver_packet_iov() static to prevent any external user in the
future.
This is a revised patch of CVE-2018-17963.
Cc: [email protected]
Cc: Li Qiang <[email protected]>
Fixes: 1592a9947036 ("net: ignore packet size greater than INT_MAX")
Reported-by: Li Qiang <[email protected]>
Reviewed-by: Li Qiang <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
|
static inline void vring_avail_event(VirtQueue *vq, uint16_t val)
{
hwaddr pa;
if (!vq->notification) {
return;
}
pa = vq->vring.used + offsetof(VRingUsed, ring[vq->vring.num]);
stw_phys(pa, val);
}
| 0 |
[
"CWE-269"
] |
qemu
|
5f5a1318653c08e435cfa52f60b6a712815b659d
| 106,331,792,896,337,080,000,000,000,000,000,000,000 | 9 |
virtio: properly validate address before accessing config
There are several several issues in the current checking:
- The check was based on the minus of unsigned values which can overflow
- It was done after .{set|get}_config() which can lead crash when config_len
is zero since vdev->config is NULL
Fix this by:
- Validate the address in virtio_pci_config_{read|write}() before
.{set|get}_config
- Use addition instead minus to do the validation
Cc: Michael S. Tsirkin <[email protected]>
Cc: Petr Matousek <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Acked-by: Petr Matousek <[email protected]>
Message-id: [email protected]
Signed-off-by: Anthony Liguori <[email protected]>
|
static int _epoll_ctl_del(epoll_t* epoll, int fd)
{
int ret = -1;
oe_fd_t* desc;
oe_host_fd_t host_epfd;
oe_host_fd_t host_fd;
int retval;
bool locked = false;
oe_errno = 0;
/* Check parameters. */
if (!epoll)
OE_RAISE_ERRNO(OE_EINVAL);
if (!(desc = oe_fdtable_get(fd, OE_FD_TYPE_ANY)))
OE_RAISE_ERRNO(oe_errno);
/* Get the host fd for the epoll device. */
host_epfd = epoll->host_fd;
/* Get the host fd for the device. */
if ((host_fd = desc->ops.fd.get_host_fd(desc)) == -1)
OE_RAISE_ERRNO(oe_errno);
// The host call and the map update must be done in an atomic operation.
locked = true;
oe_mutex_lock(&epoll->lock);
if (oe_syscall_epoll_ctl_ocall(
&retval, host_epfd, OE_EPOLL_CTL_DEL, host_fd, NULL) != OE_OK)
{
OE_RAISE_ERRNO(OE_EINVAL);
}
/* Delete the mapping. */
if (retval == 0)
{
bool found = false;
for (size_t i = 0; i < epoll->map_size; i++)
{
if (epoll->map[i].fd == fd)
{
/* Swap with last element of array. */
epoll->map[i] = epoll->map[--epoll->map_size];
found = true;
break;
}
}
if (!found)
OE_RAISE_ERRNO(OE_ENOENT);
}
ret = 0;
done:
if (locked)
oe_mutex_unlock(&epoll->lock);
return ret;
}
| 0 |
[
"CWE-200",
"CWE-552"
] |
openenclave
|
bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b
| 176,984,977,982,355,420,000,000,000,000,000,000,000 | 63 |
Merge pull request from GHSA-525h-wxcc-f66m
Signed-off-by: Ming-Wei Shih <[email protected]>
|
static void dumpcclass(Reclass *cc) {
Rune *p;
for (p = cc->spans; p < cc->end; p += 2) {
if (p[0] > 32 && p[0] < 127)
printf(" %c", p[0]);
else
printf(" \\x%02x", p[0]);
if (p[1] > 32 && p[1] < 127)
printf("-%c", p[1]);
else
printf("-\\x%02x", p[1]);
}
putchar('\n');
}
| 0 |
[
"CWE-703",
"CWE-674"
] |
mujs
|
160ae29578054dc09fd91e5401ef040d52797e61
| 326,052,680,635,164,820,000,000,000,000,000,000,000 | 14 |
Issue #162: Check stack overflow during regexp compilation.
Only bother checking during the first compilation pass that counts
the size of the program.
|
TEST_F(Http1ServerConnectionImplTest, RequestWithTrailersKept) { expectTrailersTest(true); }
| 0 |
[
"CWE-770"
] |
envoy
|
7ca28ff7d46454ae930e193d97b7d08156b1ba59
| 113,011,605,420,268,280,000,000,000,000,000,000,000 | 1 |
[http1] Include request URL in request header size computation, and reject partial headers that exceed configured limits (#145)
Signed-off-by: antonio <[email protected]>
|
parse_group_prop_ntr_selection_method(struct ofpbuf *payload,
enum ofp11_group_type group_type,
enum ofp15_group_mod_command group_cmd,
struct ofputil_group_props *gp)
{
struct ntr_group_prop_selection_method *prop = payload->data;
size_t fields_len, method_len;
enum ofperr error;
switch (group_type) {
case OFPGT11_SELECT:
break;
case OFPGT11_ALL:
case OFPGT11_INDIRECT:
case OFPGT11_FF:
OFPPROP_LOG(&bad_ofmsg_rl, false, "ntr selection method property is "
"only allowed for select groups");
return OFPERR_OFPBPC_BAD_VALUE;
default:
return OFPERR_OFPGMFC_BAD_TYPE;
}
switch (group_cmd) {
case OFPGC15_ADD:
case OFPGC15_MODIFY:
case OFPGC15_ADD_OR_MOD:
break;
case OFPGC15_DELETE:
case OFPGC15_INSERT_BUCKET:
case OFPGC15_REMOVE_BUCKET:
OFPPROP_LOG(&bad_ofmsg_rl, false, "ntr selection method property is "
"only allowed for add and delete group modifications");
return OFPERR_OFPBPC_BAD_VALUE;
default:
return OFPERR_OFPGMFC_BAD_COMMAND;
}
if (payload->size < sizeof *prop) {
OFPPROP_LOG(&bad_ofmsg_rl, false, "ntr selection method property "
"length %u is not valid", payload->size);
return OFPERR_OFPBPC_BAD_LEN;
}
method_len = strnlen(prop->selection_method, NTR_MAX_SELECTION_METHOD_LEN);
if (method_len == NTR_MAX_SELECTION_METHOD_LEN) {
OFPPROP_LOG(&bad_ofmsg_rl, false,
"ntr selection method is not null terminated");
return OFPERR_OFPBPC_BAD_VALUE;
}
if (strcmp("hash", prop->selection_method)
&& strcmp("dp_hash", prop->selection_method)) {
OFPPROP_LOG(&bad_ofmsg_rl, false,
"ntr selection method '%s' is not supported",
prop->selection_method);
return OFPERR_OFPBPC_BAD_VALUE;
}
/* 'method_len' is now non-zero. */
strcpy(gp->selection_method, prop->selection_method);
gp->selection_method_param = ntohll(prop->selection_method_param);
ofpbuf_pull(payload, sizeof *prop);
fields_len = ntohs(prop->length) - sizeof *prop;
if (fields_len && strcmp("hash", gp->selection_method)) {
OFPPROP_LOG(&bad_ofmsg_rl, false, "ntr selection method %s "
"does not support fields", gp->selection_method);
return OFPERR_OFPBPC_BAD_VALUE;
}
error = oxm_pull_field_array(payload->data, fields_len,
&gp->fields);
if (error) {
OFPPROP_LOG(&bad_ofmsg_rl, false,
"ntr selection method fields are invalid");
return error;
}
return 0;
}
| 0 |
[
"CWE-617",
"CWE-703"
] |
ovs
|
4af6da3b275b764b1afe194df6499b33d2bf4cde
| 54,349,972,075,462,000,000,000,000,000,000,000,000 | 82 |
ofp-group: Don't assert-fail decoding bad OF1.5 group mod type or command.
When decoding a group mod, the current code validates the group type and
command after the whole group mod has been decoded. The OF1.5 decoder,
however, tries to use the type and command earlier, when it might still be
invalid. This caused an assertion failure (via OVS_NOT_REACHED). This
commit fixes the problem.
ovs-vswitchd does not enable support for OpenFlow 1.5 by default.
Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9249
Signed-off-by: Ben Pfaff <[email protected]>
Reviewed-by: Yifeng Sun <[email protected]>
|
void lsrc_box_del(GF_Box *s)
{
GF_LASERConfigurationBox *ptr = (GF_LASERConfigurationBox *)s;
if (ptr == NULL) return;
if (ptr->hdr) gf_free(ptr->hdr);
gf_free(ptr);
}
| 0 |
[
"CWE-787"
] |
gpac
|
77510778516803b7f7402d7423c6d6bef50254c3
| 159,447,302,275,527,570,000,000,000,000,000,000,000 | 7 |
fixed #2255
|
static bool test_writeclose(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_write io;
NTSTATUS status;
bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
const char *fname = BASEDIR "\\test.txt";
unsigned int seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setting_bool(tctx, "writeclose_support", true)) {
torture_skip(tctx, "Server does not support writeclose - skipping\n");
}
if (!torture_setup_dir(cli, BASEDIR)) {
torture_fail(tctx, "failed to setup basedir");
}
torture_comment(tctx, "Testing RAW_WRITE_WRITECLOSE\n");
io.generic.level = RAW_WRITE_WRITECLOSE;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
}
torture_comment(tctx, "Trying zero write\n");
io.writeclose.in.file.fnum = fnum;
io.writeclose.in.count = 0;
io.writeclose.in.offset = 0;
io.writeclose.in.mtime = 0;
io.writeclose.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
setup_buffer(buf, seed, maxsize);
torture_comment(tctx, "Trying small write\n");
io.writeclose.in.count = 9;
io.writeclose.in.offset = 4;
io.writeclose.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.file.fnum = fnum;
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf+4, seed, 9);
CHECK_VALUE(IVAL(buf,0), 0);
setup_buffer(buf, seed, maxsize);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.file.fnum = fnum;
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf+4, seed, 9);
CHECK_VALUE(IVAL(buf,0), 0);
setup_buffer(buf, seed, maxsize);
torture_comment(tctx, "Trying large write\n");
io.writeclose.in.count = 4000;
io.writeclose.in.offset = 0;
io.writeclose.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, 4000);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.file.fnum = fnum;
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf, seed, 4000);
torture_comment(tctx, "Trying bad fnum\n");
io.writeclose.in.file.fnum = fnum+1;
io.writeclose.in.count = 4000;
io.writeclose.in.offset = 0;
io.writeclose.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
torture_comment(tctx, "Setting file as sparse\n");
status = torture_set_sparse(cli->tree, fnum);
CHECK_STATUS(status, NT_STATUS_OK);
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
torture_skip(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
}
torture_comment(tctx, "Trying 2^32 offset\n");
setup_buffer(buf, seed, maxsize);
io.writeclose.in.file.fnum = fnum;
io.writeclose.in.count = 4000;
io.writeclose.in.offset = 0xFFFFFFFF - 2000;
io.writeclose.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, 4000);
CHECK_ALL_INFO(io.writeclose.in.count + (uint64_t)io.writeclose.in.offset, size);
fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.file.fnum = fnum;
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf, seed, 4000);
done:
smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
| 0 |
[
"CWE-200"
] |
samba
|
a60863458dc6b60a09aa8d31fada6c36f5043c76
| 129,120,163,355,464,580,000,000,000,000,000,000,000 | 150 |
CVE-2022-32742: s4: torture: Add raw.write.bad-write test.
Reproduces the test code in:
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15085
Add knownfail.
Signed-off-by: Jeremy Allison <[email protected]>
Reviewed-by: David Disseldorp <[email protected]>
|
static int local_renameat(FsContext *ctx, V9fsPath *olddir,
const char *old_name, V9fsPath *newdir,
const char *new_name)
{
int ret;
int odirfd, ndirfd;
odirfd = local_opendir_nofollow(ctx, olddir->data);
if (odirfd == -1) {
return -1;
}
ndirfd = local_opendir_nofollow(ctx, newdir->data);
if (ndirfd == -1) {
close_preserve_errno(odirfd);
return -1;
}
ret = renameat(odirfd, old_name, ndirfd, new_name);
if (ret < 0) {
goto out;
}
if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
int omap_dirfd, nmap_dirfd;
ret = mkdirat(ndirfd, VIRTFS_META_DIR, 0700);
if (ret < 0 && errno != EEXIST) {
goto err_undo_rename;
}
omap_dirfd = openat_dir(odirfd, VIRTFS_META_DIR);
if (omap_dirfd == -1) {
goto err;
}
nmap_dirfd = openat_dir(ndirfd, VIRTFS_META_DIR);
if (nmap_dirfd == -1) {
close_preserve_errno(omap_dirfd);
goto err;
}
/* rename the .virtfs_metadata files */
ret = renameat(omap_dirfd, old_name, nmap_dirfd, new_name);
close_preserve_errno(nmap_dirfd);
close_preserve_errno(omap_dirfd);
if (ret < 0 && errno != ENOENT) {
goto err_undo_rename;
}
ret = 0;
}
goto out;
err:
ret = -1;
err_undo_rename:
renameat_preserve_errno(ndirfd, new_name, odirfd, old_name);
out:
close_preserve_errno(ndirfd);
close_preserve_errno(odirfd);
return ret;
}
| 1 |
[
"CWE-732"
] |
qemu
|
7a95434e0ca8a037fd8aa1a2e2461f92585eb77b
| 27,729,923,074,625,057,000,000,000,000,000,000,000 | 63 |
9pfs: local: forbid client access to metadata (CVE-2017-7493)
When using the mapped-file security mode, we shouldn't let the client mess
with the metadata. The current code already tries to hide the metadata dir
from the client by skipping it in local_readdir(). But the client can still
access or modify it through several other operations. This can be used to
escalate privileges in the guest.
Affected backend operations are:
- local_mknod()
- local_mkdir()
- local_open2()
- local_symlink()
- local_link()
- local_unlinkat()
- local_renameat()
- local_rename()
- local_name_to_path()
Other operations are safe because they are only passed a fid path, which
is computed internally in local_name_to_path().
This patch converts all the functions listed above to fail and return
EINVAL when being passed the name of the metadata dir. This may look
like a poor choice for errno, but there's no such thing as an illegal
path name on Linux and I could not think of anything better.
This fixes CVE-2017-7493.
Reported-by: Leo Gaspard <[email protected]>
Signed-off-by: Greg Kurz <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
|
static inline int pte_young(pte_t pte)
{
return pte_flags(pte) & _PAGE_ACCESSED;
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
linux
|
027ef6c87853b0a9df53175063028edb4950d476
| 233,755,749,590,209,670,000,000,000,000,000,000,000 | 4 |
mm: thp: fix pmd_present for split_huge_page and PROT_NONE with THP
In many places !pmd_present has been converted to pmd_none. For pmds
that's equivalent and pmd_none is quicker so using pmd_none is better.
However (unless we delete pmd_present) we should provide an accurate
pmd_present too. This will avoid the risk of code thinking the pmd is non
present because it's under __split_huge_page_map, see the pmd_mknotpresent
there and the comment above it.
If the page has been mprotected as PROT_NONE, it would also lead to a
pmd_present false negative in the same way as the race with
split_huge_page.
Because the PSE bit stays on at all times (both during split_huge_page and
when the _PAGE_PROTNONE bit get set), we could only check for the PSE bit,
but checking the PROTNONE bit too is still good to remember pmd_present
must always keep PROT_NONE into account.
This explains a not reproducible BUG_ON that was seldom reported on the
lists.
The same issue is in pmd_large, it would go wrong with both PROT_NONE and
if it races with split_huge_page.
Signed-off-by: Andrea Arcangeli <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
ZEND_VM_HOT_HANDLER(117, ZEND_SEND_VAR, VAR|CV, NUM)
{
USE_OPLINE
zval *varptr, *arg;
zend_free_op free_op1;
varptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) {
SAVE_OPLINE();
ZVAL_UNDEFINED_OP1();
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
ZVAL_NULL(arg);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
arg = ZEND_CALL_VAR(EX(call), opline->result.var);
if (OP1_TYPE == IS_CV) {
ZVAL_COPY_DEREF(arg, varptr);
} else /* if (OP1_TYPE == IS_VAR) */ {
if (UNEXPECTED(Z_ISREF_P(varptr))) {
zend_refcounted *ref = Z_COUNTED_P(varptr);
varptr = Z_REFVAL_P(varptr);
ZVAL_COPY_VALUE(arg, varptr);
if (UNEXPECTED(GC_DELREF(ref) == 0)) {
efree_size(ref, sizeof(zend_reference));
} else if (Z_OPT_REFCOUNTED_P(arg)) {
Z_ADDREF_P(arg);
}
} else {
ZVAL_COPY_VALUE(arg, varptr);
}
}
ZEND_VM_NEXT_OPCODE();
}
| 0 |
[
"CWE-787"
] |
php-src
|
f1ce8d5f5839cb2069ea37ff424fb96b8cd6932d
| 186,804,940,904,756,320,000,000,000,000,000,000,000 | 37 |
Fix #73122: Integer Overflow when concatenating strings
We must avoid integer overflows in memory allocations, so we introduce
an additional check in the VM, and bail out in the rare case of an
overflow. Since the recent fix for bug #74960 still doesn't catch all
possible overflows, we fix that right away.
|
static void submit_flushes(struct work_struct *ws)
{
struct mddev *mddev = container_of(ws, struct mddev, flush_work);
struct md_rdev *rdev;
INIT_WORK(&mddev->flush_work, md_submit_flush_data);
atomic_set(&mddev->flush_pending, 1);
rcu_read_lock();
rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 &&
!test_bit(Faulty, &rdev->flags)) {
/* Take two references, one is dropped
* when request finishes, one after
* we reclaim rcu_read_lock
*/
struct bio *bi;
atomic_inc(&rdev->nr_pending);
atomic_inc(&rdev->nr_pending);
rcu_read_unlock();
bi = bio_alloc_mddev(GFP_NOIO, 0, mddev);
bi->bi_end_io = md_end_flush;
bi->bi_private = rdev;
bi->bi_bdev = rdev->bdev;
atomic_inc(&mddev->flush_pending);
submit_bio(WRITE_FLUSH, bi);
rcu_read_lock();
rdev_dec_pending(rdev, mddev);
}
rcu_read_unlock();
if (atomic_dec_and_test(&mddev->flush_pending))
queue_work(md_wq, &mddev->flush_work);
}
| 0 |
[
"CWE-200"
] |
linux
|
b6878d9e03043695dbf3fa1caa6dfc09db225b16
| 63,812,573,937,442,700,000,000,000,000,000,000,000 | 32 |
md: use kzalloc() when bitmap is disabled
In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
mdu_bitmap_file_t called "file".
5769 file = kmalloc(sizeof(*file), GFP_NOIO);
5770 if (!file)
5771 return -ENOMEM;
This structure is copied to user space at the end of the function.
5786 if (err == 0 &&
5787 copy_to_user(arg, file, sizeof(*file)))
5788 err = -EFAULT
But if bitmap is disabled only the first byte of "file" is initialized
with zero, so it's possible to read some bytes (up to 4095) of kernel
space memory from user space. This is an information leak.
5775 /* bitmap disabled, zero the first byte and copy out */
5776 if (!mddev->bitmap_info.file)
5777 file->pathname[0] = '\0';
Signed-off-by: Benjamin Randazzo <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
|
void ha_partition::start_part_bulk_insert(THD *thd, uint part_id)
{
long old_buffer_size;
if (!bitmap_is_set(&m_bulk_insert_started, part_id) &&
bitmap_is_set(&m_bulk_insert_started, m_tot_parts))
{
old_buffer_size= thd->variables.read_buff_size;
/* Update read_buffer_size for this partition */
thd->variables.read_buff_size= estimate_read_buffer_size(old_buffer_size);
m_file[part_id]->ha_start_bulk_insert(guess_bulk_insert_rows());
bitmap_set_bit(&m_bulk_insert_started, part_id);
thd->variables.read_buff_size= old_buffer_size;
}
m_bulk_inserted_rows++;
}
| 0 |
[] |
mysql-server
|
be901b60ae59c93848c829d1b0b2cb523ab8692e
| 15,907,698,649,399,522,000,000,000,000,000,000,000 | 15 |
Bug#26390632: CREATE TABLE CAN CAUSE MYSQL TO EXIT.
Analysis
========
CREATE TABLE of InnoDB table with a partition name
which exceeds the path limit can cause the server
to exit.
During the preparation of the partition name,
there was no check to identify whether the complete
path name for partition exceeds the max supported
path length, causing the server to exit during
subsequent processing.
Fix
===
During the preparation of partition name, check and report
an error if the partition path name exceeds the maximum path
name limit.
This is a 5.5 patch.
|
template<typename t>
CImg<T>& distance_dijkstra(const T& value, const CImg<t>& metric,
const bool is_high_connectivity=false) {
return get_distance_dijkstra(value,metric,is_high_connectivity).move_to(*this);
| 0 |
[
"CWE-125"
] |
CImg
|
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
| 333,457,955,888,905,780,000,000,000,000,000,000,000 | 4 |
Fix other issues in 'CImg<T>::load_bmp()'.
|
static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
bool write_fault, bool *writable)
{
struct vm_area_struct *vma;
kvm_pfn_t pfn = 0;
int npages, r;
/* we can do it either atomically or asynchronously, not both */
BUG_ON(atomic && async);
if (hva_to_pfn_fast(addr, write_fault, writable, &pfn))
return pfn;
if (atomic)
return KVM_PFN_ERR_FAULT;
npages = hva_to_pfn_slow(addr, async, write_fault, writable, &pfn);
if (npages == 1)
return pfn;
down_read(¤t->mm->mmap_sem);
if (npages == -EHWPOISON ||
(!async && check_user_page_hwpoison(addr))) {
pfn = KVM_PFN_ERR_HWPOISON;
goto exit;
}
retry:
vma = find_vma_intersection(current->mm, addr, addr + 1);
if (vma == NULL)
pfn = KVM_PFN_ERR_FAULT;
else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
r = hva_to_pfn_remapped(vma, addr, async, write_fault, writable, &pfn);
if (r == -EAGAIN)
goto retry;
if (r < 0)
pfn = KVM_PFN_ERR_FAULT;
} else {
if (async && vma_is_valid(vma, write_fault))
*async = true;
pfn = KVM_PFN_ERR_FAULT;
}
exit:
up_read(¤t->mm->mmap_sem);
return pfn;
}
| 0 |
[
"CWE-416"
] |
linux
|
0774a964ef561b7170d8d1b1bfe6f88002b6d219
| 247,609,173,231,048,000,000,000,000,000,000,000,000 | 47 |
KVM: Fix out of range accesses to memslots
Reset the LRU slot if it becomes invalid when deleting a memslot to fix
an out-of-bounds/use-after-free access when searching through memslots.
Explicitly check for there being no used slots in search_memslots(), and
in the caller of s390's approximation variant.
Fixes: 36947254e5f9 ("KVM: Dynamically size memslot array based on number of used slots")
Reported-by: Qian Cai <[email protected]>
Cc: Peter Xu <[email protected]>
Signed-off-by: Sean Christopherson <[email protected]>
Message-Id: <[email protected]>
Acked-by: Christian Borntraeger <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
|
size_t AsyncSSLSocket::getRawBytesWritten() const {
// The bio(s) in the write path are in a chain
// each bio flushes to the next and finally written into the socket
// to get the rawBytesWritten on the socket,
// get the write bytes of the last bio
BIO* b;
if (!ssl_ || !(b = SSL_get_wbio(ssl_.get()))) {
return 0;
}
BIO* next = BIO_next(b);
while (next != nullptr) {
b = next;
next = BIO_next(b);
}
return BIO_number_written(b);
}
| 0 |
[
"CWE-125"
] |
folly
|
c321eb588909646c15aefde035fd3133ba32cdee
| 200,345,578,005,131,240,000,000,000,000,000,000,000 | 17 |
Handle close_notify as standard writeErr in AsyncSSLSocket.
Summary: Fixes CVE-2019-11934
Reviewed By: mingtaoy
Differential Revision: D18020613
fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836
|
known_contexts_useful_p (vec<ipa_polymorphic_call_context> known_contexts)
{
ipa_polymorphic_call_context *ctx;
int i;
FOR_EACH_VEC_ELT (known_contexts, i, ctx)
if (!ctx->useless_p ())
return true;
return false;
}
| 0 |
[
"CWE-20"
] |
gcc
|
a09ccc22459c565814f79f96586fe4ad083fe4eb
| 337,843,404,367,528,560,000,000,000,000,000,000,000 | 10 |
Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015)
2019-12-21 Martin Jambor <[email protected]>
PR ipa/93015
* ipa-cp.c (ipcp_store_vr_results): Check that info exists
testsuite/
* gcc.dg/lto/pr93015_0.c: New test.
From-SVN: r279695
|
int rr_sequential(READ_RECORD *info)
{
int tmp;
while ((tmp= info->table->file->ha_rnd_next(info->record)))
{
/*
rnd_next can return RECORD_DELETED for MyISAM when one thread is
reading and another deleting without locks.
*/
if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED))
{
tmp= rr_handle_error(info, tmp);
break;
}
}
return tmp;
}
| 0 |
[] |
server
|
1b8bb44106f528f742faa19d23bd6e822be04f39
| 124,025,585,718,714,930,000,000,000,000,000,000,000 | 17 |
MDEV-26351 segfault - (MARIA_HA *) 0x0 in ha_maria::extra
use the correct check. before invoking handler methods we
need to know that the table was opened, not only created.
|
static int wait_for_connected(struct usb_device *udev,
struct usb_hub *hub, int *port1,
u16 *portchange, u16 *portstatus)
{
int status = 0, delay_ms = 0;
while (delay_ms < 2000) {
if (status || *portstatus & USB_PORT_STAT_CONNECTION)
break;
if (!port_is_power_on(hub, *portstatus)) {
status = -ENODEV;
break;
}
msleep(20);
delay_ms += 20;
status = hub_port_status(hub, *port1, portstatus, portchange);
}
dev_dbg(&udev->dev, "Waited %dms for CONNECT\n", delay_ms);
return status;
}
| 0 |
[
"CWE-400",
"CWE-703"
] |
linux
|
704620afc70cf47abb9d6a1a57f3825d2bca49cf
| 177,736,223,026,223,570,000,000,000,000,000,000,000 | 20 |
USB: check usb_get_extra_descriptor for proper size
When reading an extra descriptor, we need to properly check the minimum
and maximum size allowed, to prevent from invalid data being sent by a
device.
Reported-by: Hui Peng <[email protected]>
Reported-by: Mathias Payer <[email protected]>
Co-developed-by: Linus Torvalds <[email protected]>
Signed-off-by: Hui Peng <[email protected]>
Signed-off-by: Mathias Payer <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
static void mutt_decode_quoted (STATE *s, LOFF_T len, int istext, iconv_t cd)
{
char line[STRING];
char decline[2*STRING];
size_t l = 0;
size_t linelen; /* number of input bytes in `line' */
size_t l3;
int last; /* store the last character in the input line */
if (istext)
state_set_prefix(s);
while (len > 0)
{
last = 0;
/*
* It's ok to use a fixed size buffer for input, even if the line turns
* out to be longer than this. Just process the line in chunks. This
* really shouldn't happen according the MIME spec, since Q-P encoded
* lines are at most 76 characters, but we should be liberal about what
* we accept.
*/
if (fgets (line, MIN ((ssize_t)sizeof (line), len + 1), s->fpin) == NULL)
break;
linelen = strlen(line);
len -= linelen;
/*
* inspect the last character we read so we can tell if we got the
* entire line.
*/
last = linelen ? line[linelen - 1] : 0;
/* chop trailing whitespace if we got the full line */
if (last == '\n')
{
while (linelen > 0 && ISSPACE (line[linelen-1]))
linelen--;
line[linelen]=0;
}
/* decode and do character set conversion */
qp_decode_line (decline + l, line, &l3, last);
l += l3;
mutt_convert_to_state (cd, decline, &l, s);
}
mutt_convert_to_state (cd, 0, 0, s);
state_reset_prefix(s);
}
| 0 |
[
"CWE-120"
] |
mutt
|
e5ed080c00e59701ca62ef9b2a6d2612ebf765a5
| 326,133,803,841,973,900,000,000,000,000,000,000,000 | 53 |
Fix uudecode buffer overflow.
mutt_decode_uuencoded() used each line's initial "length character"
without any validation. It would happily read past the end of the
input line, and with a suitable value even past the length of the
input buffer.
As I noted in ticket 404, there are several other changes that could
be added to make the parser more robust. However, to avoid
accidentally introducing another bug or regression, I'm restricting
this patch to simply addressing the overflow.
Thanks to Tavis Ormandy for reporting the issue, along with a sample
message demonstrating the problem.
|
void __fastcall TConsoleRunner::Input(
const UnicodeString Prompt, UnicodeString & Str, bool Echo, bool Interactive)
{
Print(Prompt);
if (!DoInput(Str, Echo, InputTimeout(), Interactive))
{
Abort();
}
}
| 0 |
[
"CWE-787"
] |
winscp
|
faa96e8144e6925a380f94a97aa382c9427f688d
| 311,351,789,123,174,970,000,000,000,000,000,000,000 | 10 |
Bug 1943: Prevent loading session settings that can lead to remote code execution from handled URLs
https://winscp.net/tracker/1943
(cherry picked from commit ec584f5189a856cd79509f754722a6898045c5e0)
Source commit: 0f4be408b3f01132b00682da72d925d6c4ee649b
|
on_monitor_sighup(int signo)
{
sighup_received = 1;
#ifdef POSIX_SIGTYPE
return;
#else
return(0);
#endif
}
| 0 |
[
"CWE-476"
] |
krb5
|
5d2d9a1abe46a2c1a8614d4672d08d9d30a5f8bf
| 81,571,523,949,876,200,000,000,000,000,000,000,000 | 10 |
Multi-realm KDC null deref [CVE-2013-1418]
If a KDC serves multiple realms, certain requests can cause
setup_server_realm() to dereference a null pointer, crashing the KDC.
CVSSv2: AV:N/AC:M/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C
A related but more minor vulnerability requires authentication to
exploit, and is only present if a third-party KDC database module can
dereference a null pointer under certain conditions.
ticket: 7755 (new)
target_version: 1.12
tags: pullup
|
MONGO_EXPORT void bson_iterator_from_buffer( bson_iterator *i, const char *buffer ) {
i->cur = buffer + 4;
i->first = 1;
}
| 0 |
[
"CWE-190"
] |
mongo-c-driver-legacy
|
1a1f5e26a4309480d88598913f9eebf9e9cba8ca
| 40,552,304,253,023,000,000,000,000,000,000,000,000 | 4 |
don't mix up int and size_t (first pass to fix that)
|
void prepare_echo_response(Stream *stream, Http2Handler *hd) {
auto length = lseek(stream->file_ent->fd, 0, SEEK_END);
if (length == -1) {
hd->submit_rst_stream(stream, NGHTTP2_INTERNAL_ERROR);
return;
}
stream->body_length = length;
if (lseek(stream->file_ent->fd, 0, SEEK_SET) == -1) {
hd->submit_rst_stream(stream, NGHTTP2_INTERNAL_ERROR);
return;
}
nghttp2_data_provider data_prd;
data_prd.source.fd = stream->file_ent->fd;
data_prd.read_callback = file_read_callback;
HeaderRefs headers;
headers.emplace_back(StringRef::from_lit("nghttpd-response"),
StringRef::from_lit("echo"));
if (!hd->get_config()->no_content_length) {
headers.emplace_back(StringRef::from_lit("content-length"),
util::make_string_ref_uint(stream->balloc, length));
}
hd->submit_response(StringRef::from_lit("200"), stream->stream_id, headers,
&data_prd);
}
| 0 |
[] |
nghttp2
|
95efb3e19d174354ca50c65d5d7227d92bcd60e1
| 131,159,534,346,708,640,000,000,000,000,000,000,000 | 26 |
Don't read too greedily
|
MagickExport char *GetNextImageRegistry(void)
{
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
if (registry == (void *) NULL)
return((char *) NULL);
return((char *) GetNextKeyInSplayTree(registry));
}
| 0 |
[
"CWE-476"
] |
ImageMagick
|
cca91aa1861818342e3d072bb0fad7dc4ffac24a
| 317,642,488,282,947,740,000,000,000,000,000,000,000 | 8 |
https://github.com/ImageMagick/ImageMagick/issues/790
|
gsicc_search_icc_table(clist_icctable_t *icc_table, int64_t icc_hashcode, int *size)
{
int tablesize = icc_table->tablesize, k;
clist_icctable_entry_t *curr_entry;
curr_entry = icc_table->head;
for (k = 0; k < tablesize; k++ ) {
if ( curr_entry->serial_data.hashcode == icc_hashcode ) {
*size = curr_entry->serial_data.size;
return curr_entry->serial_data.file_position;
}
curr_entry = curr_entry->next;
}
/* Did not find it! */
*size = 0;
return -1;
}
| 0 |
[] |
ghostpdl
|
6d444c273da5499a4cd72f21cb6d4c9a5256807d
| 14,815,769,148,368,651,000,000,000,000,000,000,000 | 18 |
Bug 697178: Add a file permissions callback
For the rare occasions when the graphics library directly opens a file
(currently for reading), this allows us to apply any restrictions on
file access normally applied in the interpteter.
|
virtual void clipToStrokePath(GfxState * /*state*/) {}
| 0 |
[] |
poppler
|
abf167af8b15e5f3b510275ce619e6fdb42edd40
| 232,861,829,927,822,940,000,000,000,000,000,000,000 | 1 |
Implement tiling/patterns in SplashOutputDev
Fixes bug 13518
|
static void sc_usage(void)
{
BIO_printf(bio_err,"usage: s_client args\n");
BIO_printf(bio_err,"\n");
BIO_printf(bio_err," -host host - use -connect instead\n");
BIO_printf(bio_err," -port port - use -connect instead\n");
BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR);
BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n");
BIO_printf(bio_err," -cert arg - certificate file to use, PEM format assumed\n");
BIO_printf(bio_err," -certform arg - certificate format (PEM or DER) PEM default\n");
BIO_printf(bio_err," -key arg - Private key file to use, in cert file if\n");
BIO_printf(bio_err," not specified but cert file is.\n");
BIO_printf(bio_err," -keyform arg - key format (PEM or DER) PEM default\n");
BIO_printf(bio_err," -pass arg - private key file pass phrase source\n");
BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n");
BIO_printf(bio_err," -CAfile arg - PEM format file of CA's\n");
BIO_printf(bio_err," -reconnect - Drop and re-make the connection with the same Session-ID\n");
BIO_printf(bio_err," -pause - sleep(1) after each read(2) and write(2) system call\n");
BIO_printf(bio_err," -showcerts - show all certificates in the chain\n");
BIO_printf(bio_err," -debug - extra output\n");
#ifdef WATT32
BIO_printf(bio_err," -wdebug - WATT-32 tcp debugging\n");
#endif
BIO_printf(bio_err," -msg - Show protocol messages\n");
BIO_printf(bio_err," -nbio_test - more ssl protocol testing\n");
BIO_printf(bio_err," -state - print the 'ssl' states\n");
#ifdef FIONBIO
BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
#endif
BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
BIO_printf(bio_err," -quiet - no s_client output\n");
BIO_printf(bio_err," -ign_eof - ignore input eof (default when -quiet)\n");
BIO_printf(bio_err," -no_ign_eof - don't ignore input eof\n");
#ifndef OPENSSL_NO_PSK
BIO_printf(bio_err," -psk_identity arg - PSK identity\n");
BIO_printf(bio_err," -psk arg - PSK in hex (without 0x)\n");
# ifndef OPENSSL_NO_JPAKE
BIO_printf(bio_err," -jpake arg - JPAKE secret to use\n");
# endif
#endif
BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
BIO_printf(bio_err," -ssl3 - just use SSLv3\n");
BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n");
BIO_printf(bio_err," -tls1 - just use TLSv1\n");
BIO_printf(bio_err," -dtls1 - just use DTLSv1\n");
BIO_printf(bio_err," -mtu - set the link layer MTU\n");
BIO_printf(bio_err," -no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n");
BIO_printf(bio_err," -serverpref - Use server's cipher preferences (only SSLv2)\n");
BIO_printf(bio_err," -cipher - preferred cipher to use, use the 'openssl ciphers'\n");
BIO_printf(bio_err," command to see what is available\n");
BIO_printf(bio_err," -starttls prot - use the STARTTLS command before starting TLS\n");
BIO_printf(bio_err," for those protocols that support it, where\n");
BIO_printf(bio_err," 'prot' defines which one to assume. Currently,\n");
BIO_printf(bio_err," only \"smtp\", \"pop3\", \"imap\", \"ftp\" and \"xmpp\"\n");
BIO_printf(bio_err," are supported.\n");
#ifndef OPENSSL_NO_ENGINE
BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n");
#endif
BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
BIO_printf(bio_err," -sess_out arg - file to write SSL session to\n");
BIO_printf(bio_err," -sess_in arg - file to read SSL session from\n");
#ifndef OPENSSL_NO_TLSEXT
BIO_printf(bio_err," -servername host - Set TLS extension servername in ClientHello\n");
BIO_printf(bio_err," -tlsextdebug - hex dump of all TLS extensions received\n");
BIO_printf(bio_err," -status - request certificate status from server\n");
BIO_printf(bio_err," -no_ticket - disable use of RFC4507bis session tickets\n");
# ifndef OPENSSL_NO_NPN
BIO_printf(bio_err," -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n");
# endif
#endif
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
}
| 0 |
[] |
openssl
|
ee2ffc279417f15fef3b1073c7dc81a908991516
| 303,904,887,995,895,030,000,000,000,000,000,000,000 | 74 |
Add Next Protocol Negotiation.
|
void fill_luma_motion_vector_predictors(base_context* ctx,
const slice_segment_header* shdr,
de265_image* img,
int xC,int yC,int nCS,int xP,int yP,
int nPbW,int nPbH, int l,
int refIdx, int partIdx,
MotionVector out_mvpList[2])
{
// 8.5.3.1.6: derive two spatial vector predictors A (0) and B (1)
uint8_t availableFlagLXN[2];
MotionVector mvLXN[2];
derive_spatial_luma_vector_prediction(ctx, img, shdr, xC,yC, nCS, xP,yP,
nPbW,nPbH, l, refIdx, partIdx,
availableFlagLXN, mvLXN);
// 8.5.3.1.7: if we only have one spatial vector or both spatial vectors are the same,
// derive a temporal predictor
uint8_t availableFlagLXCol;
MotionVector mvLXCol;
if (availableFlagLXN[0] &&
availableFlagLXN[1] &&
(mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)) {
availableFlagLXCol = 0;
}
else {
derive_temporal_luma_vector_prediction(ctx, img, shdr,
xP,yP, nPbW,nPbH, refIdx,l,
&mvLXCol, &availableFlagLXCol);
}
// --- build candidate vector list with exactly two entries ---
int numMVPCandLX=0;
// spatial predictor A
if (availableFlagLXN[0])
{
out_mvpList[numMVPCandLX++] = mvLXN[0];
}
// spatial predictor B (if not same as A)
if (availableFlagLXN[1] &&
(!availableFlagLXN[0] || // in case A in not available, but mvLXA initialized to same as mvLXB
(mvLXN[0].x != mvLXN[1].x || mvLXN[0].y != mvLXN[1].y)))
{
out_mvpList[numMVPCandLX++] = mvLXN[1];
}
// temporal predictor
if (availableFlagLXCol)
{
out_mvpList[numMVPCandLX++] = mvLXCol;
}
// fill with zero predictors
while (numMVPCandLX<2) {
out_mvpList[numMVPCandLX].x = 0;
out_mvpList[numMVPCandLX].y = 0;
numMVPCandLX++;
}
assert(numMVPCandLX==2);
}
| 0 |
[
"CWE-787"
] |
libde265
|
697aa4f7c774abd6374596e6707a6f4f54265355
| 197,002,547,428,779,920,000,000,000,000,000,000,000 | 74 |
fix MC with HDR chroma, but SDR luma (#301)
|
print_p2r_header (const char *name, const unsigned char *msg, size_t msglen)
{
DEBUGOUT_1 ("%s:\n", name);
if (msglen < 7)
return;
DEBUGOUT_1 (" dwLength ..........: %u\n", convert_le_u32 (msg+1));
DEBUGOUT_1 (" bSlot .............: %u\n", msg[5]);
DEBUGOUT_1 (" bSeq ..............: %u\n", msg[6]);
}
| 0 |
[
"CWE-20"
] |
gnupg
|
2183683bd633818dd031b090b5530951de76f392
| 198,239,993,283,252,400,000,000,000,000,000,000,000 | 9 |
Use inline functions to convert buffer data to scalars.
* common/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.
--
Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to
avoid all sign extension on shift problems. Hanno Böck found a case
with an invalid read due to this problem. To fix that once and for
all almost all uses of "<< 24" and "<< 8" are changed by this patch to
use an inline function from host2net.h.
Signed-off-by: Werner Koch <[email protected]>
|
static char *find_include(const char *prefix, const char *file) {
char *pfx = NULL, *ret = NULL, *env = r_sys_getenv (R_EGG_INCDIR_ENV);
if (!prefix) {
prefix = "";
}
if (*prefix == '$') {
char *out = r_sys_getenv (prefix + 1);
pfx = out? out: strdup ("");
} else {
pfx = strdup (prefix);
if (!pfx) {
free (env);
return NULL;
}
}
if (env) {
char *str, *ptr = strchr (env, ':');
// eprintf ("MUST FIND IN PATH (%s)\n", env);
str = env;
while (str) {
if (ptr) {
*ptr = 0;
}
free (ret);
ret = r_str_appendf (NULL, "%s/%s", pfx, file);
{
char *filepath = r_str_appendf (NULL, "%s/%s/%s", str, pfx, file);
// eprintf ("try (%s)\n", filepath);
if (r_file_exists (filepath)) {
free (env);
free (pfx);
free (ret);
return filepath;
}
free (filepath);
}
if (!ptr) {
break;
}
str = ptr + 1;
ptr = strchr (str, ':');
}
free (env);
} else {
ret = r_str_appendf (NULL, "%s/%s", pfx, file);
}
free (pfx);
return ret;
}
| 0 |
[
"CWE-416"
] |
radare2
|
93af319e0af787ede96537d46210369f5c24240c
| 141,128,523,732,065,500,000,000,000,000,000,000,000 | 50 |
Fix #14296 - Segfault in ragg2 (#14308)
|
f_isdirectory(typval_T *argvars, typval_T *rettv)
{
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
rettv->vval.v_number = mch_isdir(tv_get_string(&argvars[0]));
}
| 0 |
[
"CWE-823",
"CWE-703"
] |
vim
|
5921aeb5741fc6e84c870d68c7c35b93ad0c9f87
| 291,247,955,184,504,960,000,000,000,000,000,000,000 | 7 |
patch 8.2.4418: crash when using special multi-byte character
Problem: Crash when using special multi-byte character.
Solution: Don't use isalpha() for an arbitrary character.
|
normal_cmd(
oparg_T *oap,
int toplevel UNUSED) // TRUE when called from main()
{
cmdarg_T ca; // command arguments
int c;
int ctrl_w = FALSE; // got CTRL-W command
int old_col = curwin->w_curswant;
int need_flushbuf = FALSE; // need to call out_flush()
pos_T old_pos; // cursor position before command
int mapped_len;
static int old_mapped_len = 0;
int idx;
int set_prevcount = FALSE;
int save_did_cursorhold = did_cursorhold;
CLEAR_FIELD(ca); // also resets ca.retval
ca.oap = oap;
// Use a count remembered from before entering an operator. After typing
// "3d" we return from normal_cmd() and come back here, the "3" is
// remembered in "opcount".
ca.opcount = opcount;
// If there is an operator pending, then the command we take this time
// will terminate it. Finish_op tells us to finish the operation before
// returning this time (unless the operation was cancelled).
#ifdef CURSOR_SHAPE
c = finish_op;
#endif
finish_op = (oap->op_type != OP_NOP);
#ifdef CURSOR_SHAPE
if (finish_op != c)
{
ui_cursor_shape(); // may show different cursor shape
# ifdef FEAT_MOUSESHAPE
update_mouseshape(-1);
# endif
}
#endif
may_trigger_modechanged();
// When not finishing an operator and no register name typed, reset the
// count.
if (!finish_op && !oap->regname)
{
ca.opcount = 0;
#ifdef FEAT_EVAL
set_prevcount = TRUE;
#endif
}
// Restore counts from before receiving K_CURSORHOLD. This means after
// typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not
// "3 * 2".
if (oap->prev_opcount > 0 || oap->prev_count0 > 0)
{
ca.opcount = oap->prev_opcount;
ca.count0 = oap->prev_count0;
oap->prev_opcount = 0;
oap->prev_count0 = 0;
}
mapped_len = typebuf_maplen();
State = MODE_NORMAL_BUSY;
#ifdef USE_ON_FLY_SCROLL
dont_scroll = FALSE; // allow scrolling here
#endif
#ifdef FEAT_EVAL
// Set v:count here, when called from main() and not a stuffed
// command, so that v:count can be used in an expression mapping
// when there is no count. Do set it for redo.
if (toplevel && readbuf1_empty())
set_vcount_ca(&ca, &set_prevcount);
#endif
/*
* Get the command character from the user.
*/
c = safe_vgetc();
LANGMAP_ADJUST(c, get_real_state() != MODE_SELECT);
// If a mapping was started in Visual or Select mode, remember the length
// of the mapping. This is used below to not return to Insert mode for as
// long as the mapping is being executed.
if (restart_edit == 0)
old_mapped_len = 0;
else if (old_mapped_len
|| (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0))
old_mapped_len = typebuf_maplen();
if (c == NUL)
c = K_ZERO;
// In Select mode, typed text replaces the selection.
if (VIsual_active
&& VIsual_select
&& (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER))
{
int len;
// Fake a "c"hange command. When "restart_edit" is set (e.g., because
// 'insertmode' is set) fake a "d"elete command, Insert mode will
// restart automatically.
// Insert the typed character in the typeahead buffer, so that it can
// be mapped in Insert mode. Required for ":lmap" to work.
len = ins_char_typebuf(vgetc_char, vgetc_mod_mask);
// When recording and gotchars() was called the character will be
// recorded again, remove the previous recording.
if (KeyTyped)
ungetchars(len);
if (restart_edit != 0)
c = 'd';
else
c = 'c';
msg_nowait = TRUE; // don't delay going to insert mode
old_mapped_len = 0; // do go to Insert mode
}
// If the window was made so small that nothing shows, make it at least one
// line and one column when typing a command.
if (KeyTyped && !KeyStuffed)
win_ensure_size();
#ifdef FEAT_CMDL_INFO
need_flushbuf = add_to_showcmd(c);
#endif
// Get the command count
c = normal_cmd_get_count(&ca, c, toplevel, set_prevcount, &ctrl_w,
&need_flushbuf);
// Find the command character in the table of commands.
// For CTRL-W we already got nchar when looking for a count.
if (ctrl_w)
{
ca.nchar = c;
ca.cmdchar = Ctrl_W;
}
else
ca.cmdchar = c;
idx = find_command(ca.cmdchar);
if (idx < 0)
{
// Not a known command: beep.
clearopbeep(oap);
goto normal_end;
}
if ((nv_cmds[idx].cmd_flags & NV_NCW)
&& (check_text_locked(oap) || curbuf_locked()))
// this command is not allowed now
goto normal_end;
// In Visual/Select mode, a few keys are handled in a special way.
if (VIsual_active)
{
// when 'keymodel' contains "stopsel" may stop Select/Visual mode
if (km_stopsel
&& (nv_cmds[idx].cmd_flags & NV_STS)
&& !(mod_mask & MOD_MASK_SHIFT))
{
end_visual_mode();
redraw_curbuf_later(INVERTED);
}
// Keys that work different when 'keymodel' contains "startsel"
if (km_startsel)
{
if (nv_cmds[idx].cmd_flags & NV_SS)
{
unshift_special(&ca);
idx = find_command(ca.cmdchar);
if (idx < 0)
{
// Just in case
clearopbeep(oap);
goto normal_end;
}
}
else if ((nv_cmds[idx].cmd_flags & NV_SSS)
&& (mod_mask & MOD_MASK_SHIFT))
mod_mask &= ~MOD_MASK_SHIFT;
}
}
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl && KeyTyped && !KeyStuffed
&& (nv_cmds[idx].cmd_flags & NV_RL))
{
// Invert horizontal movements and operations. Only when typed by the
// user directly, not when the result of a mapping or "x" translated
// to "dl".
switch (ca.cmdchar)
{
case 'l': ca.cmdchar = 'h'; break;
case K_RIGHT: ca.cmdchar = K_LEFT; break;
case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break;
case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break;
case 'h': ca.cmdchar = 'l'; break;
case K_LEFT: ca.cmdchar = K_RIGHT; break;
case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break;
case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break;
case '>': ca.cmdchar = '<'; break;
case '<': ca.cmdchar = '>'; break;
}
idx = find_command(ca.cmdchar);
}
#endif
// Get additional characters if we need them.
if (normal_cmd_needs_more_chars(&ca, nv_cmds[idx].cmd_flags))
idx = normal_cmd_get_more_chars(idx, &ca, &need_flushbuf);
#ifdef FEAT_CMDL_INFO
// Flush the showcmd characters onto the screen so we can see them while
// the command is being executed. Only do this when the shown command was
// actually displayed, otherwise this will slow down a lot when executing
// mappings.
if (need_flushbuf)
out_flush();
#endif
if (ca.cmdchar != K_IGNORE)
{
if (ex_normal_busy)
did_cursorhold = save_did_cursorhold;
else
did_cursorhold = FALSE;
}
State = MODE_NORMAL;
if (ca.nchar == ESC)
{
clearop(oap);
if (restart_edit == 0 && goto_im())
restart_edit = 'a';
goto normal_end;
}
if (ca.cmdchar != K_IGNORE)
{
msg_didout = FALSE; // don't scroll screen up for normal command
msg_col = 0;
}
old_pos = curwin->w_cursor; // remember where cursor was
// When 'keymodel' contains "startsel" some keys start Select/Visual
// mode.
if (!VIsual_active && km_startsel)
{
if (nv_cmds[idx].cmd_flags & NV_SS)
{
start_selection();
unshift_special(&ca);
idx = find_command(ca.cmdchar);
}
else if ((nv_cmds[idx].cmd_flags & NV_SSS)
&& (mod_mask & MOD_MASK_SHIFT))
{
start_selection();
mod_mask &= ~MOD_MASK_SHIFT;
}
}
// Execute the command!
// Call the command function found in the commands table.
ca.arg = nv_cmds[idx].cmd_arg;
(nv_cmds[idx].cmd_func)(&ca);
// If we didn't start or finish an operator, reset oap->regname, unless we
// need it later.
if (!finish_op
&& !oap->op_type
&& (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG)))
{
clearop(oap);
#ifdef FEAT_EVAL
reset_reg_var();
#endif
}
// Get the length of mapped chars again after typing a count, second
// character or "z333<cr>".
if (old_mapped_len > 0)
old_mapped_len = typebuf_maplen();
// If an operation is pending, handle it. But not for K_IGNORE or
// K_MOUSEMOVE.
if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE)
do_pending_operator(&ca, old_col, FALSE);
// Wait for a moment when a message is displayed that will be overwritten
// by the mode message.
if (normal_cmd_need_to_wait_for_msg(&ca, &old_pos))
normal_cmd_wait_for_msg();
// Finish up after executing a Normal mode command.
normal_end:
msg_nowait = FALSE;
#ifdef FEAT_EVAL
if (finish_op)
reset_reg_var();
#endif
// Reset finish_op, in case it was set
#ifdef CURSOR_SHAPE
c = finish_op;
#endif
finish_op = FALSE;
may_trigger_modechanged();
#ifdef CURSOR_SHAPE
// Redraw the cursor with another shape, if we were in Operator-pending
// mode or did a replace command.
if (c || ca.cmdchar == 'r')
{
ui_cursor_shape(); // may show different cursor shape
# ifdef FEAT_MOUSESHAPE
update_mouseshape(-1);
# endif
}
#endif
#ifdef FEAT_CMDL_INFO
if (oap->op_type == OP_NOP && oap->regname == 0
&& ca.cmdchar != K_CURSORHOLD)
clear_showcmd();
#endif
checkpcmark(); // check if we moved since setting pcmark
vim_free(ca.searchbuf);
if (has_mbyte)
mb_adjust_cursor();
if (curwin->w_p_scb && toplevel)
{
validate_cursor(); // may need to update w_leftcol
do_check_scrollbind(TRUE);
}
if (curwin->w_p_crb && toplevel)
{
validate_cursor(); // may need to update w_leftcol
do_check_cursorbind();
}
#ifdef FEAT_TERMINAL
// don't go to Insert mode if a terminal has a running job
if (term_job_running(curbuf->b_term))
restart_edit = 0;
#endif
// May restart edit(), if we got here with CTRL-O in Insert mode (but not
// if still inside a mapping that started in Visual mode).
// May switch from Visual to Select mode after CTRL-O command.
if ( oap->op_type == OP_NOP
&& ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0)
|| restart_VIsual_select == 1)
&& !(ca.retval & CA_COMMAND_BUSY)
&& stuff_empty()
&& oap->regname == 0)
{
if (restart_VIsual_select == 1)
{
VIsual_select = TRUE;
may_trigger_modechanged();
showmode();
restart_VIsual_select = 0;
VIsual_select_reg = 0;
}
if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0)
(void)edit(restart_edit, FALSE, 1L);
}
if (restart_VIsual_select == 2)
restart_VIsual_select = 1;
// Save count before an operator for next time.
opcount = ca.opcount;
}
| 0 |
[
"CWE-416"
] |
vim
|
e2fa213cf571041dbd04ab0329303ffdc980678a
| 231,473,365,677,452,460,000,000,000,000,000,000,000 | 388 |
patch 8.2.5024: using freed memory with "]d"
Problem: Using freed memory with "]d".
Solution: Copy the pattern before searching.
|
**/
CImg<T>& operator+=(const char *const expression) {
return *this+=(+*this)._fill(expression,true,1,0,0,"operator+=",this);
| 0 |
[
"CWE-119",
"CWE-787"
] |
CImg
|
ac8003393569aba51048c9d67e1491559877b1d1
| 262,754,147,611,547,600,000,000,000,000,000,000,000 | 3 |
.
|
sbni_interrupt( int irq, void *dev_id )
{
struct net_device *dev = dev_id;
struct net_local *nl = dev->priv;
int repeat;
spin_lock( &nl->lock );
if( nl->second )
spin_lock( &((struct net_local *) nl->second->priv)->lock );
do {
repeat = 0;
if( inb( dev->base_addr + CSR0 ) & (RC_RDY | TR_RDY) )
handle_channel( dev ),
repeat = 1;
if( nl->second && /* second channel present */
(inb( nl->second->base_addr+CSR0 ) & (RC_RDY | TR_RDY)) )
handle_channel( nl->second ),
repeat = 1;
} while( repeat );
if( nl->second )
spin_unlock( &((struct net_local *)nl->second->priv)->lock );
spin_unlock( &nl->lock );
return IRQ_HANDLED;
}
| 0 |
[
"CWE-264"
] |
linux-2.6
|
f2455eb176ac87081bbfc9a44b21c7cd2bc1967e
| 141,069,618,364,515,620,000,000,000,000,000,000,000 | 26 |
wan: Missing capability checks in sbni_ioctl()
There are missing capability checks in the following code:
1300 static int
1301 sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd)
1302 {
[...]
1319 case SIOCDEVRESINSTATS :
1320 if( current->euid != 0 ) /* root only */
1321 return -EPERM;
[...]
1336 case SIOCDEVSHWSTATE :
1337 if( current->euid != 0 ) /* root only */
1338 return -EPERM;
[...]
1357 case SIOCDEVENSLAVE :
1358 if( current->euid != 0 ) /* root only */
1359 return -EPERM;
[...]
1372 case SIOCDEVEMANSIPATE :
1373 if( current->euid != 0 ) /* root only */
1374 return -EPERM;
Here's my proposed fix:
Missing capability checks.
Signed-off-by: Eugene Teo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
void MYSQL_LOG::init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg)
{
DBUG_ENTER("MYSQL_LOG::init");
log_type= log_type_arg;
io_cache_type= io_cache_type_arg;
DBUG_PRINT("info",("log_type: %d", log_type));
DBUG_VOID_RETURN;
}
| 0 |
[
"CWE-264"
] |
mysql-server
|
48bd8b16fe382be302c6f0b45931be5aa6f29a0e
| 313,648,991,076,505,300,000,000,000,000,000,000,000 | 9 |
Bug#24388753: PRIVILEGE ESCALATION USING MYSQLD_SAFE
[This is the 5.5/5.6 version of the bugfix].
The problem was that it was possible to write log files ending
in .ini/.cnf that later could be parsed as an options file.
This made it possible for users to specify startup options
without the permissions to do so.
This patch fixes the problem by disallowing general query log
and slow query log to be written to files ending in .ini and .cnf.
|
schannel_connect_step1(struct Curl_easy *data, struct connectdata *conn,
int sockindex)
{
ssize_t written = -1;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
SecBuffer outbuf;
SecBufferDesc outbuf_desc;
SecBuffer inbuf;
SecBufferDesc inbuf_desc;
#ifdef HAS_ALPN
unsigned char alpn_buffer[128];
#endif
SCHANNEL_CRED schannel_cred;
PCCERT_CONTEXT client_certs[1] = { NULL };
SECURITY_STATUS sspi_status = SEC_E_OK;
struct Curl_schannel_cred *old_cred = NULL;
struct in_addr addr;
#ifdef ENABLE_IPV6
struct in6_addr addr6;
#endif
TCHAR *host_name;
CURLcode result;
char * const hostname = SSL_HOST_NAME();
DEBUGF(infof(data,
"schannel: SSL/TLS connection with %s port %hu (step 1/3)\n",
hostname, conn->remote_port));
if(curlx_verify_windows_version(5, 1, PLATFORM_WINNT,
VERSION_LESS_THAN_EQUAL)) {
/* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and
algorithms that may not be supported by all servers. */
infof(data, "schannel: Windows version is old and may not be able to "
"connect to some servers due to lack of SNI, algorithms, etc.\n");
}
#ifdef HAS_ALPN
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it doesn't seem to be supported for Wine, see curl bug #983. */
BACKEND->use_alpn = conn->bits.tls_enable_alpn &&
!GetProcAddress(GetModuleHandle(TEXT("ntdll")),
"wine_get_version") &&
curlx_verify_windows_version(6, 3, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);
#else
BACKEND->use_alpn = false;
#endif
#ifdef _WIN32_WCE
#ifdef HAS_MANUAL_VERIFY_API
/* certificate validation on CE doesn't seem to work right; we'll
* do it following a more manual process. */
BACKEND->use_manual_cred_validation = true;
#else
#error "compiler too old to support requisite manual cert verify for Win CE"
#endif
#else
#ifdef HAS_MANUAL_VERIFY_API
if(SSL_CONN_CONFIG(CAfile) || SSL_CONN_CONFIG(ca_info_blob)) {
if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL)) {
BACKEND->use_manual_cred_validation = true;
}
else {
failf(data, "schannel: this version of Windows is too old to support "
"certificate verification via CA bundle file.");
return CURLE_SSL_CACERT_BADFILE;
}
}
else
BACKEND->use_manual_cred_validation = false;
#else
if(SSL_CONN_CONFIG(CAfile) || SSL_CONN_CONFIG(ca_info_blob)) {
failf(data, "schannel: CA cert support not built in");
return CURLE_NOT_BUILT_IN;
}
#endif
#endif
BACKEND->cred = NULL;
/* check for an existing re-usable credential handle */
if(SSL_SET_OPTION(primary.sessionid)) {
Curl_ssl_sessionid_lock(data);
if(!Curl_ssl_getsessionid(data, conn,
SSL_IS_PROXY() ? TRUE : FALSE,
(void **)&old_cred, NULL, sockindex)) {
BACKEND->cred = old_cred;
DEBUGF(infof(data, "schannel: re-using existing credential handle\n"));
/* increment the reference counter of the credential/session handle */
BACKEND->cred->refcount++;
DEBUGF(infof(data,
"schannel: incremented credential handle refcount = %d\n",
BACKEND->cred->refcount));
}
Curl_ssl_sessionid_unlock(data);
}
if(!BACKEND->cred) {
/* setup Schannel API options */
memset(&schannel_cred, 0, sizeof(schannel_cred));
schannel_cred.dwVersion = SCHANNEL_CRED_VERSION;
if(conn->ssl_config.verifypeer) {
#ifdef HAS_MANUAL_VERIFY_API
if(BACKEND->use_manual_cred_validation)
schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION;
else
#endif
schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
if(SSL_SET_OPTION(no_revoke)) {
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
DEBUGF(infof(data, "schannel: disabled server certificate revocation "
"checks\n"));
}
else if(SSL_SET_OPTION(revoke_best_effort)) {
schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
SCH_CRED_IGNORE_REVOCATION_OFFLINE | SCH_CRED_REVOCATION_CHECK_CHAIN;
DEBUGF(infof(data, "schannel: ignore revocation offline errors"));
}
else {
schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN;
DEBUGF(infof(data,
"schannel: checking server certificate revocation\n"));
}
}
else {
schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION |
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
DEBUGF(infof(data,
"schannel: disabled server cert revocation checks\n"));
}
if(!conn->ssl_config.verifyhost) {
schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK;
DEBUGF(infof(data, "schannel: verifyhost setting prevents Schannel from "
"comparing the supplied target name with the subject "
"names in server certificates.\n"));
}
if(!SSL_SET_OPTION(auto_client_cert)) {
schannel_cred.dwFlags &= ~SCH_CRED_USE_DEFAULT_CREDS;
schannel_cred.dwFlags |= SCH_CRED_NO_DEFAULT_CREDS;
infof(data, "schannel: disabled automatic use of client certificate\n");
}
else
infof(data, "schannel: enabled automatic use of client certificate\n");
switch(conn->ssl_config.version) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1_1:
case CURL_SSLVERSION_TLSv1_2:
case CURL_SSLVERSION_TLSv1_3:
{
result = set_ssl_version_min_max(&schannel_cred, data, conn);
if(result != CURLE_OK)
return result;
break;
}
case CURL_SSLVERSION_SSLv3:
case CURL_SSLVERSION_SSLv2:
failf(data, "SSL versions not supported");
return CURLE_NOT_BUILT_IN;
default:
failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
return CURLE_SSL_CONNECT_ERROR;
}
if(SSL_CONN_CONFIG(cipher_list)) {
result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list),
BACKEND->algIds);
if(CURLE_OK != result) {
failf(data, "Unable to set ciphers to passed via SSL_CONN_CONFIG");
return result;
}
}
#ifdef HAS_CLIENT_CERT_PATH
/* client certificate */
if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
DWORD cert_store_name = 0;
TCHAR *cert_store_path = NULL;
TCHAR *cert_thumbprint_str = NULL;
CRYPT_HASH_BLOB cert_thumbprint;
BYTE cert_thumbprint_data[CERT_THUMBPRINT_DATA_LEN];
HCERTSTORE cert_store = NULL;
FILE *fInCert = NULL;
void *certdata = NULL;
size_t certsize = 0;
bool blob = data->set.ssl.primary.cert_blob != NULL;
TCHAR *cert_path = NULL;
if(blob) {
certdata = data->set.ssl.primary.cert_blob->data;
certsize = data->set.ssl.primary.cert_blob->len;
}
else {
cert_path = curlx_convert_UTF8_to_tchar(
data->set.ssl.primary.clientcert);
if(!cert_path)
return CURLE_OUT_OF_MEMORY;
result = get_cert_location(cert_path, &cert_store_name,
&cert_store_path, &cert_thumbprint_str);
if(result && (data->set.ssl.primary.clientcert[0]!='\0'))
fInCert = fopen(data->set.ssl.primary.clientcert, "rb");
if(result && !fInCert) {
failf(data, "schannel: Failed to get certificate location"
" or file for %s",
data->set.ssl.primary.clientcert);
curlx_unicodefree(cert_path);
return result;
}
}
if((fInCert || blob) && (data->set.ssl.cert_type) &&
(!strcasecompare(data->set.ssl.cert_type, "P12"))) {
failf(data, "schannel: certificate format compatibility error "
" for %s",
blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
curlx_unicodefree(cert_path);
return CURLE_SSL_CERTPROBLEM;
}
if(fInCert || blob) {
/* Reading a .P12 or .pfx file, like the example at bottom of
https://social.msdn.microsoft.com/Forums/windowsdesktop/
en-US/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5
*/
CRYPT_DATA_BLOB datablob;
WCHAR* pszPassword;
size_t pwd_len = 0;
int str_w_len = 0;
const char *cert_showfilename_error = blob ?
"(memory blob)" : data->set.ssl.primary.clientcert;
curlx_unicodefree(cert_path);
if(fInCert) {
long cert_tell = 0;
bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0;
if(continue_reading)
cert_tell = ftell(fInCert);
if(cert_tell < 0)
continue_reading = FALSE;
else
certsize = (size_t)cert_tell;
if(continue_reading)
continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
if(continue_reading)
certdata = malloc(certsize + 1);
if((!certdata) ||
((int) fread(certdata, certsize, 1, fInCert) != 1))
continue_reading = FALSE;
fclose(fInCert);
if(!continue_reading) {
failf(data, "schannel: Failed to read cert file %s",
data->set.ssl.primary.clientcert);
free(certdata);
return CURLE_SSL_CERTPROBLEM;
}
}
/* Convert key-pair data to the in-memory certificate store */
datablob.pbData = (BYTE*)certdata;
datablob.cbData = (DWORD)certsize;
if(data->set.ssl.key_passwd != NULL)
pwd_len = strlen(data->set.ssl.key_passwd);
pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1));
if(pszPassword) {
if(pwd_len > 0)
str_w_len = MultiByteToWideChar(CP_UTF8,
MB_ERR_INVALID_CHARS,
data->set.ssl.key_passwd, (int)pwd_len,
pszPassword, (int)(pwd_len + 1));
if((str_w_len >= 0) && (str_w_len <= (int)pwd_len))
pszPassword[str_w_len] = 0;
else
pszPassword[0] = 0;
cert_store = PFXImportCertStore(&datablob, pszPassword, 0);
free(pszPassword);
}
if(!blob)
free(certdata);
if(!cert_store) {
DWORD errorcode = GetLastError();
if(errorcode == ERROR_INVALID_PASSWORD)
failf(data, "schannel: Failed to import cert file %s, "
"password is bad",
cert_showfilename_error);
else
failf(data, "schannel: Failed to import cert file %s, "
"last error is 0x%x",
cert_showfilename_error, errorcode);
return CURLE_SSL_CERTPROBLEM;
}
client_certs[0] = CertFindCertificateInStore(
cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
CERT_FIND_ANY, NULL, NULL);
if(!client_certs[0]) {
failf(data, "schannel: Failed to get certificate from file %s"
", last error is 0x%x",
cert_showfilename_error, GetLastError());
CertCloseStore(cert_store, 0);
return CURLE_SSL_CERTPROBLEM;
}
schannel_cred.cCreds = 1;
schannel_cred.paCred = client_certs;
}
else {
cert_store =
CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
(HCRYPTPROV)NULL,
CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
cert_store_path);
if(!cert_store) {
failf(data, "schannel: Failed to open cert store %x %s, "
"last error is 0x%x",
cert_store_name, cert_store_path, GetLastError());
free(cert_store_path);
curlx_unicodefree(cert_path);
return CURLE_SSL_CERTPROBLEM;
}
free(cert_store_path);
cert_thumbprint.pbData = cert_thumbprint_data;
cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN;
if(!CryptStringToBinary(cert_thumbprint_str,
CERT_THUMBPRINT_STR_LEN,
CRYPT_STRING_HEX,
cert_thumbprint_data,
&cert_thumbprint.cbData,
NULL, NULL)) {
curlx_unicodefree(cert_path);
CertCloseStore(cert_store, 0);
return CURLE_SSL_CERTPROBLEM;
}
client_certs[0] = CertFindCertificateInStore(
cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
CERT_FIND_HASH, &cert_thumbprint, NULL);
curlx_unicodefree(cert_path);
if(client_certs[0]) {
schannel_cred.cCreds = 1;
schannel_cred.paCred = client_certs;
}
else {
/* CRYPT_E_NOT_FOUND / E_INVALIDARG */
CertCloseStore(cert_store, 0);
return CURLE_SSL_CERTPROBLEM;
}
}
CertCloseStore(cert_store, 0);
}
#else
if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
failf(data, "schannel: client cert support not built in");
return CURLE_NOT_BUILT_IN;
}
#endif
/* allocate memory for the re-usable credential handle */
BACKEND->cred = (struct Curl_schannel_cred *)
calloc(1, sizeof(struct Curl_schannel_cred));
if(!BACKEND->cred) {
failf(data, "schannel: unable to allocate memory");
if(client_certs[0])
CertFreeCertificateContext(client_certs[0]);
return CURLE_OUT_OF_MEMORY;
}
BACKEND->cred->refcount = 1;
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa374716.aspx
*/
sspi_status =
s_pSecFn->AcquireCredentialsHandle(NULL, (TCHAR *)UNISP_NAME,
SECPKG_CRED_OUTBOUND, NULL,
&schannel_cred, NULL, NULL,
&BACKEND->cred->cred_handle,
&BACKEND->cred->time_stamp);
if(client_certs[0])
CertFreeCertificateContext(client_certs[0]);
if(sspi_status != SEC_E_OK) {
char buffer[STRERROR_LEN];
failf(data, "schannel: AcquireCredentialsHandle failed: %s",
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
Curl_safefree(BACKEND->cred);
switch(sspi_status) {
case SEC_E_INSUFFICIENT_MEMORY:
return CURLE_OUT_OF_MEMORY;
case SEC_E_NO_CREDENTIALS:
case SEC_E_SECPKG_NOT_FOUND:
case SEC_E_NOT_OWNER:
case SEC_E_UNKNOWN_CREDENTIALS:
case SEC_E_INTERNAL_ERROR:
default:
return CURLE_SSL_CONNECT_ERROR;
}
}
}
/* Warn if SNI is disabled due to use of an IP address */
if(Curl_inet_pton(AF_INET, hostname, &addr)
#ifdef ENABLE_IPV6
|| Curl_inet_pton(AF_INET6, hostname, &addr6)
#endif
) {
infof(data, "schannel: using IP address, SNI is not supported by OS.\n");
}
#ifdef HAS_ALPN
if(BACKEND->use_alpn) {
int cur = 0;
int list_start_index = 0;
unsigned int *extension_len = NULL;
unsigned short* list_len = NULL;
/* The first four bytes will be an unsigned int indicating number
of bytes of data in the rest of the buffer. */
extension_len = (unsigned int *)(&alpn_buffer[cur]);
cur += sizeof(unsigned int);
/* The next four bytes are an indicator that this buffer will contain
ALPN data, as opposed to NPN, for example. */
*(unsigned int *)&alpn_buffer[cur] =
SecApplicationProtocolNegotiationExt_ALPN;
cur += sizeof(unsigned int);
/* The next two bytes will be an unsigned short indicating the number
of bytes used to list the preferred protocols. */
list_len = (unsigned short*)(&alpn_buffer[cur]);
cur += sizeof(unsigned short);
list_start_index = cur;
#ifdef USE_HTTP2
if(data->state.httpwant >= CURL_HTTP_VERSION_2) {
memcpy(&alpn_buffer[cur], ALPN_H2, ALPN_H2_LENGTH);
cur += ALPN_H2_LENGTH;
infof(data, "schannel: ALPN, offering %s\n", ALPN_H2);
}
#endif
alpn_buffer[cur++] = ALPN_HTTP_1_1_LENGTH;
memcpy(&alpn_buffer[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH);
cur += ALPN_HTTP_1_1_LENGTH;
infof(data, "schannel: ALPN, offering %s\n", ALPN_HTTP_1_1);
*list_len = curlx_uitous(cur - list_start_index);
*extension_len = *list_len + sizeof(unsigned int) + sizeof(unsigned short);
InitSecBuffer(&inbuf, SECBUFFER_APPLICATION_PROTOCOLS, alpn_buffer, cur);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
else {
InitSecBuffer(&inbuf, SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
#else /* HAS_ALPN */
InitSecBuffer(&inbuf, SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
#endif
/* setup output buffer */
InitSecBuffer(&outbuf, SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&outbuf_desc, &outbuf, 1);
/* security request flags */
BACKEND->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
if(!SSL_SET_OPTION(auto_client_cert)) {
BACKEND->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS;
}
/* allocate memory for the security context handle */
BACKEND->ctxt = (struct Curl_schannel_ctxt *)
calloc(1, sizeof(struct Curl_schannel_ctxt));
if(!BACKEND->ctxt) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
}
host_name = curlx_convert_UTF8_to_tchar(hostname);
if(!host_name)
return CURLE_OUT_OF_MEMORY;
/* Schannel InitializeSecurityContext:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa375924.aspx
At the moment we don't pass inbuf unless we're using ALPN since we only
use it for that, and Wine (for which we currently disable ALPN) is giving
us problems with inbuf regardless. https://github.com/curl/curl/issues/983
*/
sspi_status = s_pSecFn->InitializeSecurityContext(
&BACKEND->cred->cred_handle, NULL, host_name, BACKEND->req_flags, 0, 0,
(BACKEND->use_alpn ? &inbuf_desc : NULL),
0, &BACKEND->ctxt->ctxt_handle,
&outbuf_desc, &BACKEND->ret_flags, &BACKEND->ctxt->time_stamp);
curlx_unicodefree(host_name);
if(sspi_status != SEC_I_CONTINUE_NEEDED) {
char buffer[STRERROR_LEN];
Curl_safefree(BACKEND->ctxt);
switch(sspi_status) {
case SEC_E_INSUFFICIENT_MEMORY:
failf(data, "schannel: initial InitializeSecurityContext failed: %s",
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
return CURLE_OUT_OF_MEMORY;
case SEC_E_WRONG_PRINCIPAL:
failf(data, "schannel: SNI or certificate check failed: %s",
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
return CURLE_PEER_FAILED_VERIFICATION;
/*
case SEC_E_INVALID_HANDLE:
case SEC_E_INVALID_TOKEN:
case SEC_E_LOGON_DENIED:
case SEC_E_TARGET_UNKNOWN:
case SEC_E_NO_AUTHENTICATING_AUTHORITY:
case SEC_E_INTERNAL_ERROR:
case SEC_E_NO_CREDENTIALS:
case SEC_E_UNSUPPORTED_FUNCTION:
case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
*/
default:
failf(data, "schannel: initial InitializeSecurityContext failed: %s",
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
return CURLE_SSL_CONNECT_ERROR;
}
}
DEBUGF(infof(data, "schannel: sending initial handshake data: "
"sending %lu bytes...\n", outbuf.cbBuffer));
/* send initial handshake data which is now stored in output buffer */
result = Curl_write_plain(data, conn->sock[sockindex], outbuf.pvBuffer,
outbuf.cbBuffer, &written);
s_pSecFn->FreeContextBuffer(outbuf.pvBuffer);
if((result != CURLE_OK) || (outbuf.cbBuffer != (size_t) written)) {
failf(data, "schannel: failed to send initial handshake data: "
"sent %zd of %lu bytes", written, outbuf.cbBuffer);
return CURLE_SSL_CONNECT_ERROR;
}
DEBUGF(infof(data, "schannel: sent initial handshake data: "
"sent %zd bytes\n", written));
BACKEND->recv_unrecoverable_err = CURLE_OK;
BACKEND->recv_sspi_close_notify = false;
BACKEND->recv_connection_closed = false;
BACKEND->encdata_is_incomplete = false;
/* continue to second handshake step */
connssl->connecting_state = ssl_connect_2;
return CURLE_OK;
}
| 0 |
[
"CWE-416",
"CWE-295"
] |
curl
|
7f4a9a9b2a49547eae24d2e19bc5c346e9026479
| 33,903,512,494,372,710,000,000,000,000,000,000,000 | 581 |
openssl: associate/detach the transfer from connection
CVE-2021-22901
Bug: https://curl.se/docs/CVE-2021-22901.html
|
XML_SetCdataSectionHandler(XML_Parser parser,
XML_StartCdataSectionHandler start,
XML_EndCdataSectionHandler end)
{
if (parser == NULL)
return;
startCdataSectionHandler = start;
endCdataSectionHandler = end;
}
| 0 |
[
"CWE-611"
] |
libexpat
|
c4bf96bb51dd2a1b0e185374362ee136fe2c9d7f
| 90,607,189,587,436,570,000,000,000,000,000,000,000 | 9 |
xmlparse.c: Fix external entity infinite loop bug (CVE-2017-9233)
|
static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
uint32_t value = BrotliUnalignedRead32(p);
return BROTLI_BSWAP32_(value);
}
| 0 |
[
"CWE-120"
] |
brotli
|
223d80cfbec8fd346e32906c732c8ede21f0cea6
| 215,193,405,575,505,750,000,000,000,000,000,000,000 | 4 |
Update (#826)
* IMPORTANT: decoder: fix potential overflow when input chunk is >2GiB
* simplify max Huffman table size calculation
* eliminate symbol duplicates (static arrays in .h files)
* minor combing in research/ code
|
MagickExport MagickBooleanType DrawAffineImage(Image *image,
const Image *source,const AffineMatrix *affine)
{
AffineMatrix
inverse_affine;
CacheView
*image_view,
*source_view;
ExceptionInfo
*exception;
MagickBooleanType
status;
MagickPixelPacket
zero;
PointInfo
extent[4],
min,
max,
point;
ssize_t
i;
SegmentInfo
edge;
ssize_t
start,
stop,
y;
/*
Determine bounding box.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(source != (const Image *) NULL);
assert(source->signature == MagickCoreSignature);
assert(affine != (AffineMatrix *) NULL);
extent[0].x=0.0;
extent[0].y=0.0;
extent[1].x=(double) source->columns-1.0;
extent[1].y=0.0;
extent[2].x=(double) source->columns-1.0;
extent[2].y=(double) source->rows-1.0;
extent[3].x=0.0;
extent[3].y=(double) source->rows-1.0;
for (i=0; i < 4; i++)
{
point=extent[i];
extent[i].x=point.x*affine->sx+point.y*affine->ry+affine->tx;
extent[i].y=point.x*affine->rx+point.y*affine->sy+affine->ty;
}
min=extent[0];
max=extent[0];
for (i=1; i < 4; i++)
{
if (min.x > extent[i].x)
min.x=extent[i].x;
if (min.y > extent[i].y)
min.y=extent[i].y;
if (max.x < extent[i].x)
max.x=extent[i].x;
if (max.y < extent[i].y)
max.y=extent[i].y;
}
/*
Affine transform image.
*/
if (SetImageStorageClass(image,DirectClass) == MagickFalse)
return(MagickFalse);
status=MagickTrue;
edge.x1=MagickMax(min.x,0.0);
edge.y1=MagickMax(min.y,0.0);
edge.x2=MagickMin(max.x,(double) image->columns-1.0);
edge.y2=MagickMin(max.y,(double) image->rows-1.0);
inverse_affine=InverseAffineMatrix(affine);
GetMagickPixelPacket(image,&zero);
exception=(&image->exception);
start=CastDoubleToLong(ceil(edge.y1-0.5));
stop=CastDoubleToLong(floor(edge.y2+0.5));
source_view=AcquireVirtualCacheView(source,exception);
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
magick_number_threads(source,image,stop-start,1)
#endif
for (y=start; y <= stop; y++)
{
MagickPixelPacket
composite,
pixel;
PointInfo
point;
IndexPacket
*magick_restrict indexes;
ssize_t
x;
PixelPacket
*magick_restrict q;
SegmentInfo
inverse_edge;
ssize_t
x_offset;
if (status == MagickFalse)
continue;
inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
if (inverse_edge.x2 < inverse_edge.x1)
continue;
q=GetCacheViewAuthenticPixels(image_view,CastDoubleToLong(
ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToLong(floor(
inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),1,exception);
if (q == (PixelPacket *) NULL)
continue;
indexes=GetCacheViewAuthenticIndexQueue(image_view);
pixel=zero;
composite=zero;
x_offset=0;
for (x=CastDoubleToLong(ceil(inverse_edge.x1-0.5));
x <= CastDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
{
point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
inverse_affine.tx;
point.y=(double) x*inverse_affine.rx+y*inverse_affine.sy+
inverse_affine.ty;
status=InterpolateMagickPixelPacket(source,source_view,
UndefinedInterpolatePixel,point.x,point.y,&pixel,exception);
if (status == MagickFalse)
break;
SetMagickPixelPacket(image,q,indexes+x_offset,&composite);
MagickPixelCompositeOver(&pixel,pixel.opacity,&composite,
composite.opacity,&composite);
SetPixelPacket(image,&composite,q,indexes+x_offset);
x_offset++;
q++;
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
}
source_view=DestroyCacheView(source_view);
image_view=DestroyCacheView(image_view);
return(status);
}
| 0 |
[] |
ImageMagick6
|
4b5e026c704d777efe9c2ead5dd68ca4fe3b2aa1
| 174,786,277,012,104,270,000,000,000,000,000,000,000 | 157 |
https://github.com/ImageMagick/ImageMagick/issues/3338
|
std::string get_program_invocation(const std::string &program_name)
{
const std::string real_program_name(program_name
#ifdef DEBUG
+ "-debug"
#endif
#ifdef _WIN32
+ ".exe"
#endif
);
return (path(game_config::wesnoth_program_dir) / real_program_name).string();
}
| 0 |
[
"CWE-200"
] |
wesnoth
|
f8914468182e8d0a1551b430c0879ba236fe4d6d
| 149,092,620,517,897,680,000,000,000,000,000,000,000 | 12 |
Disallow inclusion of .pbl files from WML (bug #23504)
Note that this will also cause Lua wesnoth.have_file() to return false
on .pbl files.
|
ff_layout_release_ds_info(struct pnfs_ds_commit_info *fl_cinfo,
struct inode *inode)
{
spin_lock(&inode->i_lock);
pnfs_generic_ds_cinfo_destroy(fl_cinfo);
spin_unlock(&inode->i_lock);
}
| 0 |
[
"CWE-787"
] |
linux
|
ed34695e15aba74f45247f1ee2cf7e09d449f925
| 176,551,249,958,596,660,000,000,000,000,000,000,000 | 7 |
pNFS/flexfiles: fix incorrect size check in decode_nfs_fh()
We (adam zabrocki, alexander matrosov, alexander tereshkin, maksym
bazalii) observed the check:
if (fh->size > sizeof(struct nfs_fh))
should not use the size of the nfs_fh struct which includes an extra two
bytes from the size field.
struct nfs_fh {
unsigned short size;
unsigned char data[NFS_MAXFHSIZE];
}
but should determine the size from data[NFS_MAXFHSIZE] so the memcpy
will not write 2 bytes beyond destination. The proposed fix is to
compare against the NFS_MAXFHSIZE directly, as is done elsewhere in fs
code base.
Fixes: d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver")
Signed-off-by: Nikola Livic <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
|
static void channel_change_topic(IRC_SERVER_REC *server, const char *channel,
const char *topic, const char *setby,
time_t settime)
{
CHANNEL_REC *chanrec;
char *recoded = NULL;
chanrec = channel_find(SERVER(server), channel);
if (chanrec == NULL) return;
/* the topic may be send out encoded, so we need to
recode it back or /topic <tab> will not work properly */
recoded = recode_in(SERVER(server), topic, channel);
if (topic != NULL) {
g_free_not_null(chanrec->topic);
chanrec->topic = recoded == NULL ? NULL : g_strdup(recoded);
}
g_free(recoded);
g_free_not_null(chanrec->topic_by);
chanrec->topic_by = g_strdup(setby);
chanrec->topic_time = settime;
signal_emit("channel topic changed", 1, chanrec);
}
| 0 |
[
"CWE-416"
] |
irssi
|
43e44d553d44e313003cee87e6ea5e24d68b84a1
| 152,126,712,150,172,920,000,000,000,000,000,000,000 | 25 |
Merge branch 'security' into 'master'
Security
Closes GL#12, GL#13, GL#14, GL#15, GL#16
See merge request irssi/irssi!23
|
int push_unpushed_submodules(struct oid_array *commits,
const struct remote *remote,
const char **refspec, int refspec_nr,
const struct string_list *push_options,
int dry_run)
{
int i, ret = 1;
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
if (!find_unpushed_submodules(commits, remote->name, &needs_pushing))
return 1;
/*
* Verify that the remote and refspec can be propagated to all
* submodules. This check can be skipped if the remote and refspec
* won't be propagated due to the remote being unconfigured (e.g. a URL
* instead of a remote name).
*/
if (remote->origin != REMOTE_UNCONFIGURED) {
char *head;
struct object_id head_oid;
head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
if (!head)
die(_("Failed to resolve HEAD as a valid ref."));
for (i = 0; i < needs_pushing.nr; i++)
submodule_push_check(needs_pushing.items[i].string,
head, remote,
refspec, refspec_nr);
free(head);
}
/* Actually push the submodules */
for (i = 0; i < needs_pushing.nr; i++) {
const char *path = needs_pushing.items[i].string;
fprintf(stderr, "Pushing submodule '%s'\n", path);
if (!push_submodule(path, remote, refspec, refspec_nr,
push_options, dry_run)) {
fprintf(stderr, "Unable to push submodule '%s'\n", path);
ret = 0;
}
}
string_list_clear(&needs_pushing, 0);
return ret;
}
| 0 |
[] |
git
|
a8dee3ca610f5a1d403634492136c887f83b59d2
| 226,565,836,576,068,800,000,000,000,000,000,000,000 | 48 |
Disallow dubiously-nested submodule git directories
Currently it is technically possible to let a submodule's git
directory point right into the git dir of a sibling submodule.
Example: the git directories of two submodules with the names `hippo`
and `hippo/hooks` would be `.git/modules/hippo/` and
`.git/modules/hippo/hooks/`, respectively, but the latter is already
intended to house the former's hooks.
In most cases, this is just confusing, but there is also a (quite
contrived) attack vector where Git can be fooled into mistaking remote
content for file contents it wrote itself during a recursive clone.
Let's plug this bug.
To do so, we introduce the new function `validate_submodule_git_dir()`
which simply verifies that no git dir exists for any leading directories
of the submodule name (if there are any).
Note: this patch specifically continues to allow sibling modules names
of the form `core/lib`, `core/doc`, etc, as long as `core` is not a
submodule name.
This fixes CVE-2019-1387.
Reported-by: Nicolas Joly <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
|
static int handle_apic_access(struct kvm_vcpu *vcpu)
{
if (likely(fasteoi)) {
unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
int access_type, offset;
access_type = exit_qualification & APIC_ACCESS_TYPE;
offset = exit_qualification & APIC_ACCESS_OFFSET;
/*
* Sane guest uses MOV to write EOI, with written value
* not cared. So make a short-circuit here by avoiding
* heavy instruction emulation.
*/
if ((access_type == TYPE_LINEAR_APIC_INST_WRITE) &&
(offset == APIC_EOI)) {
kvm_lapic_set_eoi(vcpu);
skip_emulated_instruction(vcpu);
return 1;
}
}
return emulate_instruction(vcpu, 0) == EMULATE_DONE;
}
| 0 |
[] |
kvm
|
a642fc305053cc1c6e47e4f4df327895747ab485
| 181,652,608,414,470,750,000,000,000,000,000,000,000 | 22 |
kvm: vmx: handle invvpid vm exit gracefully
On systems with invvpid instruction support (corresponding bit in
IA32_VMX_EPT_VPID_CAP MSR is set) guest invocation of invvpid
causes vm exit, which is currently not handled and results in
propagation of unknown exit to userspace.
Fix this by installing an invvpid vm exit handler.
This is CVE-2014-3646.
Cc: [email protected]
Signed-off-by: Petr Matousek <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
|
lldp_tlv_end(struct dp_packet *p, unsigned int start)
{
ovs_be16 *tlv = dp_packet_at_assert(p, start, 2);
*tlv |= htons((dp_packet_size(p) - (start + 2)) & 0x1ff);
}
| 0 |
[
"CWE-400"
] |
ovs
|
78e712c0b1dacc2f12d2a03d98f083d8672867f0
| 133,629,731,024,295,950,000,000,000,000,000,000,000 | 5 |
lldp: do not leak memory on multiple instances of TLVs
Upstream commit:
commit a8d3c90feca548fc0656d95b5d278713db86ff61
Date: Tue, 17 Nov 2020 09:28:17 -0500
lldp: avoid memory leak from bad packets
A packet that contains multiple instances of certain TLVs will cause
lldpd to continually allocate memory and leak the old memory. As an
example, multiple instances of system name TLV will cause old values
to be dropped by the decoding routine.
Reported-at: https://github.com/openvswitch/ovs/pull/337
Reported-by: Jonas Rudloff <[email protected]>
Signed-off-by: Aaron Conole <[email protected]>
Vulnerability: CVE-2020-27827
Signed-off-by: Aaron Conole <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
|
cin_get_equal_amount(linenr_T lnum)
{
char_u *line;
char_u *s;
colnr_T col;
pos_T fp;
if (lnum > 1)
{
line = ml_get(lnum - 1);
if (*line != NUL && line[STRLEN(line) - 1] == '\\')
return -1;
}
line = s = ml_get(lnum);
while (*s != NUL && vim_strchr((char_u *)"=;{}\"'", *s) == NULL)
{
if (cin_iscomment(s)) // ignore comments
s = cin_skipcomment(s);
else
++s;
}
if (*s != '=')
return 0;
s = skipwhite(s + 1);
if (cin_nocode(s))
return 0;
if (*s == '"') // nice alignment for continued strings
++s;
fp.lnum = lnum;
fp.col = (colnr_T)(s - line);
getvcol(curwin, &fp, &col, NULL, NULL);
return (int)col;
}
| 0 |
[
"CWE-122",
"CWE-787"
] |
vim
|
2de9b7c7c8791da8853a9a7ca9c467867465b655
| 87,179,163,097,962,660,000,000,000,000,000,000,000 | 37 |
patch 8.2.3625: illegal memory access when C-indenting
Problem: Illegal memory access when C-indenting.
Solution: Also set the cursor column.
|
static void udscs_connection_class_init(UdscsConnectionClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
VDAgentConnectionClass *conn_class = VDAGENT_CONNECTION_CLASS(klass);
gobject_class->finalize = udscs_connection_finalize;
conn_class->handle_header = conn_handle_header;
conn_class->handle_message = conn_handle_message;
}
| 0 |
[
"CWE-770"
] |
spice-vd_agent
|
91caa9223857708475d29df1768208fed1675340
| 331,622,249,411,344,800,000,000,000,000,000,000,000 | 10 |
Avoids unlimited agent connections
Limit the number of agents that can be connected.
Avoids reaching the maximum number of files in a process.
Beside one file descriptor per agent the daemon open just some
other fixed number of files.
This issue was reported by SUSE security team.
Signed-off-by: Frediano Ziglio <[email protected]>
|
GF_Node *gf_sg_get_root_node(GF_SceneGraph *sg)
{
return sg ? sg->RootNode : NULL;
}
| 0 |
[
"CWE-416"
] |
gpac
|
9723dd0955894f2cb7be13b94cf7a47f2754b893
| 242,286,934,202,881,200,000,000,000,000,000,000,000 | 4 |
fixed #2109
|
static long sock_prot_memory_allocated(struct proto *proto)
{
return proto->memory_allocated != NULL ? proto_memory_allocated(proto): -1L;
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
linux
|
82981930125abfd39d7c8378a9cfdf5e1be2002b
| 61,670,527,001,997,200,000,000,000,000,000,000,000 | 4 |
net: cleanups in sock_setsockopt()
Use min_t()/max_t() macros, reformat two comments, use !!test_bit() to
match !!sock_flag()
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
_rsvg_node_text_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
{
double x, y;
gboolean lastwasspace = TRUE;
RsvgNodeText *text = (RsvgNodeText *) self;
rsvg_state_reinherit_top (ctx, self->state, dominate);
x = _rsvg_css_normalize_length (&text->x, ctx, 'h');
y = _rsvg_css_normalize_length (&text->y, ctx, 'v');
x += _rsvg_css_normalize_length (&text->dx, ctx, 'h');
y += _rsvg_css_normalize_length (&text->dy, ctx, 'v');
if (rsvg_current_state (ctx)->text_anchor != TEXT_ANCHOR_START) {
double length = 0;
_rsvg_node_text_length_children (self, ctx, &length, &lastwasspace);
if (rsvg_current_state (ctx)->text_anchor == TEXT_ANCHOR_END)
x -= length;
if (rsvg_current_state (ctx)->text_anchor == TEXT_ANCHOR_MIDDLE)
x -= length / 2;
}
lastwasspace = TRUE;
_rsvg_node_text_type_children (self, ctx, &x, &y, &lastwasspace);
}
| 0 |
[] |
librsvg
|
34c95743ca692ea0e44778e41a7c0a129363de84
| 14,368,112,653,973,482,000,000,000,000,000,000,000 | 24 |
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
|
crypt_token_info crypt_token_status(struct crypt_device *cd, int token, const char **type)
{
if (_onlyLUKS2(cd, CRYPT_CD_QUIET | CRYPT_CD_UNRESTRICTED, 0))
return CRYPT_TOKEN_INVALID;
return LUKS2_token_status(cd, &cd->u.luks2.hdr, token, type);
}
| 0 |
[
"CWE-345"
] |
cryptsetup
|
0113ac2d889c5322659ad0596d4cfc6da53e356c
| 292,091,401,268,017,100,000,000,000,000,000,000,000 | 7 |
Fix CVE-2021-4122 - LUKS2 reencryption crash recovery attack
Fix possible attacks against data confidentiality through LUKS2 online
reencryption extension crash recovery.
An attacker can modify on-disk metadata to simulate decryption in
progress with crashed (unfinished) reencryption step and persistently
decrypt part of the LUKS device.
This attack requires repeated physical access to the LUKS device but
no knowledge of user passphrases.
The decryption step is performed after a valid user activates
the device with a correct passphrase and modified metadata.
There are no visible warnings for the user that such recovery happened
(except using the luksDump command). The attack can also be reversed
afterward (simulating crashed encryption from a plaintext) with
possible modification of revealed plaintext.
The problem was caused by reusing a mechanism designed for actual
reencryption operation without reassessing the security impact for new
encryption and decryption operations. While the reencryption requires
calculating and verifying both key digests, no digest was needed to
initiate decryption recovery if the destination is plaintext (no
encryption key). Also, some metadata (like encryption cipher) is not
protected, and an attacker could change it. Note that LUKS2 protects
visible metadata only when a random change occurs. It does not protect
against intentional modification but such modification must not cause
a violation of data confidentiality.
The fix introduces additional digest protection of reencryption
metadata. The digest is calculated from known keys and critical
reencryption metadata. Now an attacker cannot create correct metadata
digest without knowledge of a passphrase for used keyslots.
For more details, see LUKS2 On-Disk Format Specification version 1.1.0.
|
static inline void init_sd_lb_stats(struct sd_lb_stats *sds)
{
/*
* Skimp on the clearing to avoid duplicate work. We can avoid clearing
* local_stat because update_sg_lb_stats() does a full clear/assignment.
* We must however clear busiest_stat::avg_load because
* update_sd_pick_busiest() reads this before assignment.
*/
*sds = (struct sd_lb_stats){
.busiest = NULL,
.local = NULL,
.total_running = 0UL,
.total_load = 0UL,
.total_capacity = 0UL,
.busiest_stat = {
.avg_load = 0UL,
.sum_nr_running = 0,
.group_type = group_other,
},
};
}
| 0 |
[
"CWE-400",
"CWE-703",
"CWE-835"
] |
linux
|
c40f7d74c741a907cfaeb73a7697081881c497d0
| 339,638,374,231,487,540,000,000,000,000,000,000,000 | 21 |
sched/fair: Fix infinite loop in update_blocked_averages() by reverting a9e7f6544b9c
Zhipeng Xie, Xie XiuQi and Sargun Dhillon reported lockups in the
scheduler under high loads, starting at around the v4.18 time frame,
and Zhipeng Xie tracked it down to bugs in the rq->leaf_cfs_rq_list
manipulation.
Do a (manual) revert of:
a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path")
It turns out that the list_del_leaf_cfs_rq() introduced by this commit
is a surprising property that was not considered in followup commits
such as:
9c2791f936ef ("sched/fair: Fix hierarchical order in rq->leaf_cfs_rq_list")
As Vincent Guittot explains:
"I think that there is a bigger problem with commit a9e7f6544b9c and
cfs_rq throttling:
Let take the example of the following topology TG2 --> TG1 --> root:
1) The 1st time a task is enqueued, we will add TG2 cfs_rq then TG1
cfs_rq to leaf_cfs_rq_list and we are sure to do the whole branch in
one path because it has never been used and can't be throttled so
tmp_alone_branch will point to leaf_cfs_rq_list at the end.
2) Then TG1 is throttled
3) and we add TG3 as a new child of TG1.
4) The 1st enqueue of a task on TG3 will add TG3 cfs_rq just before TG1
cfs_rq and tmp_alone_branch will stay on rq->leaf_cfs_rq_list.
With commit a9e7f6544b9c, we can del a cfs_rq from rq->leaf_cfs_rq_list.
So if the load of TG1 cfs_rq becomes NULL before step 2) above, TG1
cfs_rq is removed from the list.
Then at step 4), TG3 cfs_rq is added at the beginning of rq->leaf_cfs_rq_list
but tmp_alone_branch still points to TG3 cfs_rq because its throttled
parent can't be enqueued when the lock is released.
tmp_alone_branch doesn't point to rq->leaf_cfs_rq_list whereas it should.
So if TG3 cfs_rq is removed or destroyed before tmp_alone_branch
points on another TG cfs_rq, the next TG cfs_rq that will be added,
will be linked outside rq->leaf_cfs_rq_list - which is bad.
In addition, we can break the ordering of the cfs_rq in
rq->leaf_cfs_rq_list but this ordering is used to update and
propagate the update from leaf down to root."
Instead of trying to work through all these cases and trying to reproduce
the very high loads that produced the lockup to begin with, simplify
the code temporarily by reverting a9e7f6544b9c - which change was clearly
not thought through completely.
This (hopefully) gives us a kernel that doesn't lock up so people
can continue to enjoy their holidays without worrying about regressions. ;-)
[ mingo: Wrote changelog, fixed weird spelling in code comment while at it. ]
Analyzed-by: Xie XiuQi <[email protected]>
Analyzed-by: Vincent Guittot <[email protected]>
Reported-by: Zhipeng Xie <[email protected]>
Reported-by: Sargun Dhillon <[email protected]>
Reported-by: Xie XiuQi <[email protected]>
Tested-by: Zhipeng Xie <[email protected]>
Tested-by: Sargun Dhillon <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Acked-by: Vincent Guittot <[email protected]>
Cc: <[email protected]> # v4.13+
Cc: Bin Li <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Fixes: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
|
static int proc_setconfig(struct usb_dev_state *ps, void __user *arg)
{
int u;
int status = 0;
struct usb_host_config *actconfig;
if (get_user(u, (int __user *)arg))
return -EFAULT;
actconfig = ps->dev->actconfig;
/* Don't touch the device if any interfaces are claimed.
* It could interfere with other drivers' operations, and if
* an interface is claimed by usbfs it could easily deadlock.
*/
if (actconfig) {
int i;
for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) {
if (usb_interface_claimed(actconfig->interface[i])) {
dev_warn(&ps->dev->dev,
"usbfs: interface %d claimed by %s "
"while '%s' sets config #%d\n",
actconfig->interface[i]
->cur_altsetting
->desc.bInterfaceNumber,
actconfig->interface[i]
->dev.driver->name,
current->comm, u);
status = -EBUSY;
break;
}
}
}
/* SET_CONFIGURATION is often abused as a "cheap" driver reset,
* so avoid usb_set_configuration()'s kick to sysfs
*/
if (status == 0) {
if (actconfig && actconfig->desc.bConfigurationValue == u)
status = usb_reset_configuration(ps->dev);
else
status = usb_set_configuration(ps->dev, u);
}
return status;
}
| 0 |
[
"CWE-200"
] |
linux
|
681fef8380eb818c0b845fca5d2ab1dcbab114ee
| 319,063,118,680,770,140,000,000,000,000,000,000,000 | 47 |
USB: usbfs: fix potential infoleak in devio
The stack object “ci” has a total size of 8 bytes. Its last 3 bytes
are padding bytes which are not initialized and leaked to userland
via “copy_to_user”.
Signed-off-by: Kangjie Lu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg)
{
struct tcm_loop_tpg *tl_tpg =
(struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
/*
* Return the passed NAA identifier for the SAS Target Port
*/
return &tl_tpg->tl_hba->tl_wwn_address[0];
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
linux
|
12f09ccb4612734a53e47ed5302e0479c10a50f8
| 143,702,272,752,972,360,000,000,000,000,000,000,000 | 9 |
loopback: off by one in tcm_loop_make_naa_tpg()
This is an off by one 'tgpt' check in tcm_loop_make_naa_tpg() that could result
in memory corruption.
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Nicholas A. Bellinger <[email protected]>
|
static void nvme_zone_reset_cb(void *opaque, int ret)
{
NvmeZoneResetAIOCB *iocb = opaque;
NvmeRequest *req = iocb->req;
NvmeNamespace *ns = req->ns;
if (ret < 0) {
iocb->ret = ret;
goto done;
}
if (iocb->zone) {
nvme_zrm_reset(ns, iocb->zone);
if (!iocb->all) {
goto done;
}
}
while (iocb->idx < ns->num_zones) {
NvmeZone *zone = &ns->zone_array[iocb->idx++];
switch (nvme_get_zone_state(zone)) {
case NVME_ZONE_STATE_EMPTY:
if (!iocb->all) {
goto done;
}
continue;
case NVME_ZONE_STATE_EXPLICITLY_OPEN:
case NVME_ZONE_STATE_IMPLICITLY_OPEN:
case NVME_ZONE_STATE_CLOSED:
case NVME_ZONE_STATE_FULL:
iocb->zone = zone;
break;
default:
continue;
}
trace_pci_nvme_zns_zone_reset(zone->d.zslba);
iocb->aiocb = blk_aio_pwrite_zeroes(ns->blkconf.blk,
nvme_l2b(ns, zone->d.zslba),
nvme_l2b(ns, ns->zone_size),
BDRV_REQ_MAY_UNMAP,
nvme_zone_reset_epilogue_cb,
iocb);
return;
}
done:
iocb->aiocb = NULL;
if (iocb->bh) {
qemu_bh_schedule(iocb->bh);
}
}
| 0 |
[] |
qemu
|
736b01642d85be832385063f278fe7cd4ffb5221
| 70,673,788,413,442,750,000,000,000,000,000,000,000 | 58 |
hw/nvme: fix CVE-2021-3929
This fixes CVE-2021-3929 "locally" by denying DMA to the iomem of the
device itself. This still allows DMA to MMIO regions of other devices
(e.g. doing P2P DMA to the controller memory buffer of another NVMe
device).
Fixes: CVE-2021-3929
Reported-by: Qiuhao Li <[email protected]>
Reviewed-by: Keith Busch <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]>
|
buflist_new(
char_u *ffname_arg, // full path of fname or relative
char_u *sfname_arg, // short fname or NULL
linenr_T lnum, // preferred cursor line
int flags) // BLN_ defines
{
char_u *ffname = ffname_arg;
char_u *sfname = sfname_arg;
buf_T *buf;
#ifdef UNIX
stat_T st;
#endif
if (top_file_num == 1)
hash_init(&buf_hashtab);
fname_expand(curbuf, &ffname, &sfname); // will allocate ffname
/*
* If the file name already exists in the list, update the entry.
*/
#ifdef UNIX
// On Unix we can use inode numbers when the file exists. Works better
// for hard links.
if (sfname == NULL || mch_stat((char *)sfname, &st) < 0)
st.st_dev = (dev_T)-1;
#endif
if (ffname != NULL && !(flags & (BLN_DUMMY | BLN_NEW)) && (buf =
#ifdef UNIX
buflist_findname_stat(ffname, &st)
#else
buflist_findname(ffname)
#endif
) != NULL)
{
vim_free(ffname);
if (lnum != 0)
buflist_setfpos(buf, (flags & BLN_NOCURWIN) ? NULL : curwin,
lnum, (colnr_T)0, FALSE);
if ((flags & BLN_NOOPT) == 0)
// copy the options now, if 'cpo' doesn't have 's' and not done
// already
buf_copy_options(buf, 0);
if ((flags & BLN_LISTED) && !buf->b_p_bl)
{
bufref_T bufref;
buf->b_p_bl = TRUE;
set_bufref(&bufref, buf);
if (!(flags & BLN_DUMMY))
{
if (apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, buf)
&& !bufref_valid(&bufref))
return NULL;
}
}
return buf;
}
/*
* If the current buffer has no name and no contents, use the current
* buffer. Otherwise: Need to allocate a new buffer structure.
*
* This is the ONLY place where a new buffer structure is allocated!
* (A spell file buffer is allocated in spell.c, but that's not a normal
* buffer.)
*/
buf = NULL;
if ((flags & BLN_CURBUF) && curbuf_reusable())
{
buf = curbuf;
// It's like this buffer is deleted. Watch out for autocommands that
// change curbuf! If that happens, allocate a new buffer anyway.
if (curbuf->b_p_bl)
apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
if (buf == curbuf)
apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
{
vim_free(ffname);
return NULL;
}
#endif
if (buf == curbuf)
{
// Make sure 'bufhidden' and 'buftype' are empty
clear_string_option(&buf->b_p_bh);
clear_string_option(&buf->b_p_bt);
}
}
if (buf != curbuf || curbuf == NULL)
{
buf = ALLOC_CLEAR_ONE(buf_T);
if (buf == NULL)
{
vim_free(ffname);
return NULL;
}
#ifdef FEAT_EVAL
// init b: variables
buf->b_vars = dict_alloc();
if (buf->b_vars == NULL)
{
vim_free(ffname);
vim_free(buf);
return NULL;
}
init_var_dict(buf->b_vars, &buf->b_bufvar, VAR_SCOPE);
#endif
init_changedtick(buf);
}
if (ffname != NULL)
{
buf->b_ffname = ffname;
buf->b_sfname = vim_strsave(sfname);
}
clear_wininfo(buf);
buf->b_wininfo = ALLOC_CLEAR_ONE(wininfo_T);
if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL))
|| buf->b_wininfo == NULL)
{
if (buf->b_sfname != buf->b_ffname)
VIM_CLEAR(buf->b_sfname);
else
buf->b_sfname = NULL;
VIM_CLEAR(buf->b_ffname);
if (buf != curbuf)
free_buffer(buf);
return NULL;
}
if (buf == curbuf)
{
// free all things allocated for this buffer
buf_freeall(buf, 0);
if (buf != curbuf) // autocommands deleted the buffer!
return NULL;
#if defined(FEAT_EVAL)
if (aborting()) // autocmds may abort script processing
return NULL;
#endif
free_buffer_stuff(buf, FALSE); // delete local variables et al.
// Init the options.
buf->b_p_initialized = FALSE;
buf_copy_options(buf, BCO_ENTER);
#ifdef FEAT_KEYMAP
// need to reload lmaps and set b:keymap_name
curbuf->b_kmap_state |= KEYMAP_INIT;
#endif
}
else
{
// put the new buffer at the end of the buffer list
buf->b_next = NULL;
if (firstbuf == NULL) // buffer list is empty
{
buf->b_prev = NULL;
firstbuf = buf;
}
else // append new buffer at end of list
{
lastbuf->b_next = buf;
buf->b_prev = lastbuf;
}
lastbuf = buf;
if ((flags & BLN_REUSE) && buf_reuse.ga_len > 0)
{
// Recycle a previously used buffer number. Used for buffers which
// are normally hidden, e.g. in a popup window. Avoids that the
// buffer number grows rapidly.
--buf_reuse.ga_len;
buf->b_fnum = ((int *)buf_reuse.ga_data)[buf_reuse.ga_len];
// Move buffer to the right place in the buffer list.
while (buf->b_prev != NULL && buf->b_fnum < buf->b_prev->b_fnum)
{
buf_T *prev = buf->b_prev;
prev->b_next = buf->b_next;
if (prev->b_next != NULL)
prev->b_next->b_prev = prev;
buf->b_next = prev;
buf->b_prev = prev->b_prev;
if (buf->b_prev != NULL)
buf->b_prev->b_next = buf;
prev->b_prev = buf;
if (lastbuf == buf)
lastbuf = prev;
if (firstbuf == prev)
firstbuf = buf;
}
}
else
buf->b_fnum = top_file_num++;
if (top_file_num < 0) // wrap around (may cause duplicates)
{
emsg(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0 && !in_assert_fails)
{
out_flush();
ui_delay(3001L, TRUE); // make sure it is noticed
}
top_file_num = 1;
}
buf_hashtab_add(buf);
// Always copy the options from the current buffer.
buf_copy_options(buf, BCO_ALWAYS);
}
buf->b_wininfo->wi_fpos.lnum = lnum;
buf->b_wininfo->wi_win = curwin;
#ifdef FEAT_SYN_HL
hash_init(&buf->b_s.b_keywtab);
hash_init(&buf->b_s.b_keywtab_ic);
#endif
buf->b_fname = buf->b_sfname;
#ifdef UNIX
if (st.st_dev == (dev_T)-1)
buf->b_dev_valid = FALSE;
else
{
buf->b_dev_valid = TRUE;
buf->b_dev = st.st_dev;
buf->b_ino = st.st_ino;
}
#endif
buf->b_u_synced = TRUE;
buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED;
if (flags & BLN_DUMMY)
buf->b_flags |= BF_DUMMY;
buf_clear_file(buf);
clrallmarks(buf); // clear marks
fmarks_check_names(buf); // check file marks for this file
buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; // init 'buflisted'
if (!(flags & BLN_DUMMY))
{
bufref_T bufref;
// Tricky: these autocommands may change the buffer list. They could
// also split the window with re-using the one empty buffer. This may
// result in unexpectedly losing the empty buffer.
set_bufref(&bufref, buf);
if (apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf)
&& !bufref_valid(&bufref))
return NULL;
if (flags & BLN_LISTED)
{
if (apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, buf)
&& !bufref_valid(&bufref))
return NULL;
}
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing
return NULL;
#endif
}
return buf;
}
| 0 |
[
"CWE-416"
] |
vim
|
9b4a80a66544f2782040b641498754bcb5b8d461
| 33,623,469,486,996,893,000,000,000,000,000,000,000 | 271 |
patch 8.2.4281: using freed memory with :lopen and :bwipe
Problem: Using freed memory with :lopen and :bwipe.
Solution: Do not use a wiped out buffer.
|
int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
{
struct ext4_iloc iloc;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
int err;
might_sleep();
trace_ext4_mark_inode_dirty(inode, _RET_IP_);
err = ext4_reserve_inode_write(handle, inode, &iloc);
if (err)
return err;
if (EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize)
ext4_try_to_expand_extra_isize(inode, sbi->s_want_extra_isize,
iloc, handle);
return ext4_mark_iloc_dirty(handle, inode, &iloc);
}
| 0 |
[] |
linux
|
8e4b5eae5decd9dfe5a4ee369c22028f90ab4c44
| 184,374,461,210,892,270,000,000,000,000,000,000,000 | 18 |
ext4: fail ext4_iget for root directory if unallocated
If the root directory has an i_links_count of zero, then when the file
system is mounted, then when ext4_fill_super() notices the problem and
tries to call iput() the root directory in the error return path,
ext4_evict_inode() will try to free the inode on disk, before all of
the file system structures are set up, and this will result in an OOPS
caused by a NULL pointer dereference.
This issue has been assigned CVE-2018-1092.
https://bugzilla.kernel.org/show_bug.cgi?id=199179
https://bugzilla.redhat.com/show_bug.cgi?id=1560777
Reported-by: Wen Xu <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
Cc: [email protected]
|
GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_kind_global(size_t lb, int k)
{
void *op;
void **opp;
size_t lg;
DCL_LOCK_STATE;
GC_ASSERT(k < MAXOBJKINDS);
if (SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
LOCK();
opp = &GC_obj_kinds[k].ok_freelist[lg];
op = *opp;
if (EXPECT(op != NULL, TRUE)) {
if (k == PTRFREE) {
*opp = obj_link(op);
} else {
GC_ASSERT(0 == obj_link(op)
|| ((word)obj_link(op)
<= (word)GC_greatest_plausible_heap_addr
&& (word)obj_link(op)
>= (word)GC_least_plausible_heap_addr));
*opp = obj_link(op);
obj_link(op) = 0;
}
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
return op;
}
UNLOCK();
}
return GENERAL_MALLOC(lb, k);
}
| 0 |
[
"CWE-119"
] |
bdwgc
|
7292c02fac2066d39dd1bcc37d1a7054fd1e32ee
| 200,396,279,595,537,400,000,000,000,000,000,000,000 | 34 |
Fix malloc routines to prevent size value wrap-around
See issue #135 on Github.
* allchblk.c (GC_allochblk, GC_allochblk_nth): Use
OBJ_SZ_TO_BLOCKS_CHECKED instead of OBJ_SZ_TO_BLOCKS.
* malloc.c (GC_alloc_large): Likewise.
* alloc.c (GC_expand_hp_inner): Type of "bytes" local variable changed
from word to size_t; cast ROUNDUP_PAGESIZE argument to size_t; prevent
overflow when computing GC_heapsize+bytes > GC_max_heapsize.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable):
Use SIZET_SAT_ADD (instead of "+" operator) to add extra bytes to lb
value.
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* gcj_mlc.c (GC_debug_gcj_malloc): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Likewise.
* include/private/gcconfig.h (GET_MEM): Likewise.
* mallocx.c (GC_malloc_many, GC_memalign): Likewise.
* os_dep.c (GC_wince_get_mem, GC_win32_get_mem): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Likewise.
* headers.c (GC_scratch_alloc): Change type of bytes_to_get from word
to size_t (because ROUNDUP_PAGESIZE_IF_MMAP result type changed).
* include/private/gc_priv.h: Include limits.h (unless SIZE_MAX already
defined).
* include/private/gc_priv.h (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Move from
malloc.c file.
* include/private/gc_priv.h (SIZET_SAT_ADD): New macro (defined before
include gcconfig.h).
* include/private/gc_priv.h (EXTRA_BYTES, GC_page_size): Change type
to size_t.
* os_dep.c (GC_page_size): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, ROUNDUP_PAGESIZE): Add comment about the argument.
* include/private/gcconfig.h (GET_MEM): Likewise.
* include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES,
ADD_SLOP, OBJ_SZ_TO_BLOCKS, ROUNDUP_PAGESIZE,
ROUNDUP_PAGESIZE_IF_MMAP): Rename argument to "lb".
* include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): New macro.
* include/private/gcconfig.h (GC_win32_get_mem, GC_wince_get_mem,
GC_unix_get_mem): Change argument type from word to int.
* os_dep.c (GC_unix_mmap_get_mem, GC_unix_get_mem,
GC_unix_sbrk_get_mem, GC_wince_get_mem, GC_win32_get_mem): Likewise.
* malloc.c (GC_alloc_large_and_clear): Call OBJ_SZ_TO_BLOCKS only
if no value wrap around is guaranteed.
* malloc.c (GC_generic_malloc): Do not check for lb_rounded < lb case
(because ROUNDED_UP_GRANULES and GRANULES_TO_BYTES guarantees no value
wrap around).
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* misc.c (GC_init_size_map): Change "i" local variable type from int
to size_t.
* os_dep.c (GC_write_fault_handler, catch_exception_raise): Likewise.
* misc.c (GC_envfile_init): Cast len to size_t when passed to
ROUNDUP_PAGESIZE_IF_MMAP.
* os_dep.c (GC_setpagesize): Cast GC_sysinfo.dwPageSize and
GETPAGESIZE() to size_t (when setting GC_page_size).
* os_dep.c (GC_unix_mmap_get_mem, GC_unmap_start, GC_remove_protection):
Expand ROUNDUP_PAGESIZE macro but without value wrap-around checking
(the argument is of word type).
* os_dep.c (GC_unix_mmap_get_mem): Replace -GC_page_size with
~GC_page_size+1 (because GC_page_size is unsigned); remove redundant
cast to size_t.
* os_dep.c (GC_unix_sbrk_get_mem): Add explicit cast of GC_page_size
to SBRK_ARG_T.
* os_dep.c (GC_wince_get_mem): Change type of res_bytes local variable
to size_t.
* typd_mlc.c: Do not include limits.h.
* typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Remove (as defined in
gc_priv.h now).
|
static int get_client_master_key(SSL *s)
{
int is_export, i, n, keya, ek;
unsigned long len;
unsigned char *p;
const SSL_CIPHER *cp;
const EVP_CIPHER *c;
const EVP_MD *md;
p = (unsigned char *)s->init_buf->data;
if (s->state == SSL2_ST_GET_CLIENT_MASTER_KEY_A) {
i = ssl2_read(s, (char *)&(p[s->init_num]), 10 - s->init_num);
if (i < (10 - s->init_num))
return (ssl2_part_read(s, SSL_F_GET_CLIENT_MASTER_KEY, i));
s->init_num = 10;
if (*(p++) != SSL2_MT_CLIENT_MASTER_KEY) {
if (p[-1] != SSL2_MT_ERROR) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,
SSL_R_READ_WRONG_PACKET_TYPE);
} else
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_PEER_ERROR);
return (-1);
}
cp = ssl2_get_cipher_by_char(p);
if (cp == NULL) {
ssl2_return_error(s, SSL2_PE_NO_CIPHER);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_NO_CIPHER_MATCH);
return (-1);
}
s->session->cipher = cp;
p += 3;
n2s(p, i);
s->s2->tmp.clear = i;
n2s(p, i);
s->s2->tmp.enc = i;
n2s(p, i);
if (i > SSL_MAX_KEY_ARG_LENGTH) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_KEY_ARG_TOO_LONG);
return -1;
}
s->session->key_arg_length = i;
s->state = SSL2_ST_GET_CLIENT_MASTER_KEY_B;
}
/* SSL2_ST_GET_CLIENT_MASTER_KEY_B */
p = (unsigned char *)s->init_buf->data;
if (s->init_buf->length < SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, ERR_R_INTERNAL_ERROR);
return -1;
}
keya = s->session->key_arg_length;
len =
10 + (unsigned long)s->s2->tmp.clear + (unsigned long)s->s2->tmp.enc +
(unsigned long)keya;
if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_MESSAGE_TOO_LONG);
return -1;
}
n = (int)len - s->init_num;
i = ssl2_read(s, (char *)&(p[s->init_num]), n);
if (i != n)
return (ssl2_part_read(s, SSL_F_GET_CLIENT_MASTER_KEY, i));
if (s->msg_callback) {
/* CLIENT-MASTER-KEY */
s->msg_callback(0, s->version, 0, p, (size_t)len, s,
s->msg_callback_arg);
}
p += 10;
memcpy(s->session->key_arg, &(p[s->s2->tmp.clear + s->s2->tmp.enc]),
(unsigned int)keya);
if (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_NO_PRIVATEKEY);
return (-1);
}
i = ssl_rsa_private_decrypt(s->cert, s->s2->tmp.enc,
&(p[s->s2->tmp.clear]),
&(p[s->s2->tmp.clear]),
(s->s2->ssl2_rollback) ? RSA_SSLV23_PADDING :
RSA_PKCS1_PADDING);
is_export = SSL_C_IS_EXPORT(s->session->cipher);
if (!ssl_cipher_get_evp(s->session, &c, &md, NULL, NULL, NULL)) {
ssl2_return_error(s, SSL2_PE_NO_CIPHER);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,
SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS);
return (0);
}
if (s->session->cipher->algorithm2 & SSL2_CF_8_BYTE_ENC) {
is_export = 1;
ek = 8;
} else
ek = 5;
/* bad decrypt */
# if 1
/*
* If a bad decrypt, continue with protocol but with a random master
* secret (Bleichenbacher attack)
*/
if ((i < 0) || ((!is_export && (i != EVP_CIPHER_key_length(c)))
|| (is_export && ((i != ek)
|| (s->s2->tmp.clear +
(unsigned int)i != (unsigned int)
EVP_CIPHER_key_length(c)))))) {
ERR_clear_error();
if (is_export)
i = ek;
else
i = EVP_CIPHER_key_length(c);
if (RAND_pseudo_bytes(p, i) <= 0)
return 0;
}
# else
if (i < 0) {
error = 1;
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_BAD_RSA_DECRYPT);
}
/* incorrect number of key bytes for non export cipher */
else if ((!is_export && (i != EVP_CIPHER_key_length(c)))
|| (is_export && ((i != ek) || (s->s2->tmp.clear + i !=
EVP_CIPHER_key_length(c))))) {
error = 1;
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_WRONG_NUMBER_OF_KEY_BITS);
}
if (error) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
return (-1);
}
# endif
if (is_export)
i += s->s2->tmp.clear;
if (i > SSL_MAX_MASTER_KEY_LENGTH) {
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);
SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, ERR_R_INTERNAL_ERROR);
return -1;
}
s->session->master_key_length = i;
memcpy(s->session->master_key, p, (unsigned int)i);
return (1);
}
| 1 |
[
"CWE-20"
] |
openssl
|
86f8fb0e344d62454f8daf3e15236b2b59210756
| 170,603,313,163,069,730,000,000,000,000,000,000,000 | 155 |
Fix reachable assert in SSLv2 servers.
This assert is reachable for servers that support SSLv2 and export ciphers.
Therefore, such servers can be DoSed by sending a specially crafted
SSLv2 CLIENT-MASTER-KEY.
Also fix s2_srvr.c to error out early if the key lengths are malformed.
These lengths are sent unencrypted, so this does not introduce an oracle.
CVE-2015-0293
This issue was discovered by Sean Burford (Google) and Emilia Käsper of
the OpenSSL development team.
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
|
void exec_command_free_array(ExecCommand **c, size_t n) {
size_t i;
for (i = 0; i < n; i++)
c[i] = exec_command_free_list(c[i]);
}
| 0 |
[
"CWE-269"
] |
systemd
|
f69567cbe26d09eac9d387c0be0fc32c65a83ada
| 97,044,175,612,723,320,000,000,000,000,000,000,000 | 6 |
core: expose SUID/SGID restriction as new unit setting RestrictSUIDSGID=
|
local_scan_crash_handler(int sig)
{
log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() function crashed with "
"signal %d - message temporarily rejected (size %d)", sig, message_size);
/* Does not return */
receive_bomb_out(US"local-scan-error", US"local verification problem");
}
| 0 |
[
"CWE-416"
] |
exim
|
4e6ae6235c68de243b1c2419027472d7659aa2b4
| 322,259,861,264,450,700,000,000,000,000,000,000,000 | 7 |
Avoid release of store if there have been later allocations. Bug 2199
|
u32 parse_dashlive(char *arg, char *arg_val, u32 opt)
{
dash_mode = opt ? GF_DASH_DYNAMIC_DEBUG : GF_DASH_DYNAMIC;
dash_live = 1;
if (arg[10] == '=') {
dash_ctx_file = arg + 11;
}
dash_duration = atof(arg_val);
return 0;
| 0 |
[
"CWE-787"
] |
gpac
|
4e56ad72ac1afb4e049a10f2d99e7512d7141f9d
| 134,823,821,549,362,270,000,000,000,000,000,000,000 | 10 |
fixed #2216
|
void display_progress (double file_progress)
{
char title [40];
if (set_console_title) {
file_progress = (file_index + file_progress) / num_files;
sprintf (title, "%d%% (WvUnpack)", (int) ((file_progress * 100.0) + 0.5));
DoSetConsoleTitle (title);
}
}
| 0 |
[
"CWE-476",
"CWE-703"
] |
WavPack
|
25b4a2725d8568212e7cf89ca05ca29d128af7ac
| 289,377,437,645,718,840,000,000,000,000,000,000,000 | 10 |
issue #121: NULL pointer dereference in wvunpack.c
* check for NULL pointer before dereferencing in wvunpack.c
* sanitize custom extensions to be alphanumeric only
|
static int exif_scan_thumbnail(image_info_type *ImageInfo)
{
uchar c, *data = (uchar*)ImageInfo->Thumbnail.data;
int n, marker;
size_t length=2, pos=0;
jpeg_sof_info sof_info;
if (!data) {
return FALSE; /* nothing to do here */
}
if (memcmp(data, "\xFF\xD8\xFF", 3)) {
if (!ImageInfo->Thumbnail.width && !ImageInfo->Thumbnail.height) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Thumbnail is not a JPEG image");
}
return FALSE;
}
for (;;) {
pos += length;
if (pos>=ImageInfo->Thumbnail.size)
return FALSE;
c = data[pos++];
if (pos>=ImageInfo->Thumbnail.size)
return FALSE;
if (c != 0xFF) {
return FALSE;
}
n = 8;
while ((c = data[pos++]) == 0xFF && n--) {
if (pos+3>=ImageInfo->Thumbnail.size)
return FALSE;
/* +3 = pos++ of next check when reaching marker + 2 bytes for length */
}
if (c == 0xFF)
return FALSE;
marker = c;
if (pos>=ImageInfo->Thumbnail.size)
return FALSE;
length = php_jpg_get16(data+pos);
if (length > ImageInfo->Thumbnail.size || pos >= ImageInfo->Thumbnail.size - length) {
return FALSE;
}
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: process section(x%02X=%s) @ x%04X + x%04X", marker, exif_get_markername(marker), pos, length);
#endif
switch (marker) {
case M_SOF0:
case M_SOF1:
case M_SOF2:
case M_SOF3:
case M_SOF5:
case M_SOF6:
case M_SOF7:
case M_SOF9:
case M_SOF10:
case M_SOF11:
case M_SOF13:
case M_SOF14:
case M_SOF15:
/* handle SOFn block */
if (length < 8 || ImageInfo->Thumbnail.size - 8 < pos) {
/* exif_process_SOFn needs 8 bytes */
return FALSE;
}
exif_process_SOFn(data+pos, marker, &sof_info);
ImageInfo->Thumbnail.height = sof_info.height;
ImageInfo->Thumbnail.width = sof_info.width;
#ifdef EXIF_DEBUG
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Thumbnail: size: %d * %d", sof_info.width, sof_info.height);
#endif
return TRUE;
case M_SOS:
case M_EOI:
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail");
return FALSE;
break;
default:
/* just skip */
break;
}
}
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Could not compute size of thumbnail");
return FALSE;
}
| 1 |
[
"CWE-125"
] |
php-src
|
f22101c8308669bb63c03a73a2cac2408d844f38
| 84,288,978,238,803,080,000,000,000,000,000,000,000 | 86 |
Fix bug #78222 (heap-buffer-overflow on exif_scan_thumbnail)
(cherry picked from commit dea2989ab8ba87a6180af497b2efaf0527e985c5)
|
static inline struct crypto_instance *shash_crypto_instance(
struct shash_instance *inst)
{
return container_of(&inst->alg.base, struct crypto_instance, alg);
}
| 0 |
[
"CWE-835"
] |
linux
|
ef0579b64e93188710d48667cb5e014926af9f1b
| 226,592,700,557,769,360,000,000,000,000,000,000,000 | 5 |
crypto: ahash - Fix EINPROGRESS notification callback
The ahash API modifies the request's callback function in order
to clean up after itself in some corner cases (unaligned final
and missing finup).
When the request is complete ahash will restore the original
callback and everything is fine. However, when the request gets
an EBUSY on a full queue, an EINPROGRESS callback is made while
the request is still ongoing.
In this case the ahash API will incorrectly call its own callback.
This patch fixes the problem by creating a temporary request
object on the stack which is used to relay EINPROGRESS back to
the original completion function.
This patch also adds code to preserve the original flags value.
Fixes: ab6bf4e5e5e4 ("crypto: hash - Fix the pointer voodoo in...")
Cc: <[email protected]>
Reported-by: Sabrina Dubroca <[email protected]>
Tested-by: Sabrina Dubroca <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
|
propagate_context_across_jump_function (cgraph_edge *cs,
ipa_jump_func *jfunc, int idx,
ipcp_lattice<ipa_polymorphic_call_context> *dest_lat)
{
ipa_edge_args *args = IPA_EDGE_REF (cs);
if (dest_lat->bottom)
return false;
bool ret = false;
bool added_sth = false;
bool type_preserved = true;
ipa_polymorphic_call_context edge_ctx, *edge_ctx_ptr
= ipa_get_ith_polymorhic_call_context (args, idx);
if (edge_ctx_ptr)
edge_ctx = *edge_ctx_ptr;
if (jfunc->type == IPA_JF_PASS_THROUGH
|| jfunc->type == IPA_JF_ANCESTOR)
{
class ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
int src_idx;
ipcp_lattice<ipa_polymorphic_call_context> *src_lat;
/* TODO: Once we figure out how to propagate speculations, it will
probably be a good idea to switch to speculation if type_preserved is
not set instead of punting. */
if (jfunc->type == IPA_JF_PASS_THROUGH)
{
if (ipa_get_jf_pass_through_operation (jfunc) != NOP_EXPR)
goto prop_fail;
type_preserved = ipa_get_jf_pass_through_type_preserved (jfunc);
src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
}
else
{
type_preserved = ipa_get_jf_ancestor_type_preserved (jfunc);
src_idx = ipa_get_jf_ancestor_formal_id (jfunc);
}
src_lat = ipa_get_poly_ctx_lat (caller_info, src_idx);
/* If we would need to clone the caller and cannot, do not propagate. */
if (!ipcp_versionable_function_p (cs->caller)
&& (src_lat->contains_variable
|| (src_lat->values_count > 1)))
goto prop_fail;
ipcp_value<ipa_polymorphic_call_context> *src_val;
for (src_val = src_lat->values; src_val; src_val = src_val->next)
{
ipa_polymorphic_call_context cur = src_val->value;
if (!type_preserved)
cur.possible_dynamic_type_change (cs->in_polymorphic_cdtor);
if (jfunc->type == IPA_JF_ANCESTOR)
cur.offset_by (ipa_get_jf_ancestor_offset (jfunc));
/* TODO: In cases we know how the context is going to be used,
we can improve the result by passing proper OTR_TYPE. */
cur.combine_with (edge_ctx);
if (!cur.useless_p ())
{
if (src_lat->contains_variable
&& !edge_ctx.equal_to (cur))
ret |= dest_lat->set_contains_variable ();
ret |= dest_lat->add_value (cur, cs, src_val, src_idx);
added_sth = true;
}
}
}
prop_fail:
if (!added_sth)
{
if (!edge_ctx.useless_p ())
ret |= dest_lat->add_value (edge_ctx, cs);
else
ret |= dest_lat->set_contains_variable ();
}
return ret;
}
| 0 |
[
"CWE-20"
] |
gcc
|
a09ccc22459c565814f79f96586fe4ad083fe4eb
| 69,034,801,759,301,480,000,000,000,000,000,000,000 | 81 |
Avoid segfault when doing IPA-VRP but not IPA-CP (PR 93015)
2019-12-21 Martin Jambor <[email protected]>
PR ipa/93015
* ipa-cp.c (ipcp_store_vr_results): Check that info exists
testsuite/
* gcc.dg/lto/pr93015_0.c: New test.
From-SVN: r279695
|
void SSL_free(SSL *s)
{
int i;
if(s == NULL)
return;
i=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL);
#ifdef REF_PRINT
REF_PRINT("SSL",s);
#endif
if (i > 0) return;
#ifdef REF_CHECK
if (i < 0)
{
fprintf(stderr,"SSL_free, bad reference count\n");
abort(); /* ok */
}
#endif
if (s->param)
X509_VERIFY_PARAM_free(s->param);
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);
if (s->bbio != NULL)
{
/* If the buffering BIO is in place, pop it off */
if (s->bbio == s->wbio)
{
s->wbio=BIO_pop(s->wbio);
}
BIO_free(s->bbio);
s->bbio=NULL;
}
if (s->rbio != NULL)
BIO_free_all(s->rbio);
if ((s->wbio != NULL) && (s->wbio != s->rbio))
BIO_free_all(s->wbio);
if (s->init_buf != NULL) BUF_MEM_free(s->init_buf);
/* add extra stuff */
if (s->cipher_list != NULL) sk_SSL_CIPHER_free(s->cipher_list);
if (s->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(s->cipher_list_by_id);
/* Make the next call work :-) */
if (s->session != NULL)
{
ssl_clear_bad_session(s);
SSL_SESSION_free(s->session);
}
ssl_clear_cipher_ctx(s);
ssl_clear_hash_ctx(&s->read_hash);
ssl_clear_hash_ctx(&s->write_hash);
if (s->cert != NULL) ssl_cert_free(s->cert);
/* Free up if allocated */
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_hostname)
OPENSSL_free(s->tlsext_hostname);
if (s->initial_ctx) SSL_CTX_free(s->initial_ctx);
#ifndef OPENSSL_NO_EC
if (s->tlsext_ecpointformatlist) OPENSSL_free(s->tlsext_ecpointformatlist);
if (s->tlsext_ellipticcurvelist) OPENSSL_free(s->tlsext_ellipticcurvelist);
#endif /* OPENSSL_NO_EC */
if (s->tlsext_opaque_prf_input) OPENSSL_free(s->tlsext_opaque_prf_input);
if (s->tlsext_ocsp_exts)
sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts,
X509_EXTENSION_free);
if (s->tlsext_ocsp_ids)
sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free);
if (s->tlsext_ocsp_resp)
OPENSSL_free(s->tlsext_ocsp_resp);
#endif
if (s->client_CA != NULL)
sk_X509_NAME_pop_free(s->client_CA,X509_NAME_free);
if (s->method != NULL) s->method->ssl_free(s);
if (s->ctx) SSL_CTX_free(s->ctx);
#ifndef OPENSSL_NO_KRB5
if (s->kssl_ctx != NULL)
kssl_ctx_free(s->kssl_ctx);
#endif /* OPENSSL_NO_KRB5 */
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
if (s->next_proto_negotiated)
OPENSSL_free(s->next_proto_negotiated);
#endif
if (s->srtp_profiles)
sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles);
OPENSSL_free(s);
}
| 0 |
[] |
openssl
|
0ffa49970b9f8ea66b43ce2eb7f8fd523b65bc2c
| 155,612,066,933,196,720,000,000,000,000,000,000,000 | 100 |
Backport support for fixed DH ciphersuites (from HEAD)
|
Subsets and Splits
CWE 416 & 19
The query filters records related to specific CWEs (Common Weakness Enumerations), providing a basic overview of entries with these vulnerabilities but without deeper analysis.
CWE Frequency in Train Set
Counts the occurrences of each CWE (Common Weakness Enumeration) in the dataset, providing a basic distribution but limited insight.