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
static int tg_cfs_schedulable_down(struct task_group *tg, void *data) { struct cfs_schedulable_data *d = data; struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; s64 quota = 0, parent_quota = -1; if (!tg->parent) { quota = RUNTIME_INF; } else { struct cfs_bandwidth *parent_b = &tg->parent->cfs_bandwidth; quota = normalize_cfs_quota(tg, d); parent_quota = parent_b->hierarchical_quota; /* * ensure max(child_quota) <= parent_quota, inherit when no * limit is set */ if (quota == RUNTIME_INF) quota = parent_quota; else if (parent_quota != RUNTIME_INF && quota > parent_quota) return -EINVAL; } cfs_b->hierarchical_quota = quota; return 0; }
0
[ "CWE-119" ]
linux
29d6455178a09e1dc340380c582b13356227e8df
18,949,670,751,942,911,000,000,000,000,000,000,000
27
sched: panic on corrupted stack end Until now, hitting this BUG_ON caused a recursive oops (because oops handling involves do_exit(), which calls into the scheduler, which in turn raises an oops), which caused stuff below the stack to be overwritten until a panic happened (e.g. via an oops in interrupt context, caused by the overwritten CPU index in the thread_info). Just panic directly. Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
QPDF::setOutputStreams(std::ostream* out, std::ostream* err) { this->out_stream = out ? out : &std::cout; this->err_stream = err ? err : &std::cerr; }
0
[ "CWE-399", "CWE-835" ]
qpdf
701b518d5c56a1449825a3a37a716c58e05e1c3e
332,139,909,226,474,880,000,000,000,000,000,000,000
5
Detect recursion loops resolving objects (fixes #51) During parsing of an object, sometimes parts of the object have to be resolved. An example is stream lengths. If such an object directly or indirectly points to the object being parsed, it can cause an infinite loop. Guard against all cases of re-entrant resolution of objects.
dns_run_resolution(struct dns_resolution *resolution) { struct dns_resolvers *resolvers = resolution->resolvers; int query_id, i; /* Avoid sending requests for resolutions that don't yet have an * hostname, ie resolutions linked to servers that do not yet have an * fqdn */ if (!resolution->hostname_dn) return 0; /* Check if a resolution has already been started for this server return * directly to avoid resolution pill up. */ if (resolution->step != RSLV_STEP_NONE) return 0; /* Generates a new query id. We try at most 100 times to find a free * query id */ for (i = 0; i < 100; ++i) { query_id = dns_rnd16(); if (!eb32_lookup(&resolvers->query_ids, query_id)) break; query_id = -1; } if (query_id == -1) { send_log(NULL, LOG_NOTICE, "could not generate a query id for %s, in resolvers %s.\n", resolution->hostname_dn, resolvers->id); return -1; } /* Update resolution parameters */ resolution->query_id = query_id; resolution->qid.key = query_id; resolution->step = RSLV_STEP_RUNNING; resolution->query_type = resolution->prefered_query_type; resolution->try = resolvers->resolve_retries; eb32_insert(&resolvers->query_ids, &resolution->qid); /* Send the DNS query */ resolution->try -= 1; dns_send_query(resolution); return 1; }
0
[ "CWE-125" ]
haproxy
efbbdf72992cd20458259962346044cafd9331c0
10,576,415,072,303,012,000,000,000,000,000,000,000
44
BUG: dns: Prevent out-of-bounds read in dns_validate_dns_response() We need to make sure that the record length is not making us read past the end of the data we received. Before this patch we could for example read the 16 bytes corresponding to an AAAA record from the non-initialized part of the buffer, possibly accessing anything that was left on the stack, or even past the end of the 8193-byte buffer, depending on the value of accepted_payload_size. To be backported to 1.8, probably also 1.7.
__releases(&hb->lock) { __queue_me(q, hb); spin_unlock(&hb->lock); }
0
[ "CWE-190" ]
linux
fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a
211,364,212,340,841,900,000,000,000,000,000,000,000
5
futex: Prevent overflow by strengthen input validation UBSAN reports signed integer overflow in kernel/futex.c: UBSAN: Undefined behaviour in kernel/futex.c:2041:18 signed integer overflow: 0 - -2147483648 cannot be represented in type 'int' Add a sanity check to catch negative values of nr_wake and nr_requeue. Signed-off-by: Li Jinyue <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl_arg) { TABLE_LIST tables; TABLE *table; LEX_STRING dl= *dl_arg; bool error; int argc=orig_argc; char **argv=orig_argv; unsigned long event_class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE] = { MYSQL_AUDIT_GENERAL_CLASSMASK }; DBUG_ENTER("mysql_install_plugin"); tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (!opt_noacl && check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); /* need to open before acquiring LOCK_plugin or it will deadlock */ if (! (table = open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) DBUG_RETURN(TRUE); if (my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL)) { report_error(REPORT_TO_USER, ER_PLUGIN_IS_NOT_LOADED, name->str); DBUG_RETURN(TRUE); } /* Pre-acquire audit plugins for events that may potentially occur during [UN]INSTALL PLUGIN. When audit event is triggered, audit subsystem acquires interested plugins by walking through plugin list. Evidently plugin list iterator protects plugin list by acquiring LOCK_plugin, see plugin_foreach_with_mask(). On the other hand [UN]INSTALL PLUGIN is acquiring LOCK_plugin rather for a long time. When audit event is triggered during [UN]INSTALL PLUGIN, plugin list iterator acquires the same lock (within the same thread) second time. This hack should be removed when LOCK_plugin is fixed so it protects only what it supposed to protect. See also mysql_uninstall_plugin() and initialize_audit_plugin() */ if (mysql_audit_general_enabled()) mysql_audit_acquire_plugins(thd, event_class_mask); mysql_mutex_lock(&LOCK_plugin); error= plugin_add(thd->mem_root, name, &dl, REPORT_TO_USER); if (error) goto err; if (name->str) error= finalize_install(thd, table, name, &argc, argv); else { st_plugin_dl *plugin_dl= plugin_dl_find(&dl); struct st_maria_plugin *plugin; for (plugin= plugin_dl->plugins; plugin->info; plugin++) { LEX_STRING str= { const_cast<char*>(plugin->name), strlen(plugin->name) }; error|= finalize_install(thd, table, &str, &argc, argv); } } if (error) { reap_needed= true; reap_plugins(); } err: global_plugin_version++; mysql_mutex_unlock(&LOCK_plugin); if (argv) free_defaults(argv); DBUG_RETURN(error); WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); }
0
[ "CWE-416" ]
server
c05fd700970ad45735caed3a6f9930d4ce19a3bd
97,846,760,301,658,470,000,000,000,000,000,000,000
86
MDEV-26323 use-after-poison issue of MariaDB server
S3BootScriptSaveMemWrite ( IN S3_BOOT_SCRIPT_LIB_WIDTH Width, IN UINT64 Address, IN UINTN Count, IN VOID *Buffer ) { UINT8 Length; UINT8 *Script; UINT8 WidthInByte; EFI_BOOT_SCRIPT_MEM_WRITE ScriptMemWrite; WidthInByte = (UINT8) (0x01 << (Width & 0x03)); // // Truncation check // if ((Count > MAX_UINT8) || (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_MEM_WRITE))) { return RETURN_OUT_OF_RESOURCES; } Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_WRITE) + (WidthInByte * Count)); Script = S3BootScriptGetEntryAddAddress (Length); if (Script == NULL) { return RETURN_OUT_OF_RESOURCES; } // // Build script data // ScriptMemWrite.OpCode = EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE; ScriptMemWrite.Length = Length; ScriptMemWrite.Width = Width; ScriptMemWrite.Address = Address; ScriptMemWrite.Count = (UINT32) Count; CopyMem ((VOID*)Script, (VOID*)&ScriptMemWrite, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE)); CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count); SyncBootScript (Script); return RETURN_SUCCESS; }
0
[ "CWE-787" ]
edk2
322ac05f8bbc1bce066af1dabd1b70ccdbe28891
3,995,905,604,155,880,400,000,000,000,000,000,000
43
MdeModulePkg/PiDxeS3BootScriptLib: Fix potential numeric truncation (CVE-2019-14563) REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2001 For S3BootScriptLib APIs: S3BootScriptSaveIoWrite S3BootScriptSaveMemWrite S3BootScriptSavePciCfgWrite S3BootScriptSavePciCfg2Write S3BootScriptSaveSmbusExecute S3BootScriptSaveInformation S3BootScriptSaveInformationAsciiString S3BootScriptLabel (happen in S3BootScriptLabelInternal()) possible numeric truncations will happen that may lead to S3 boot script entry with improper size being returned to store the boot script data. This commit will add checks to prevent this kind of issue. Please note that the remaining S3BootScriptLib APIs: S3BootScriptSaveIoReadWrite S3BootScriptSaveMemReadWrite S3BootScriptSavePciCfgReadWrite S3BootScriptSavePciCfg2ReadWrite S3BootScriptSaveStall S3BootScriptSaveDispatch2 S3BootScriptSaveDispatch S3BootScriptSaveMemPoll S3BootScriptSaveIoPoll S3BootScriptSavePciPoll S3BootScriptSavePci2Poll S3BootScriptCloseTable S3BootScriptExecute S3BootScriptMoveLastOpcode S3BootScriptCompare are not affected by such numeric truncation. Signed-off-by: Hao A Wu <[email protected]> Reviewed-by: Laszlo Ersek <[email protected]> Reviewed-by: Eric Dong <[email protected]> Acked-by: Jian J Wang <[email protected]>
long do_mount(const char *dev_name, const char __user *dir_name, const char *type_page, unsigned long flags, void *data_page) { struct path path; int retval = 0; int mnt_flags = 0; /* Discard magic */ if ((flags & MS_MGC_MSK) == MS_MGC_VAL) flags &= ~MS_MGC_MSK; /* Basic sanity checks */ if (data_page) ((char *)data_page)[PAGE_SIZE - 1] = 0; /* ... and get the mountpoint */ retval = user_path(dir_name, &path); if (retval) return retval; retval = security_sb_mount(dev_name, &path, type_page, flags, data_page); if (!retval && !may_mount()) retval = -EPERM; if (!retval && (flags & MS_MANDLOCK) && !may_mandlock()) retval = -EPERM; if (retval) goto dput_out; /* Default to relatime unless overriden */ if (!(flags & MS_NOATIME)) mnt_flags |= MNT_RELATIME; /* Separate the per-mountpoint flags */ if (flags & MS_NOSUID) mnt_flags |= MNT_NOSUID; if (flags & MS_NODEV) mnt_flags |= MNT_NODEV; if (flags & MS_NOEXEC) mnt_flags |= MNT_NOEXEC; if (flags & MS_NOATIME) mnt_flags |= MNT_NOATIME; if (flags & MS_NODIRATIME) mnt_flags |= MNT_NODIRATIME; if (flags & MS_STRICTATIME) mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME); if (flags & MS_RDONLY) mnt_flags |= MNT_READONLY; /* The default atime for remount is preservation */ if ((flags & MS_REMOUNT) && ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME | MS_STRICTATIME)) == 0)) { mnt_flags &= ~MNT_ATIME_MASK; mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK; } flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN | MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT | MS_STRICTATIME); if (flags & MS_REMOUNT) retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags, data_page); else if (flags & MS_BIND) retval = do_loopback(&path, dev_name, flags & MS_REC); else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) retval = do_change_type(&path, flags); else if (flags & MS_MOVE) retval = do_move_mount(&path, dev_name); else retval = do_new_mount(&path, type_page, flags, mnt_flags, dev_name, data_page); dput_out: path_put(&path); return retval; }
0
[ "CWE-400", "CWE-703" ]
linux
d29216842a85c7970c536108e093963f02714498
16,277,836,641,984,010,000,000,000,000,000,000,000
77
mnt: Add a per mount namespace limit on the number of mounts CAI Qian <[email protected]> pointed out that the semantics of shared subtrees make it possible to create an exponentially increasing number of mounts in a mount namespace. mkdir /tmp/1 /tmp/2 mount --make-rshared / for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; done Will create create 2^20 or 1048576 mounts, which is a practical problem as some people have managed to hit this by accident. As such CVE-2016-6213 was assigned. Ian Kent <[email protected]> described the situation for autofs users as follows: > The number of mounts for direct mount maps is usually not very large because of > the way they are implemented, large direct mount maps can have performance > problems. There can be anywhere from a few (likely case a few hundred) to less > than 10000, plus mounts that have been triggered and not yet expired. > > Indirect mounts have one autofs mount at the root plus the number of mounts that > have been triggered and not yet expired. > > The number of autofs indirect map entries can range from a few to the common > case of several thousand and in rare cases up to between 30000 and 50000. I've > not heard of people with maps larger than 50000 entries. > > The larger the number of map entries the greater the possibility for a large > number of active mounts so it's not hard to expect cases of a 1000 or somewhat > more active mounts. So I am setting the default number of mounts allowed per mount namespace at 100,000. This is more than enough for any use case I know of, but small enough to quickly stop an exponential increase in mounts. Which should be perfect to catch misconfigurations and malfunctioning programs. For anyone who needs a higher limit this can be changed by writing to the new /proc/sys/fs/mount-max sysctl. Tested-by: CAI Qian <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
SaveContext* prev() { return prev_; }
0
[ "CWE-20", "CWE-119" ]
node
530af9cb8e700e7596b3ec812bad123c9fa06356
323,354,181,072,966,470,000,000,000,000,000,000,000
1
v8: Interrupts must not mask stack overflow. Backport of https://codereview.chromium.org/339883002
static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) { int error; DEFINE_WAIT_FUNC(wait, receiver_wake_function); prepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); /* Socket errors? */ error = sock_error(sk); if (error) goto out_err; if (!skb_queue_empty(&sk->sk_receive_queue)) goto out; /* Socket shut down? */ if (sk->sk_shutdown & RCV_SHUTDOWN) goto out_noerr; /* Sequenced packets can come disconnected. * If so we report the problem */ error = -ENOTCONN; if (connection_based(sk) && !(sk->sk_state == TCP_ESTABLISHED || sk->sk_state == TCP_LISTEN)) goto out_err; /* handle signals */ if (signal_pending(current)) goto interrupted; error = 0; *timeo_p = schedule_timeout(*timeo_p); out: finish_wait(sk_sleep(sk), &wait); return error; interrupted: error = sock_intr_errno(*timeo_p); out_err: *err = error; goto out; out_noerr: *err = 0; error = 1; goto out; }
0
[]
linux-2.6
77c1090f94d1b0b5186fb13a1b71b47b1343f87f
306,978,949,461,991,930,000,000,000,000,000,000,000
46
net: fix infinite loop in __skb_recv_datagram() Tommi was fuzzing with trinity and reported the following problem : commit 3f518bf745 (datagram: Add offset argument to __skb_recv_datagram) missed that a raw socket receive queue can contain skbs with no payload. We can loop in __skb_recv_datagram() with MSG_PEEK mode, because wait_for_packet() is not prepared to skip these skbs. [ 83.541011] INFO: rcu_sched detected stalls on CPUs/tasks: {} (detected by 0, t=26002 jiffies, g=27673, c=27672, q=75) [ 83.541011] INFO: Stall ended before state dump start [ 108.067010] BUG: soft lockup - CPU#0 stuck for 22s! [trinity-child31:2847] ... [ 108.067010] Call Trace: [ 108.067010] [<ffffffff818cc103>] __skb_recv_datagram+0x1a3/0x3b0 [ 108.067010] [<ffffffff818cc33d>] skb_recv_datagram+0x2d/0x30 [ 108.067010] [<ffffffff819ed43d>] rawv6_recvmsg+0xad/0x240 [ 108.067010] [<ffffffff818c4b04>] sock_common_recvmsg+0x34/0x50 [ 108.067010] [<ffffffff818bc8ec>] sock_recvmsg+0xbc/0xf0 [ 108.067010] [<ffffffff818bf31e>] sys_recvfrom+0xde/0x150 [ 108.067010] [<ffffffff81ca4329>] system_call_fastpath+0x16/0x1b Reported-by: Tommi Rantala <[email protected]> Tested-by: Tommi Rantala <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Pavel Emelyanov <[email protected]> Acked-by: Pavel Emelyanov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void *AcquireLZMAMemory(void *context,size_t items,size_t size) { (void) context; return((void *) AcquireQuantumMemory((size_t) items,(size_t) size)); }
0
[ "CWE-617" ]
ImageMagick
5d95b4c24a964114e2b1ae85c2b36769251ed11d
30,261,723,301,498,346,000,000,000,000,000,000,000
5
https://github.com/ImageMagick/ImageMagick/issues/500
static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; return psi_show(seq, psi, PSI_CPU); }
0
[ "CWE-416" ]
linux
a06247c6804f1a7c86a2e5398a4c1f1db1471848
12,826,294,075,637,886,000,000,000,000,000,000,000
7
psi: Fix uaf issue when psi trigger is destroyed while being polled With write operation on psi files replacing old trigger with a new one, the lifetime of its waitqueue is totally arbitrary. Overwriting an existing trigger causes its waitqueue to be freed and pending poll() will stumble on trigger->event_wait which was destroyed. Fix this by disallowing to redefine an existing psi trigger. If a write operation is used on a file descriptor with an already existing psi trigger, the operation will fail with EBUSY error. Also bypass a check for psi_disabled in the psi_trigger_destroy as the flag can be flipped after the trigger is created, leading to a memory leak. Fixes: 0e94682b73bf ("psi: introduce psi monitor") Reported-by: [email protected] Suggested-by: Linus Torvalds <[email protected]> Analyzed-by: Eric Biggers <[email protected]> Signed-off-by: Suren Baghdasaryan <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Eric Biggers <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
static void swap_guid(ff_asf_guid guid) { FFSWAP(unsigned char, guid[0], guid[3]); FFSWAP(unsigned char, guid[1], guid[2]); FFSWAP(unsigned char, guid[4], guid[5]); FFSWAP(unsigned char, guid[6], guid[7]); }
0
[ "CWE-119", "CWE-787" ]
FFmpeg
2b46ebdbff1d8dec7a3d8ea280a612b91a582869
282,825,512,353,517,100,000,000,000,000,000,000,000
7
avformat/asfdec_o: Check size_bmp more fully Fixes: integer overflow and out of array access Fixes: asfo-crash-46080c4341572a7137a162331af77f6ded45cbd7 Found-by: Paul Ch <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
ico_read_info (FILE *fp, gint icon_count) { gint i; IcoFileEntry *entries; IcoLoadInfo *info; /* read icon entries */ entries = g_new (IcoFileEntry, icon_count); if ( fread (entries, sizeof(IcoFileEntry), icon_count, fp) <= 0 ) { g_free (entries); return NULL; } info = g_new (IcoLoadInfo, icon_count); for (i = 0; i < icon_count; i++) { info[i].width = entries[i].width; info[i].height = entries[i].height; info[i].bpp = GUINT16_FROM_LE (entries[i].bpp); info[i].size = GUINT32_FROM_LE (entries[i].size); info[i].offset = GUINT32_FROM_LE (entries[i].offset); if (info[i].width == 0 || info[i].height == 0) { ico_read_size (fp, info+i); } D(("ico_read_info: %ix%i (%i bits, size: %i, offset: %i)\n", info[i].width, info[i].height, info[i].bpp, info[i].size, info[i].offset)); } g_free (entries); return info; }
1
[]
gimp
323ecb73f7bf36788fb7066eb2d6678830cd5de7
64,746,658,914,187,460,000,000,000,000,000,000,000
37
Bug 773233 - CVE-2007-3126 - Gimp 2.3.14 allows context-dependent attackers... ...to cause a denial of service (crash) via an ICO file with an InfoHeader containing a Height of zero Add some error handling to ico-load.c and bail out on zero width or height icons. Also some formatting cleanup. (cherry picked from commit 46bcd82800e37b0f5aead76184430ef2fe802748)
compressVerify (const unsigned short raw[], int n, const unsigned int dekHash) { Array <char> compressed (3 * n + 4 * 65536); int nCompressed = hufCompress (raw, n, compressed); // // This hash algorithm proposed by Donald E. Knuth in // The Art Of Computer Programming Volume 3, // under the topic of sorting and search chapter 6.4. // unsigned int compressedHash = nCompressed; const unsigned char* cptr = reinterpret_cast<const unsigned char*>( (const char*) compressed); for (int i = 0; i < nCompressed; ++i) { compressedHash = ((compressedHash << 5) ^ (compressedHash >> 27)) ^ (*cptr++); } cout << "verifying compressed checksum hash = " << compressedHash << std::endl; if (compressedHash != dekHash) { cout << "hash verification failed. Got " << compressedHash << " expected " << dekHash << std::endl; const unsigned char* cptr = reinterpret_cast<const unsigned char*>( (const char*) compressed); for(int i = 0 ; i < nCompressed ; ++i ) { cout << std::hex << (0xFF & (int) (*cptr++)); if ( (i & 0xF) ==0 ) { cout << '\n'; } else { cout << ' '; } } cout << "\n"; } assert (compressedHash == dekHash); }
0
[ "CWE-190" ]
openexr
51a92d67f53c08230734e74564c807043cbfe41e
99,641,112,191,037,700,000,000,000,000,000,000,000
45
check for valid Huf code lengths (#849) * check for valid Huf code lengths * test non-fast huf decoder in testHuf Signed-off-by: Peter Hillman <[email protected]>
int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) { int ret; if (pkey == NULL) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); return(0); } if (!ssl_cert_inst(&ssl->cert)) { SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_MALLOC_FAILURE); return(0); } ret=ssl_set_pkey(ssl->cert,pkey); return(ret); }
0
[]
openssl
0ffa49970b9f8ea66b43ce2eb7f8fd523b65bc2c
18,702,036,166,335,194,000,000,000,000,000,000,000
17
Backport support for fixed DH ciphersuites (from HEAD)
report_child_exit_status (int exitc, int setup_finished_fd) { ssize_t s; char data[2]; cleanup_free char *output = NULL; if (opt_json_status_fd == -1 || setup_finished_fd == -1) return; s = TEMP_FAILURE_RETRY (read (setup_finished_fd, data, sizeof data)); if (s == -1 && errno != EAGAIN) die_with_error ("read eventfd"); if (s != 1) // Is 0 if pipe closed before exec, is 2 if closed after exec. return; output = xasprintf ("{ \"exit-code\": %i }\n", exitc); dump_info (opt_json_status_fd, output, FALSE); close (opt_json_status_fd); opt_json_status_fd = -1; close (setup_finished_fd); }
0
[ "CWE-20", "CWE-269" ]
bubblewrap
efc89e3b939b4bde42c10f065f6b7b02958ed50e
36,556,173,059,394,953,000,000,000,000,000,000,000
20
Don't create our own temporary mount point for pivot_root An attacker could pre-create /tmp/.bubblewrap-$UID and make it a non-directory, non-symlink (in which case mounting our tmpfs would fail, causing denial of service), or make it a symlink under their control (potentially allowing bad things if the protected_symlinks sysctl is not enabled). Instead, temporarily mount the tmpfs on a directory that we are sure exists and is not attacker-controlled. /tmp (the directory itself, not a subdirectory) will do. Fixes: #304 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923557 Signed-off-by: Simon McVittie <[email protected]> Closes: #305 Approved by: cgwalters
static int ip_vs_info_open(struct inode *inode, struct file *file) { return seq_open_net(inode, file, &ip_vs_info_seq_ops, sizeof(struct ip_vs_iter)); }
0
[ "CWE-200" ]
linux
2d8a041b7bfe1097af21441cb77d6af95f4f4680
165,100,828,524,310,410,000,000,000,000,000,000,000
5
ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT) If at least one of CONFIG_IP_VS_PROTO_TCP or CONFIG_IP_VS_PROTO_UDP is not set, __ip_vs_get_timeouts() does not fully initialize the structure that gets copied to userland and that for leaks up to 12 bytes of kernel stack. Add an explicit memset(0) before passing the structure to __ip_vs_get_timeouts() to avoid the info leak. Signed-off-by: Mathias Krause <[email protected]> Cc: Wensong Zhang <[email protected]> Cc: Simon Horman <[email protected]> Cc: Julian Anastasov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
CommandSASL(Module* Creator, SimpleExtItem<SaslAuthenticator>& ext) : Command(Creator, "SASL", 2), authExt(ext) { this->flags_needed = FLAG_SERVERONLY; // should not be called by users }
0
[ "CWE-284", "CWE-264" ]
inspircd
74fafb7f11b06747f69f182ad5e3769b665eea7a
266,203,465,530,911,380,000,000,000,000,000,000,000
4
m_sasl: don't allow AUTHENTICATE with mechanisms with a space
void Curl_up_free(struct Curl_easy *data) { struct urlpieces *up = &data->state.up; Curl_safefree(up->scheme); Curl_safefree(up->hostname); Curl_safefree(up->port); Curl_safefree(up->user); Curl_safefree(up->password); Curl_safefree(up->options); Curl_safefree(up->path); Curl_safefree(up->query); curl_url_cleanup(data->state.uh); data->state.uh = NULL; }
0
[ "CWE-416" ]
curl
81d135d67155c5295b1033679c606165d4e28f3f
83,267,128,876,999,670,000,000,000,000,000,000,000
14
Curl_close: clear data->multi_easy on free to avoid use-after-free Regression from b46cfbc068 (7.59.0) CVE-2018-16840 Reported-by: Brian Carpenter (Geeknik Labs) Bug: https://curl.haxx.se/docs/CVE-2018-16840.html
WandPrivate void CLINoImageOperator(MagickCLI *cli_wand, const char *option,const char *arg1n,const char *arg2n) { const char /* percent escaped versions of the args */ *arg1, *arg2; #define _image_info (cli_wand->wand.image_info) #define _images (cli_wand->wand.images) #define _exception (cli_wand->wand.exception) #define _process_flags (cli_wand->process_flags) #define _option_type ((CommandOptionFlags) cli_wand->command->flags) #define IfNormalOp (*option=='-') #define IfPlusOp (*option!='-') assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == MagickWandSignature); assert(cli_wand->wand.signature == MagickWandSignature); if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- NoImage Operator: %s \"%s\" \"%s\"", option, arg1n != (char *) NULL ? arg1n : "", arg2n != (char *) NULL ? arg2n : ""); arg1 = arg1n; arg2 = arg2n; /* Interpret Percent Escapes in Arguments - using first image */ if ( (((_process_flags & ProcessInterpretProperities) != 0 ) || ((_option_type & AlwaysInterpretArgsFlag) != 0) ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { /* Interpret Percent escapes in argument 1 */ if (arg1n != (char *) NULL) { arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); if (arg1 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg1=arg1n; /* use the given argument as is */ } } if (arg2n != (char *) NULL) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg2=arg2n; /* use the given argument as is */ } } } #undef _process_flags #undef _option_type do { /* break to exit code */ /* No-op options (ignore these) */ if (LocaleCompare("noop",option+1) == 0) /* zero argument */ break; if (LocaleCompare("sans",option+1) == 0) /* one argument */ break; if (LocaleCompare("sans0",option+1) == 0) /* zero argument */ break; if (LocaleCompare("sans1",option+1) == 0) /* one argument */ break; if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ break; /* Image Reading */ if ( ( LocaleCompare("read",option+1) == 0 ) || ( LocaleCompare("--",option) == 0 ) ) { /* Do Glob filename Expansion for 'arg1' then read all images. * * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring * (but attaching to the filenames in the generated argument list) any * [...] read modifiers that may be present. * * For example: It will expand '*.gif[20x20]' into a list such as * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' * * NOTE: In IMv6 this was done globally across all images. This * meant you could include IM options in '@filename' lists, but you * could not include comments. Doing it only for image read makes * it far more secure. * * Note: arguments do not have percent escapes expanded for security * reasons. */ int argc; char **argv; ssize_t i; argc = 1; argv = (char **) &arg1; /* Expand 'glob' expressions in the given filename. Expansion handles any 'coder:' prefix, or read modifiers attached to the filename, including them in the resulting expanded list. */ if (ExpandFilenames(&argc,&argv) == MagickFalse) CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", option,GetExceptionMessage(errno)); /* loop over expanded filename list, and read then all in */ for (i=0; i < (ssize_t) argc; i++) { Image * new_images; if (_image_info->ping != MagickFalse) new_images=PingImages(_image_info,argv[i],_exception); else new_images=ReadImages(_image_info,argv[i],_exception); AppendImageToList(&_images, new_images); argv[i]=DestroyString(argv[i]); } argv=(char **) RelinquishMagickMemory(argv); break; } /* Image Writing Note: Writing a empty image list is valid in specific cases */ if (LocaleCompare("write",option+1) == 0) { /* Note: arguments do not have percent escapes expanded */ char key[MagickPathExtent]; Image *write_images; ImageInfo *write_info; /* Need images, unless a "null:" output coder is used */ if ( _images == (Image *) NULL ) { if ( LocaleCompare(arg1,"null:") == 0 ) break; CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); } (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",arg1); (void) DeleteImageRegistry(key); write_images=_images; if (IfPlusOp) write_images=CloneImageList(_images,_exception); write_info=CloneImageInfo(_image_info); (void) WriteImages(write_info,write_images,arg1,_exception); write_info=DestroyImageInfo(write_info); if (IfPlusOp) write_images=DestroyImageList(write_images); break; } /* Parenthesis and Brace operations */ if (LocaleCompare("(",option) == 0) { /* stack 'push' images */ Stack *node; size_t size; size=0; node=cli_wand->image_list_stack; for ( ; node != (Stack *) NULL; node=node->next) size++; if ( size >= MAX_STACK_DEPTH ) CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); node=(Stack *) AcquireMagickMemory(sizeof(*node)); if (node == (Stack *) NULL) CLIWandExceptionBreak(ResourceLimitFatalError, "MemoryAllocationFailed",option); node->data = (void *)cli_wand->wand.images; node->next = cli_wand->image_list_stack; cli_wand->image_list_stack = node; cli_wand->wand.images = NewImageList(); /* handle respect-parenthesis */ if (IsStringTrue(GetImageOption(cli_wand->wand.image_info, "respect-parenthesis")) != MagickFalse) option="{"; /* fall-thru so as to push image settings too */ else break; /* fall thru to operation */ } if (LocaleCompare("{",option) == 0) { /* stack 'push' of image_info settings */ Stack *node; size_t size; size=0; node=cli_wand->image_info_stack; for ( ; node != (Stack *) NULL; node=node->next) size++; if ( size >= MAX_STACK_DEPTH ) CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); node=(Stack *) AcquireMagickMemory(sizeof(*node)); if (node == (Stack *) NULL) CLIWandExceptionBreak(ResourceLimitFatalError, "MemoryAllocationFailed",option); node->data = (void *)cli_wand->wand.image_info; node->next = cli_wand->image_info_stack; cli_wand->image_info_stack = node; cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); if (cli_wand->wand.image_info == (ImageInfo *) NULL) { CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", option); cli_wand->wand.image_info = (ImageInfo *)node->data; node = (Stack *)RelinquishMagickMemory(node); break; } break; } if (LocaleCompare(")",option) == 0) { /* pop images from stack */ Stack *node; node = (Stack *)cli_wand->image_list_stack; if ( node == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); cli_wand->image_list_stack = node->next; AppendImageToList((Image **)&node->data,cli_wand->wand.images); cli_wand->wand.images= (Image *)node->data; node = (Stack *)RelinquishMagickMemory(node); /* handle respect-parenthesis - of the previous 'pushed' settings */ node = cli_wand->image_info_stack; if ( node != (Stack *) NULL) { if (IsStringTrue(GetImageOption( cli_wand->wand.image_info,"respect-parenthesis")) != MagickFalse) option="}"; /* fall-thru so as to pop image settings too */ else break; } else break; /* fall thru to next if */ } if (LocaleCompare("}",option) == 0) { /* pop image_info settings from stack */ Stack *node; node = (Stack *)cli_wand->image_info_stack; if ( node == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); cli_wand->image_info_stack = node->next; (void) DestroyImageInfo(cli_wand->wand.image_info); cli_wand->wand.image_info = (ImageInfo *)node->data; node = (Stack *)RelinquishMagickMemory(node); GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); break; } if (LocaleCompare("print",option+1) == 0) { (void) FormatLocaleFile(stdout,"%s",arg1); break; } if (LocaleCompare("set",option+1) == 0) { /* Settings are applied to each image in memory in turn (if any). While a option: only need to be applied once globally. NOTE: rguments have not been automatically percent expaneded */ /* escape the 'key' once only, using first image. */ arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); if (arg1 == (char *) NULL) CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", option); if (LocaleNCompare(arg1,"registry:",9) == 0) { if (IfPlusOp) { (void) DeleteImageRegistry(arg1+9); arg1=DestroyString((char *)arg1); break; } arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) { arg1=DestroyString((char *)arg1); CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", option); } (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception); arg1=DestroyString((char *)arg1); arg2=DestroyString((char *)arg2); break; } if (LocaleNCompare(arg1,"option:",7) == 0) { /* delete equivelent artifact from all images (if any) */ if (_images != (Image *) NULL) { MagickResetIterator(&cli_wand->wand); while (MagickNextImage(&cli_wand->wand) != MagickFalse) (void) DeleteImageArtifact(_images,arg1+7); MagickResetIterator(&cli_wand->wand); } /* now set/delete the global option as needed */ /* FUTURE: make escapes in a global 'option:' delayed */ arg2=(char *) NULL; if (IfNormalOp) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) CLIWandExceptionBreak(OptionWarning, "InterpretPropertyFailure",option); } (void) SetImageOption(_image_info,arg1+7,arg2); arg1=DestroyString((char *)arg1); arg2=DestroyString((char *)arg2); break; } /* Set Artifacts/Properties/Attributes all images (required) */ if ( _images == (Image *) NULL ) CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1); MagickResetIterator(&cli_wand->wand); while (MagickNextImage(&cli_wand->wand) != MagickFalse) { arg2=(char *) NULL; if (IfNormalOp) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) CLIWandExceptionBreak(OptionWarning, "InterpretPropertyFailure",option); } if (LocaleNCompare(arg1,"artifact:",9) == 0) (void) SetImageArtifact(_images,arg1+9,arg2); else if (LocaleNCompare(arg1,"property:",9) == 0) (void) SetImageProperty(_images,arg1+9,arg2,_exception); else (void) SetImageProperty(_images,arg1,arg2,_exception); arg2=DestroyString((char *)arg2); } MagickResetIterator(&cli_wand->wand); arg1=DestroyString((char *)arg1); break; } if (LocaleCompare("clone",option+1) == 0) { Image *new_images; if (*option == '+') arg1=AcquireString("-1"); if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse) CLIWandExceptionBreak(OptionError,"InvalidArgument",option); if ( cli_wand->image_list_stack == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); new_images = (Image *)cli_wand->image_list_stack->data; if (new_images == (Image *) NULL) CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); new_images=CloneImages(new_images,arg1,_exception); if (new_images == (Image *) NULL) CLIWandExceptionBreak(OptionError,"NoSuchImage",option); AppendImageToList(&_images,new_images); break; } /* Informational Operations. Note that these do not require either a cli-wand or images! Though currently a cli-wand much be provided regardless. */ if (LocaleCompare("version",option+1) == 0) { ListMagickVersion(stdout); break; } if (LocaleCompare("list",option+1) == 0) { /* FUTURE: This 'switch' should really be part of MagickCore */ ssize_t list; list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); if ( list < 0 ) { CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); break; } switch (list) { case MagickCoderOptions: { (void) ListCoderInfo((FILE *) NULL,_exception); break; } case MagickColorOptions: { (void) ListColorInfo((FILE *) NULL,_exception); break; } case MagickConfigureOptions: { (void) ListConfigureInfo((FILE *) NULL,_exception); break; } case MagickDelegateOptions: { (void) ListDelegateInfo((FILE *) NULL,_exception); break; } case MagickFontOptions: { (void) ListTypeInfo((FILE *) NULL,_exception); break; } case MagickFormatOptions: (void) ListMagickInfo((FILE *) NULL,_exception); break; case MagickLocaleOptions: (void) ListLocaleInfo((FILE *) NULL,_exception); break; case MagickLogOptions: (void) ListLogInfo((FILE *) NULL,_exception); break; case MagickMagicOptions: (void) ListMagicInfo((FILE *) NULL,_exception); break; case MagickMimeOptions: (void) ListMimeInfo((FILE *) NULL,_exception); break; case MagickModuleOptions: (void) ListModuleInfo((FILE *) NULL,_exception); break; case MagickPolicyOptions: (void) ListPolicyInfo((FILE *) NULL,_exception); break; case MagickResourceOptions: (void) ListMagickResourceInfo((FILE *) NULL,_exception); break; case MagickThresholdOptions: (void) ListThresholdMaps((FILE *) NULL,_exception); break; default: (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, _exception); break; } break; } CLIWandException(OptionError,"UnrecognizedOption",option); DisableMSCWarning(4127) } while (0); /* break to exit code. */ RestoreMSCWarning /* clean up percent escape interpreted strings */ if (arg1 != arg1n ) arg1=DestroyString((char *)arg1); if (arg2 != arg2n ) arg2=DestroyString((char *)arg2); #undef _image_info #undef _images #undef _exception #undef IfNormalOp #undef IfPlusOp }
0
[ "CWE-399", "CWE-401" ]
ImageMagick
4a334bbf5584de37c6f5a47c380a531c8c4b140a
264,190,072,851,029,660,000,000,000,000,000,000,000
478
https://github.com/ImageMagick/ImageMagick/issues/1623
int vnc_display_pw_expire(const char *id, time_t expires) { VncDisplay *vd = vnc_display_find(id); if (!vd) { return -EINVAL; } vd->expires = expires; return 0; }
0
[ "CWE-401" ]
qemu
6bf21f3d83e95bcc4ba35a7a07cc6655e8b010b0
210,915,539,662,543,150,000,000,000,000,000,000,000
11
vnc: fix memory leak when vnc disconnect Currently when qemu receives a vnc connect, it creates a 'VncState' to represent this connection. In 'vnc_worker_thread_loop' it creates a local 'VncState'. The connection 'VcnState' and local 'VncState' exchange data in 'vnc_async_encoding_start' and 'vnc_async_encoding_end'. In 'zrle_compress_data' it calls 'deflateInit2' to allocate the libz library opaque data. The 'VncState' used in 'zrle_compress_data' is the local 'VncState'. In 'vnc_zrle_clear' it calls 'deflateEnd' to free the libz library opaque data. The 'VncState' used in 'vnc_zrle_clear' is the connection 'VncState'. In currently implementation there will be a memory leak when the vnc disconnect. Following is the asan output backtrack: Direct leak of 29760 byte(s) in 5 object(s) allocated from: 0 0xffffa67ef3c3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33c3) 1 0xffffa65071cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) 2 0xffffa5e968f7 in deflateInit2_ (/lib64/libz.so.1+0x78f7) 3 0xaaaacec58613 in zrle_compress_data ui/vnc-enc-zrle.c:87 4 0xaaaacec58613 in zrle_send_framebuffer_update ui/vnc-enc-zrle.c:344 5 0xaaaacec34e77 in vnc_send_framebuffer_update ui/vnc.c:919 6 0xaaaacec5e023 in vnc_worker_thread_loop ui/vnc-jobs.c:271 7 0xaaaacec5e5e7 in vnc_worker_thread ui/vnc-jobs.c:340 8 0xaaaacee4d3c3 in qemu_thread_start util/qemu-thread-posix.c:502 9 0xffffa544e8bb in start_thread (/lib64/libpthread.so.0+0x78bb) 10 0xffffa53965cb in thread_start (/lib64/libc.so.6+0xd55cb) This is because the opaque allocated in 'deflateInit2' is not freed in 'deflateEnd'. The reason is that the 'deflateEnd' calls 'deflateStateCheck' and in the latter will check whether 's->strm != strm'(libz's data structure). This check will be true so in 'deflateEnd' it just return 'Z_STREAM_ERROR' and not free the data allocated in 'deflateInit2'. The reason this happens is that the 'VncState' contains the whole 'VncZrle', so when calling 'deflateInit2', the 's->strm' will be the local address. So 's->strm != strm' will be true. To fix this issue, we need to make 'zrle' of 'VncState' to be a pointer. Then the connection 'VncState' and local 'VncState' exchange mechanism will work as expection. The 'tight' of 'VncState' has the same issue, let's also turn it to a pointer. Reported-by: Ying Fang <[email protected]> Signed-off-by: Li Qiang <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
virt_to_phys_or_null_size(void *va, unsigned long size) { bool bad_size; if (!va) return 0; if (virt_addr_valid(va)) return virt_to_phys(va); /* * A fully aligned variable on the stack is guaranteed not to * cross a page bounary. Try to catch strings on the stack by * checking that 'size' is a power of two. */ bad_size = size > PAGE_SIZE || !is_power_of_2(size); WARN_ON(!IS_ALIGNED((unsigned long)va, size) || bad_size); return slow_virt_to_phys(va); }
0
[ "CWE-388" ]
tip
4e78921ba4dd0aca1cc89168f45039add4183f8e
184,814,910,561,034,870,000,000,000,000,000,000,000
21
efi/x86/Add missing error handling to old_memmap 1:1 mapping code The old_memmap flow in efi_call_phys_prolog() performs numerous memory allocations, and either does not check for failure at all, or it does but fails to propagate it back to the caller, which may end up calling into the firmware with an incomplete 1:1 mapping. So let's fix this by returning NULL from efi_call_phys_prolog() on memory allocation failures only, and by handling this condition in the caller. Also, clean up any half baked sets of page tables that we may have created before returning with a NULL return value. Note that any failure at this level will trigger a panic() two levels up, so none of this makes a huge difference, but it is a nice cleanup nonetheless. [ardb: update commit log, add efi_call_phys_epilog() call on error path] Signed-off-by: Gen Zhang <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rob Bradford <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
unknowntag_start(struct archive_read *a, struct xar *xar, const char *name) { struct unknown_tag *tag; tag = malloc(sizeof(*tag)); if (tag == NULL) { archive_set_error(&a->archive, ENOMEM, "Out of memory"); return (ARCHIVE_FATAL); } tag->next = xar->unknowntags; archive_string_init(&(tag->name)); archive_strcpy(&(tag->name), name); if (xar->unknowntags == NULL) { #if DEBUG fprintf(stderr, "UNKNOWNTAG_START:%s\n", name); #endif xar->xmlsts_unknown = xar->xmlsts; xar->xmlsts = UNKNOWN; } xar->unknowntags = tag; return (ARCHIVE_OK); }
0
[ "CWE-125" ]
libarchive
fa7438a0ff4033e4741c807394a9af6207940d71
291,467,853,468,068,100,000,000,000,000,000,000,000
22
Do something sensible for empty strings to make fuzzers happy.
check_nomodeline(char_u **argp) { if (STRNCMP(*argp, "<nomodeline>", 12) == 0) { *argp = skipwhite(*argp + 12); return FALSE; } return TRUE; }
0
[ "CWE-200", "CWE-668" ]
vim
5a73e0ca54c77e067c3b12ea6f35e3e8681e8cf8
40,734,551,047,026,560,000,000,000,000,000,000,000
9
patch 8.0.1263: others can read the swap file if a user is careless Problem: Others can read the swap file if a user is careless with his primary group. Solution: If the group permission allows for reading but the world permissions doesn't, make sure the group is right.
ProviderVerifierImpl(const std::string& provider_name, const AuthFactory& factory, const JwtProvider& provider, const BaseVerifierImpl* parent) : BaseVerifierImpl(parent), auth_factory_(factory), extractor_(Extractor::create(provider)), provider_name_(provider_name) {}
0
[ "CWE-303", "CWE-703" ]
envoy
ea39e3cba652bcc4b11bb0d5c62b017e584d2e5a
188,814,695,609,119,200,000,000,000,000,000,000,000
4
jwt_authn: fix a bug where JWT with wrong issuer is allowed in allow_missing case (#15194) [jwt] When allow_missing is used inside RequiresAny, the requests with JWT with wrong issuer are accepted. This is a bug, allow_missing should only allow requests without any JWT. This change fixed the above issue by preserving JwtUnknownIssuer in allow_missing case. Signed-off-by: Wayne Zhang <[email protected]>
bool DocumentSourceMatch::isTextQuery(const BSONObj& query) { BSONForEach(e, query) { const StringData fieldName = e.fieldNameStringData(); if (fieldName == "$text"_sd) return true; if (e.isABSONObj() && isTextQuery(e.Obj())) return true; } return false; }
0
[]
mongo
b3107d73a2c58d7e016b834dae0acfd01c0db8d7
312,689,607,947,125,770,000,000,000,000,000,000,000
11
SERVER-59299: Flatten top-level nested $match stages in doOptimizeAt (cherry picked from commit 4db5eceda2cff697f35c84cd08232bac8c33beec)
int HeaderMapWrapper::luaRemove(lua_State* state) { checkModifiable(state); const char* key = luaL_checkstring(state, 2); headers_.remove(Http::LowerCaseString(key)); return 0; }
0
[]
envoy
2c60632d41555ec8b3d9ef5246242be637a2db0f
266,991,803,278,555,400,000,000,000,000,000,000,000
7
http: header map security fixes for duplicate headers (#197) Previously header matching did not match on all headers for non-inline headers. This patch changes the default behavior to always logically match on all headers. Multiple individual headers will be logically concatenated with ',' similar to what is done with inline headers. This makes the behavior effectively consistent. This behavior can be temporary reverted by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to "false". Targeted fixes have been additionally performed on the following extensions which make them consider all duplicate headers by default as a comma concatenated list: 1) Any extension using CEL matching on headers. 2) The header to metadata filter. 3) The JWT filter. 4) The Lua filter. Like primary header matching used in routing, RBAC, etc. this behavior can be disabled by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to false. Finally, the setCopy() header map API previously only set the first header in the case of duplicate non-inline headers. setCopy() now behaves similiarly to the other set*() APIs and replaces all found headers with a single value. This may have had security implications in the extauth filter which uses this API. This behavior can be disabled by setting the runtime value "envoy.reloadable_features.http_set_copy_replace_all_headers" to false. Fixes https://github.com/envoyproxy/envoy-setec/issues/188 Signed-off-by: Matt Klein <[email protected]>
mm_answer_audit_command(int socket, Buffer *m) { u_int len; char *cmd; debug3("%s entering", __func__); cmd = buffer_get_string(m, &len); /* sanity check command, if so how? */ audit_run_command(cmd); free(cmd); return (0); }
0
[ "CWE-20", "CWE-200" ]
openssh-portable
d4697fe9a28dab7255c60433e4dd23cf7fce8a8b
259,480,776,157,491,230,000,000,000,000,000,000,000
12
Don't resend username to PAM; it already has it. Pointed out by Moritz Jodeit; ok dtucker@
static int on_send_data_cb(nghttp2_session *ngh2, nghttp2_frame *frame, const uint8_t *framehd, size_t length, nghttp2_data_source *source, void *userp) { apr_status_t status = APR_SUCCESS; h2_session *session = (h2_session *)userp; int stream_id = (int)frame->hd.stream_id; unsigned char padlen; int eos; h2_stream *stream; apr_bucket *b; apr_off_t len = length; (void)ngh2; (void)source; if (!h2_session_continue_data(session)) { return NGHTTP2_ERR_WOULDBLOCK; } ap_assert(frame->data.padlen <= (H2_MAX_PADLEN+1)); padlen = (unsigned char)frame->data.padlen; stream = get_stream(session, stream_id); if (!stream) { ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_NOTFOUND, session->c, APLOGNO(02924) "h2_stream(%ld-%d): send_data, stream not found", session->id, (int)stream_id); return NGHTTP2_ERR_CALLBACK_FAILURE; } ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c, H2_STRM_MSG(stream, "send_data_cb for %ld bytes"), (long)length); status = h2_conn_io_write(&session->io, (const char *)framehd, H2_FRAME_HDR_LEN); if (padlen && status == APR_SUCCESS) { --padlen; status = h2_conn_io_write(&session->io, (const char *)&padlen, 1); } if (status != APR_SUCCESS) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, H2_STRM_MSG(stream, "writing frame header")); return NGHTTP2_ERR_CALLBACK_FAILURE; } status = h2_stream_read_to(stream, session->bbtmp, &len, &eos); if (status != APR_SUCCESS) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, H2_STRM_MSG(stream, "send_data_cb, reading stream")); apr_brigade_cleanup(session->bbtmp); return NGHTTP2_ERR_CALLBACK_FAILURE; } else if (len != length) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, H2_STRM_MSG(stream, "send_data_cb, wanted %ld bytes, " "got %ld from stream"), (long)length, (long)len); apr_brigade_cleanup(session->bbtmp); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (padlen) { b = apr_bucket_immortal_create(immortal_zeros, padlen, session->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(session->bbtmp, b); } status = h2_conn_io_pass(&session->io, session->bbtmp); apr_brigade_cleanup(session->bbtmp); if (status == APR_SUCCESS) { stream->out_data_frames++; stream->out_data_octets += length; return 0; } else { ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, H2_STRM_LOG(APLOGNO(02925), stream, "failed send_data_cb")); return NGHTTP2_ERR_CALLBACK_FAILURE; } }
0
[ "CWE-770" ]
mod_h2
dd05d49abe0f67512ce9ed5ba422d7711effecfb
268,874,291,995,279,000,000,000,000,000,000,000,000
85
* fixes Timeout vs. KeepAliveTimeout behaviour, see PR 63534 (for trunk now, mpm event backport to 2.4.x up for vote). * Fixes stream cleanup when connection throttling is in place. * Counts stream resets by client on streams initiated by client as cause for connection throttling. * Header length checks are now logged similar to HTTP/1.1 protocol handler (thanks @mkaufmann) * Header length is checked also on the merged value from several header instances and results in a 431 response.
static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi) { up_write(&sbi->cp_rwsem); }
0
[ "CWE-476" ]
linux
4969c06a0d83c9c3dc50b8efcdc8eeedfce896f6
237,072,114,799,038,930,000,000,000,000,000,000,000
4
f2fs: support swap file w/ DIO Signed-off-by: Jaegeuk Kim <[email protected]>
get_system_info(void) { FILE* fp; static char buf[1000]; fp = popen("uname -a", "r"); if (fp == NULL) return NULL; fgets(buf, sizeof(buf), fp); pclose(fp); return buf; }
0
[ "CWE-120", "CWE-119", "CWE-787" ]
iperf
91f2fa59e8ed80dfbf400add0164ee0e508e412a
52,917,403,371,804,720,000,000,000,000,000,000,000
12
Fix a buffer overflow / heap corruption issue that could occur if a malformed JSON string was passed on the control channel. This issue, present in the cJSON library, was already fixed upstream, so was addressed here in iperf3 by importing a newer version of cJSON (plus local ESnet modifications). Discovered and reported by Dave McDaniel, Cisco Talos. Based on a patch by @dopheide-esnet, with input from @DaveGamble. Cross-references: TALOS-CAN-0164, ESNET-SECADV-2016-0001, CVE-2016-4303 (cherry picked from commit ed94082be27d971a5e1b08b666e2c217cf470a40) Signed-off-by: Bruce A. Mah <[email protected]>
void ElectronBrowserClient::ExposeInterfacesToRenderer( service_manager::BinderRegistry* registry, blink::AssociatedInterfaceRegistry* associated_registry, content::RenderProcessHost* render_process_host) { #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) associated_registry->AddInterface(base::BindRepeating( &extensions::EventRouter::BindForRenderer, render_process_host->GetID())); associated_registry->AddInterface( base::BindRepeating(&extensions::ExtensionsGuestView::CreateForExtensions, render_process_host->GetID())); #endif }
0
[]
electron
e9fa834757f41c0b9fe44a4dffe3d7d437f52d34
36,018,448,551,955,205,000,000,000,000,000,000,000
12
fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33344) * fix: ensure ElectronBrowser mojo service is only bound to authorized render frames Notes: no-notes * refactor: extract electron API IPC to its own mojo interface * fix: just check main frame not primary main frame Co-authored-by: Samuel Attard <[email protected]> Co-authored-by: Samuel Attard <[email protected]>
static void FS_Startup( const char *gameName ) { const char *homePath; Com_Printf( "----- FS_Startup -----\n" ); fs_packFiles = 0; fs_debug = Cvar_Get( "fs_debug", "0", 0 ); fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT|CVAR_PROTECTED ); fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT ); homePath = Sys_DefaultHomePath(); if (!homePath || !homePath[0]) { homePath = fs_basepath->string; } fs_homepath = Cvar_Get ("fs_homepath", homePath, CVAR_INIT|CVAR_PROTECTED ); fs_gamedirvar = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); // add search path elements in reverse priority order fs_steampath = Cvar_Get ("fs_steampath", Sys_SteamPath(), CVAR_INIT|CVAR_PROTECTED ); if (fs_steampath->string[0]) { FS_AddGameDirectory( fs_steampath->string, gameName ); } if (fs_basepath->string[0]) { FS_AddGameDirectory( fs_basepath->string, gameName ); } // fs_homepath is somewhat particular to *nix systems, only add if relevant #ifdef __APPLE__ fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT|CVAR_PROTECTED ); // Make MacOSX also include the base path included with the .app bundle if (fs_apppath->string[0]) FS_AddGameDirectory(fs_apppath->string, gameName); #endif // NOTE: same filtering below for mods and basegame if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_CreatePath ( fs_homepath->string ); FS_AddGameDirectory ( fs_homepath->string, gameName ); } // check for additional base game so mods can be based upon other mods if ( fs_basegame->string[0] && Q_stricmp( fs_basegame->string, gameName ) ) { if (fs_steampath->string[0]) { FS_AddGameDirectory(fs_steampath->string, fs_basegame->string); } if (fs_basepath->string[0]) { FS_AddGameDirectory(fs_basepath->string, fs_basegame->string); } if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_AddGameDirectory(fs_homepath->string, fs_basegame->string); } } // check for additional game folder for mods if ( fs_gamedirvar->string[0] && Q_stricmp( fs_gamedirvar->string, gameName ) ) { if (fs_steampath->string[0]) { FS_AddGameDirectory(fs_steampath->string, fs_gamedirvar->string); } if (fs_basepath->string[0]) { FS_AddGameDirectory(fs_basepath->string, fs_gamedirvar->string); } if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { FS_AddGameDirectory(fs_homepath->string, fs_gamedirvar->string); } } #ifndef STANDALONE if(!com_standalone->integer) { cvar_t *fs; Com_ReadCDKey(BASEGAME); fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); if (fs && fs->string[0] != 0) { Com_AppendCDKey( fs->string ); } } #endif // add our commands Cmd_AddCommand ("path", FS_Path_f); Cmd_AddCommand ("dir", FS_Dir_f ); Cmd_AddCommand ("fdir", FS_NewDir_f ); Cmd_AddCommand ("touchFile", FS_TouchFile_f ); Cmd_AddCommand ("which", FS_Which_f ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506 // reorder the pure pk3 files according to server order FS_ReorderPurePaks(); // print the current search paths FS_Path_f(); fs_gamedirvar->modified = qfalse; // We just loaded, it's not modified Com_Printf( "----------------------\n" ); #ifdef FS_MISSING if (missingFiles == NULL) { missingFiles = Sys_FOpen( "\\missing.txt", "ab" ); } #endif Com_Printf( "%d files in pk3 files\n", fs_packFiles ); }
0
[ "CWE-269" ]
ioq3
376267d534476a875d8b9228149c4ee18b74a4fd
186,141,143,809,549,500,000,000,000,000,000,000,000
105
Don't load .pk3s as .dlls, and don't load user config files from .pk3s.
PHP_METHOD(PharFileInfo, decompress) { char *error; PHAR_ENTRY_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } if (entry_obj->ent.entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \ "Phar entry is a directory, cannot set compression"); \ return; } if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) { RETURN_TRUE; } if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Phar is readonly, cannot decompress"); return; } if (entry_obj->ent.entry->is_deleted) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot compress deleted file"); return; } if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot decompress Gzip-compressed file, zlib extension is not enabled"); return; } if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot decompress Bzip2-compressed file, bz2 extension is not enabled"); return; } if (entry_obj->ent.entry->is_persistent) { phar_archive_data *phar = entry_obj->ent.entry->phar; if (FAILURE == phar_copy_on_write(&phar TSRMLS_CC)) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar \"%s\" is persistent, unable to copy on write", phar->fname); return; } /* re-populate after copy-on-write */ zend_hash_find(&phar->manifest, entry_obj->ent.entry->filename, entry_obj->ent.entry->filename_len, (void **)&entry_obj->ent.entry); } if (!entry_obj->ent.entry->fp) { if (FAILURE == phar_open_archive_fp(entry_obj->ent.entry->phar TSRMLS_CC)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot decompress entry \"%s\", phar error: Cannot open phar archive \"%s\" for reading", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname); return; } entry_obj->ent.entry->fp_type = PHAR_FP; } entry_obj->ent.entry->old_flags = entry_obj->ent.entry->flags; entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK; entry_obj->ent.entry->phar->is_modified = 1; entry_obj->ent.entry->is_modified = 1; phar_flush(entry_obj->ent.entry->phar, 0, 0, 0, &error TSRMLS_CC); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "%s", error); efree(error); } RETURN_TRUE; }
0
[ "CWE-119" ]
php-src
13ad4d3e971807f9a58ab5933182907dc2958539
160,081,475,888,665,920,000,000,000,000,000,000,000
73
Fix bug #71354 - remove UMR when size is 0
inline sql_mode_t sql_mode_for_dates(THD *thd) { return thd->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_NO_ZERO_IN_DATE | MODE_INVALID_DATES); }
0
[ "CWE-416" ]
server
4681b6f2d8c82b4ec5cf115e83698251963d80d5
75,298,604,387,502,350,000,000,000,000,000,000,000
5
MDEV-26281 ASAN use-after-poison when complex conversion is involved in blob the bug was that in_vector array in Item_func_in was allocated in the statement arena, not in the table->expr_arena. revert part of the 5acd391e8b2d. Instead, change the arena correctly in fix_all_session_vcol_exprs(). Remove TABLE_ARENA, that was introduced in 5acd391e8b2d to force item tree changes to be rolled back (because they were allocated in the wrong arena and didn't persist. now they do)
static int __netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev, bool master, void *private) { struct netdev_adjacent *i, *j, *to_i, *to_j; int ret = 0; ASSERT_RTNL(); if (dev == upper_dev) return -EBUSY; /* To prevent loops, check if dev is not upper device to upper_dev. */ if (__netdev_find_adj(upper_dev, dev, &upper_dev->all_adj_list.upper)) return -EBUSY; if (__netdev_find_adj(dev, upper_dev, &dev->all_adj_list.upper)) return -EEXIST; if (master && netdev_master_upper_dev_get(dev)) return -EBUSY; ret = __netdev_adjacent_dev_link_neighbour(dev, upper_dev, private, master); if (ret) return ret; /* Now that we linked these devs, make all the upper_dev's * all_adj_list.upper visible to every dev's all_adj_list.lower an * versa, and don't forget the devices itself. All of these * links are non-neighbours. */ list_for_each_entry(i, &dev->all_adj_list.lower, list) { list_for_each_entry(j, &upper_dev->all_adj_list.upper, list) { pr_debug("Interlinking %s with %s, non-neighbour\n", i->dev->name, j->dev->name); ret = __netdev_adjacent_dev_link(i->dev, j->dev); if (ret) goto rollback_mesh; } } /* add dev to every upper_dev's upper device */ list_for_each_entry(i, &upper_dev->all_adj_list.upper, list) { pr_debug("linking %s's upper device %s with %s\n", upper_dev->name, i->dev->name, dev->name); ret = __netdev_adjacent_dev_link(dev, i->dev); if (ret) goto rollback_upper_mesh; } /* add upper_dev to every dev's lower device */ list_for_each_entry(i, &dev->all_adj_list.lower, list) { pr_debug("linking %s's lower device %s with %s\n", dev->name, i->dev->name, upper_dev->name); ret = __netdev_adjacent_dev_link(i->dev, upper_dev); if (ret) goto rollback_lower_mesh; } call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev); return 0; rollback_lower_mesh: to_i = i; list_for_each_entry(i, &dev->all_adj_list.lower, list) { if (i == to_i) break; __netdev_adjacent_dev_unlink(i->dev, upper_dev); } i = NULL; rollback_upper_mesh: to_i = i; list_for_each_entry(i, &upper_dev->all_adj_list.upper, list) { if (i == to_i) break; __netdev_adjacent_dev_unlink(dev, i->dev); } i = j = NULL; rollback_mesh: to_i = i; to_j = j; list_for_each_entry(i, &dev->all_adj_list.lower, list) { list_for_each_entry(j, &upper_dev->all_adj_list.upper, list) { if (i == to_i && j == to_j) break; __netdev_adjacent_dev_unlink(i->dev, j->dev); } if (i == to_i) break; } __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); return ret;
0
[]
linux
7bced397510ab569d31de4c70b39e13355046387
135,951,689,329,711,670,000,000,000,000,000,000,000
100
net_dma: simple removal Per commit "77873803363c net_dma: mark broken" net_dma is no longer used and there is no plan to fix it. This is the mechanical removal of bits in CONFIG_NET_DMA ifdef guards. Reverting the remainder of the net_dma induced changes is deferred to subsequent patches. Marked for stable due to Roman's report of a memory leak in dma_pin_iovec_pages(): https://lkml.org/lkml/2014/9/3/177 Cc: Dave Jiang <[email protected]> Cc: Vinod Koul <[email protected]> Cc: David Whipple <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: <[email protected]> Reported-by: Roman Gushchin <[email protected]> Acked-by: David S. Miller <[email protected]> Signed-off-by: Dan Williams <[email protected]>
void vnc_hextile_set_pixel_conversion(VncState *vs, int generic) { if (!generic) { switch (vs->ds->surface->pf.bits_per_pixel) { case 8: vs->hextile.send_tile = send_hextile_tile_8; break; case 16: vs->hextile.send_tile = send_hextile_tile_16; break; case 32: vs->hextile.send_tile = send_hextile_tile_32; break; } } else { switch (vs->ds->surface->pf.bits_per_pixel) { case 8: vs->hextile.send_tile = send_hextile_tile_generic_8; break; case 16: vs->hextile.send_tile = send_hextile_tile_generic_16; break; case 32: vs->hextile.send_tile = send_hextile_tile_generic_32; break; } } }
1
[ "CWE-125" ]
qemu
9f64916da20eea67121d544698676295bbb105a7
334,573,614,575,755,000,000,000,000,000,000,000,000
28
pixman/vnc: use pixman images in vnc. The vnc code uses *three* DisplaySurfaces: First is the surface of the actual QemuConsole, usually the guest screen, but could also be a text console (monitor/serial reachable via Ctrl-Alt-<nr> keys). This is left as-is. Second is the current server's view of the screen content. The vnc code uses this to figure which parts of the guest screen did _really_ change to reduce the amount of updates sent to the vnc clients. It is also used as data source when sending out the updates to the clients. This surface gets replaced by a pixman image. The format changes too, instead of using the guest screen format we'll use fixed 32bit rgb framebuffer and convert the pixels on the fly when comparing and updating the server framebuffer. Third surface carries the format expected by the vnc client. That isn't used to store image data. This surface is switched to PixelFormat and a boolean for bigendian byte order. Signed-off-by: Gerd Hoffmann <[email protected]>
static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt, GetBitContext *gb, int block_size, int width, int height, int x_pos, int y_pos, int blk_idx) { struct FlashSVContext *s = avctx->priv_data; uint8_t *line = s->tmpblock; int k; int ret = inflateReset(&s->zstream); if (ret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret); return AVERROR_UNKNOWN; } if (s->zlibprime_curr || s->zlibprime_prev) { ret = flashsv2_prime(s, s->blocks[blk_idx].pos, s->blocks[blk_idx].size); if (ret < 0) return ret; } s->zstream.next_in = avpkt->data + get_bits_count(gb) / 8; s->zstream.avail_in = block_size; s->zstream.next_out = s->tmpblock; s->zstream.avail_out = s->block_size * 3; ret = inflate(&s->zstream, Z_FINISH); if (ret == Z_DATA_ERROR) { av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n"); inflateSync(&s->zstream); ret = inflate(&s->zstream, Z_FINISH); } if (ret != Z_OK && ret != Z_STREAM_END) { //return -1; } if (s->is_keyframe) { s->blocks[blk_idx].pos = s->keyframedata + (get_bits_count(gb) / 8); s->blocks[blk_idx].size = block_size; } if (!s->color_depth) { /* Flash Screen Video stores the image upside down, so copy * lines to destination in reverse order. */ for (k = 1; k <= s->diff_height; k++) { memcpy(s->frame.data[0] + x_pos * 3 + (s->image_height - y_pos - s->diff_start - k) * s->frame.linesize[0], line, width * 3); /* advance source pointer to next line */ line += width * 3; } } else { /* hybrid 15-bit/palette mode */ decode_hybrid(s->tmpblock, s->frame.data[0], s->image_height - (y_pos + 1 + s->diff_start + s->diff_height), x_pos, s->diff_height, width, s->frame.linesize[0], s->pal); } skip_bits_long(gb, 8 * block_size); /* skip the consumed bits */ return 0; }
0
[ "CWE-20" ]
FFmpeg
880c73cd76109697447fbfbaa8e5ee5683309446
179,011,043,118,380,500,000,000,000,000,000,000,000
59
avcodec/flashsv: check diff_start/height Fixes out of array accesses Fixes Ticket2844 Found-by: ami_stuff Signed-off-by: Michael Niedermayer <[email protected]>
static bool is_negative(T value) { return value < 0; }
0
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
262,726,993,947,337,980,000,000,000,000,000,000,000
1
Fix segfault on complex pointer formatting (#642)
restart_job_control () { if (shell_tty != -1) close (shell_tty); initialize_job_control (0); }
0
[]
bash
955543877583837c85470f7fb8a97b7aa8d45e6c
68,178,106,299,899,020,000,000,000,000,000,000,000
6
bash-4.4-rc2 release
static int rxrpc_preparse_xdr(struct key_preparsed_payload *prep) { const __be32 *xdr = prep->data, *token; const char *cp; unsigned int len, paddedlen, loop, ntoken, toklen, sec_ix; size_t datalen = prep->datalen; int ret; _enter(",{%x,%x,%x,%x},%zu", ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]), prep->datalen); if (datalen > AFSTOKEN_LENGTH_MAX) goto not_xdr; /* XDR is an array of __be32's */ if (datalen & 3) goto not_xdr; /* the flags should be 0 (the setpag bit must be handled by * userspace) */ if (ntohl(*xdr++) != 0) goto not_xdr; datalen -= 4; /* check the cell name */ len = ntohl(*xdr++); if (len < 1 || len > AFSTOKEN_CELL_MAX) goto not_xdr; datalen -= 4; paddedlen = (len + 3) & ~3; if (paddedlen > datalen) goto not_xdr; cp = (const char *) xdr; for (loop = 0; loop < len; loop++) if (!isprint(cp[loop])) goto not_xdr; for (; loop < paddedlen; loop++) if (cp[loop]) goto not_xdr; _debug("cellname: [%u/%u] '%*.*s'", len, paddedlen, len, len, (const char *) xdr); datalen -= paddedlen; xdr += paddedlen >> 2; /* get the token count */ if (datalen < 12) goto not_xdr; ntoken = ntohl(*xdr++); datalen -= 4; _debug("ntoken: %x", ntoken); if (ntoken < 1 || ntoken > AFSTOKEN_MAX) goto not_xdr; /* check each token wrapper */ token = xdr; loop = ntoken; do { if (datalen < 8) goto not_xdr; toklen = ntohl(*xdr++); sec_ix = ntohl(*xdr); datalen -= 4; _debug("token: [%x/%zx] %x", toklen, datalen, sec_ix); paddedlen = (toklen + 3) & ~3; if (toklen < 20 || toklen > datalen || paddedlen > datalen) goto not_xdr; datalen -= paddedlen; xdr += paddedlen >> 2; } while (--loop > 0); _debug("remainder: %zu", datalen); if (datalen != 0) goto not_xdr; /* okay: we're going to assume it's valid XDR format * - we ignore the cellname, relying on the key to be correctly named */ do { xdr = token; toklen = ntohl(*xdr++); token = xdr + ((toklen + 3) >> 2); sec_ix = ntohl(*xdr++); toklen -= 4; _debug("TOKEN type=%u [%p-%p]", sec_ix, xdr, token); switch (sec_ix) { case RXRPC_SECURITY_RXKAD: ret = rxrpc_preparse_xdr_rxkad(prep, datalen, xdr, toklen); if (ret != 0) goto error; break; case RXRPC_SECURITY_RXK5: ret = rxrpc_preparse_xdr_rxk5(prep, datalen, xdr, toklen); if (ret != 0) goto error; break; default: ret = -EPROTONOSUPPORT; goto error; } } while (--ntoken > 0); _leave(" = 0"); return 0; not_xdr: _leave(" = -EPROTO"); return -EPROTO; error: _leave(" = %d", ret); return ret; }
0
[ "CWE-190" ]
linux
5f2f97656ada8d811d3c1bef503ced266fcd53a0
323,609,787,361,538,900,000,000,000,000,000,000,000
119
rxrpc: Fix several cases where a padded len isn't checked in ticket decode This fixes CVE-2017-7482. When a kerberos 5 ticket is being decoded so that it can be loaded into an rxrpc-type key, there are several places in which the length of a variable-length field is checked to make sure that it's not going to overrun the available data - but the data is padded to the nearest four-byte boundary and the code doesn't check for this extra. This could lead to the size-remaining variable wrapping and the data pointer going over the end of the buffer. Fix this by making the various variable-length data checks use the padded length. Reported-by: 石磊 <[email protected]> Signed-off-by: David Howells <[email protected]> Reviewed-by: Marc Dionne <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
bool chunking() const { return chunking_; }
0
[ "CWE-20" ]
libvpx
f00890eecdf8365ea125ac16769a83aa6b68792d
13,079,707,640,833,890,000,000,000,000,000,000,000
1
update libwebm to libwebm-1.0.0.27-352-g6ab9fcf https://chromium.googlesource.com/webm/libwebm/+log/af81f26..6ab9fcf Change-Id: I9d56e1fbaba9b96404b4fbabefddc1a85b79c25d
z_jbig2decode(i_ctx_t * i_ctx_p) { os_ptr op = osp; ref *sop = NULL; s_jbig2_global_data_t *gref; stream_jbig2decode_state state; /* Extract the global context reference, if any, from the parameter dictionary and embed it in our stream state. The original object ref is under the JBIG2Globals key. We expect the postscript code to resolve this and call z_jbig2makeglobalctx() below to create an astruct wrapping the global decoder data and store it under the .jbig2globalctx key */ s_jbig2decode_set_global_data((stream_state*)&state, NULL); if (r_has_type(op, t_dictionary)) { check_dict_read(*op); if ( dict_find_string(op, ".jbig2globalctx", &sop) > 0) { gref = r_ptr(sop, s_jbig2_global_data_t); s_jbig2decode_set_global_data((stream_state*)&state, gref); } } /* we pass npop=0, since we've no arguments left to consume */ return filter_read(i_ctx_p, 0, &s_jbig2decode_template, (stream_state *) & state, (sop ? r_space(sop) : 0)); }
1
[ "CWE-704" ]
ghostpdl
ef252e7dc214bcbd9a2539216aab9202848602bb
196,694,238,274,389,240,000,000,000,000,000,000,000
27
Bug #700168 - add a type check Bug #700168 "Type confusion in JBIG2Decode" The code was assuming that .jbig2globalctx was a structure allocated by the graphics library, without checking. Add a check to see that it is a structure and that its the correct type of structure.
PGPool OSD::_get_pool(int id, OSDMapRef createmap) { if (!createmap->have_pg_pool(id)) { dout(5) << __func__ << ": the OSDmap does not contain a PG pool with id = " << id << dendl; ceph_abort(); } PGPool p = PGPool(cct, createmap, id); dout(10) << "_get_pool " << p.id << dendl; return p; }
0
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
45,385,055,580,892,430,000,000,000,000,000,000,000
13
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
xfs_attr3_leaf_getvalue( struct xfs_buf *bp, struct xfs_da_args *args) { struct xfs_attr_leafblock *leaf; struct xfs_attr3_icleaf_hdr ichdr; struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_local *name_loc; struct xfs_attr_leaf_name_remote *name_rmt; int valuelen; leaf = bp->b_addr; xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf); ASSERT(ichdr.count < args->geo->blksize / 8); ASSERT(args->index < ichdr.count); entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); ASSERT(name_loc->namelen == args->namelen); ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0); valuelen = be16_to_cpu(name_loc->valuelen); if (args->flags & ATTR_KERNOVAL) { args->valuelen = valuelen; return 0; } if (args->valuelen < valuelen) { args->valuelen = valuelen; return -ERANGE; } args->valuelen = valuelen; memcpy(args->value, &name_loc->nameval[args->namelen], valuelen); } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); ASSERT(name_rmt->namelen == args->namelen); ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0); args->rmtvaluelen = be32_to_cpu(name_rmt->valuelen); args->rmtblkno = be32_to_cpu(name_rmt->valueblk); args->rmtblkcnt = xfs_attr3_rmt_blocks(args->dp->i_mount, args->rmtvaluelen); if (args->flags & ATTR_KERNOVAL) { args->valuelen = args->rmtvaluelen; return 0; } if (args->valuelen < args->rmtvaluelen) { args->valuelen = args->rmtvaluelen; return -ERANGE; } args->valuelen = args->rmtvaluelen; } return 0; }
0
[ "CWE-476" ]
linux
bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a
304,939,655,107,331,770,000,000,000,000,000,000,000
52
xfs: don't call xfs_da_shrink_inode with NULL bp xfs_attr3_leaf_create may have errored out before instantiating a buffer, for example if the blkno is out of range. In that case there is no work to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops if we try. This also seems to fix a flaw where the original error from xfs_attr3_leaf_create gets overwritten in the cleanup case, and it removes a pointless assignment to bp which isn't used after this. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969 Reported-by: Xu, Wen <[email protected]> Tested-by: Xu, Wen <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
mymain(void) { int ret; struct testChainData data; struct testLookupData data2; struct testPathCanonicalizeData data3; struct testPathRelativeBacking data4; struct testBackingParseData data5; virStorageSourcePtr chain2; /* short for chain->backingStore */ virStorageSourcePtr chain3; /* short for chain2->backingStore */ g_autoptr(virCommand) cmd = NULL; g_autoptr(virStorageSource) chain = NULL; if (storageRegisterAll() < 0) return EXIT_FAILURE; /* Prep some files with qemu-img; if that is not found on PATH, or * if it lacks support for qcow2 and qed, skip this test. */ if ((ret = testPrepImages()) != 0) return ret; #define TEST_ONE_CHAIN(start, format, flags, ...) \ do { \ size_t i; \ memset(&data, 0, sizeof(data)); \ data = (struct testChainData){ \ start, format, { __VA_ARGS__ }, 0, flags, \ }; \ for (i = 0; i < G_N_ELEMENTS(data.files); i++) \ if (data.files[i]) \ data.nfiles++; \ if (virTestRun(virTestCounterNext(), \ testStorageChain, &data) < 0) \ ret = -1; \ } while (0) #define VIR_FLATTEN_2(...) __VA_ARGS__ #define VIR_FLATTEN_1(_1) VIR_FLATTEN_2 _1 #define TEST_CHAIN(path, format, chain, flags) \ TEST_ONE_CHAIN(path, format, flags, VIR_FLATTEN_1(chain)); /* The actual tests, in several groups. */ virTestCounterReset("Storage backing chain "); /* Missing file */ TEST_ONE_CHAIN("bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL); /* Raw image, whether with right format or no specified format */ testFileData raw = { .path = absraw, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_RAW, }; TEST_CHAIN(absraw, VIR_STORAGE_FILE_RAW, (&raw), EXP_PASS); TEST_CHAIN(absraw, VIR_STORAGE_FILE_AUTO, (&raw), EXP_PASS); /* Qcow2 file with relative raw backing, format provided */ raw.pathRel = "raw"; testFileData qcow2 = { .expBackingStoreRaw = "raw", .expCapacity = 1024, .path = absqcow2, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QCOW2, }; testFileData qcow2_as_raw = { .path = absqcow2, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_RAW, }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS); TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS); /* Rewrite qcow2 file to use absolute backing name */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", absraw, "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = absraw; raw.pathRel = NULL; /* Qcow2 file with raw as absolute backing, backing format provided */ TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS); TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS); /* Wrapped file access */ testFileData wrap = { .expBackingStoreRaw = absqcow2, .expCapacity = 1024, .path = abswrap, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QCOW2, }; TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2, &raw), EXP_PASS); /* Rewrite qcow2 and wrap file to omit backing file type */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-b", absraw, "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-b", absqcow2, "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Qcow2 file with raw as absolute backing, backing format omitted */ testFileData wrap_as_raw = { .expBackingStoreRaw = absqcow2, .expCapacity = 1024, .path = abswrap, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QCOW2, }; TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap_as_raw, &qcow2_as_raw), EXP_FAIL); /* Rewrite qcow2 to a missing backing file, with backing type */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", datadir "/bogus", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = datadir "/bogus"; /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); /* Rewrite qcow2 to a missing backing file, without backing type */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-b", datadir "/bogus", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Qcow2 file with missing backing file and no specified type */ TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); /* Rewrite qcow2 to use an nbd: protocol as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "nbd:example.org:6000:exportname=blah", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "nbd:example.org:6000:exportname=blah"; /* Qcow2 file with backing protocol instead of file */ testFileData nbd = { .path = "blah", .type = VIR_STORAGE_TYPE_NETWORK, .format = VIR_STORAGE_FILE_RAW, .protocol = VIR_STORAGE_NET_PROTOCOL_NBD, .hostname = "example.org", }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd), EXP_PASS); /* Rewrite qcow2 to use an nbd: protocol as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "nbd+tcp://example.org:6000/blah", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "nbd+tcp://example.org:6000/blah"; /* Qcow2 file with backing protocol instead of file */ testFileData nbd2 = { .path = "blah", .type = VIR_STORAGE_TYPE_NETWORK, .format = VIR_STORAGE_FILE_RAW, .protocol = VIR_STORAGE_NET_PROTOCOL_NBD, .hostname = "example.org", }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS); /* Rewrite qcow2 to use an nbd: protocol without path as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "nbd://example.org", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "nbd://example.org"; nbd2.path = NULL; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS); /* qed file */ testFileData qed = { .expBackingStoreRaw = absraw, .expCapacity = 1024, .path = absqed, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QED, }; testFileData qed_as_raw = { .path = absqed, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_RAW, }; TEST_CHAIN(absqed, VIR_STORAGE_FILE_QED, (&qed, &raw), EXP_PASS); TEST_CHAIN(absqed, VIR_STORAGE_FILE_AUTO, (&qed_as_raw), EXP_PASS); /* directory */ testFileData dir = { .path = absdir, .type = VIR_STORAGE_TYPE_DIR, .format = VIR_STORAGE_FILE_DIR, }; testFileData dir_as_raw = { .path = absdir, .type = VIR_STORAGE_TYPE_DIR, .format = VIR_STORAGE_FILE_RAW, }; TEST_CHAIN(absdir, VIR_STORAGE_FILE_RAW, (&dir_as_raw), EXP_PASS); TEST_CHAIN(absdir, VIR_STORAGE_FILE_NONE, (&dir), EXP_PASS); TEST_CHAIN(absdir, VIR_STORAGE_FILE_DIR, (&dir), EXP_PASS); #ifdef HAVE_SYMLINK /* Rewrite qcow2 and wrap file to use backing names relative to a * symlink from a different directory */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "../raw", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", "../sub/link1", "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Behavior of symlinks to qcow2 with relative backing files */ testFileData link1 = { .expBackingStoreRaw = "../raw", .expCapacity = 1024, .pathRel = "../sub/link1", .path = datadir "/sub/../sub/link1", .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QCOW2, }; testFileData link2 = { .expBackingStoreRaw = "../sub/link1", .expCapacity = 1024, .path = abslink2, .type = VIR_STORAGE_TYPE_FILE, .format = VIR_STORAGE_FILE_QCOW2, }; raw.path = datadir "/sub/../sub/../raw"; raw.pathRel = "../raw"; TEST_CHAIN(abslink2, VIR_STORAGE_FILE_QCOW2, (&link2, &link1, &raw), EXP_PASS); #endif /* Rewrite qcow2 to be a self-referential loop */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", "qcow2", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "qcow2"; /* Behavior of an infinite loop chain */ TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); /* Rewrite wrap and qcow2 to be mutually-referential loop */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", "wrap", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", absqcow2, "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "wrap"; /* Behavior of an infinite loop chain */ TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2), EXP_FAIL); /* Rewrite qcow2 to use an rbd: protocol as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "rbd:testshare", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "rbd:testshare"; /* Qcow2 file with backing protocol instead of file */ testFileData rbd1 = { .path = "testshare", .type = VIR_STORAGE_TYPE_NETWORK, .format = VIR_STORAGE_FILE_RAW, .protocol = VIR_STORAGE_NET_PROTOCOL_RBD, }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd1), EXP_PASS); /* Rewrite qcow2 to use an rbd: protocol as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "rbd:testshare:id=asdf:mon_host=example.com", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; qcow2.expBackingStoreRaw = "rbd:testshare:id=asdf:mon_host=example.com"; /* Qcow2 file with backing protocol instead of file */ testFileData rbd2 = { .path = "testshare", .type = VIR_STORAGE_TYPE_NETWORK, .format = VIR_STORAGE_FILE_RAW, .protocol = VIR_STORAGE_NET_PROTOCOL_RBD, .secret = "asdf", .hostname = "example.com", }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd2), EXP_PASS); /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", absraw, "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Test behavior of chain lookups, absolute backing from relative start */ chain = testStorageFileGetMetadata("wrap", VIR_STORAGE_FILE_QCOW2, -1, -1); if (!chain) { ret = -1; goto cleanup; } chain2 = chain->backingStore; chain3 = chain2->backingStore; #define TEST_LOOKUP_TARGET(id, target, from, name, index, result, \ meta, parent) \ do { \ data2 = (struct testLookupData){ \ chain, target, from, name, index, \ result, meta, parent, }; \ if (virTestRun("Chain lookup " #id, \ testStorageLookup, &data2) < 0) \ ret = -1; \ } while (0) #define TEST_LOOKUP(id, from, name, result, meta, parent) \ TEST_LOOKUP_TARGET(id, NULL, from, name, 0, result, meta, parent) TEST_LOOKUP(0, NULL, "bogus", NULL, NULL, NULL); TEST_LOOKUP(1, chain, "bogus", NULL, NULL, NULL); TEST_LOOKUP(2, NULL, "wrap", chain->path, chain, NULL); TEST_LOOKUP(3, chain, "wrap", NULL, NULL, NULL); TEST_LOOKUP(4, chain2, "wrap", NULL, NULL, NULL); TEST_LOOKUP(5, NULL, abswrap, chain->path, chain, NULL); TEST_LOOKUP(6, chain, abswrap, NULL, NULL, NULL); TEST_LOOKUP(7, chain2, abswrap, NULL, NULL, NULL); TEST_LOOKUP(8, NULL, "qcow2", chain2->path, chain2, chain); TEST_LOOKUP(9, chain, "qcow2", chain2->path, chain2, chain); TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(12, NULL, absqcow2, chain2->path, chain2, chain); TEST_LOOKUP(13, chain, absqcow2, chain2->path, chain2, chain); TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL, NULL); TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL, NULL); TEST_LOOKUP(16, NULL, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(17, chain, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(18, chain2, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(19, chain3, "raw", NULL, NULL, NULL); TEST_LOOKUP(20, NULL, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(21, chain, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(22, chain2, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(23, chain3, absraw, NULL, NULL, NULL); TEST_LOOKUP(24, NULL, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(25, chain, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(26, chain2, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(27, chain3, NULL, NULL, NULL, NULL); /* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "raw", "-b", "raw", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", "qcow2", "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Test behavior of chain lookups, relative backing from absolute start */ virObjectUnref(chain); chain = testStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2, -1, -1); if (!chain) { ret = -1; goto cleanup; } chain2 = chain->backingStore; chain3 = chain2->backingStore; TEST_LOOKUP(28, NULL, "bogus", NULL, NULL, NULL); TEST_LOOKUP(29, chain, "bogus", NULL, NULL, NULL); TEST_LOOKUP(30, NULL, "wrap", chain->path, chain, NULL); TEST_LOOKUP(31, chain, "wrap", NULL, NULL, NULL); TEST_LOOKUP(32, chain2, "wrap", NULL, NULL, NULL); TEST_LOOKUP(33, NULL, abswrap, chain->path, chain, NULL); TEST_LOOKUP(34, chain, abswrap, NULL, NULL, NULL); TEST_LOOKUP(35, chain2, abswrap, NULL, NULL, NULL); TEST_LOOKUP(36, NULL, "qcow2", chain2->path, chain2, chain); TEST_LOOKUP(37, chain, "qcow2", chain2->path, chain2, chain); TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(40, NULL, absqcow2, chain2->path, chain2, chain); TEST_LOOKUP(41, chain, absqcow2, chain2->path, chain2, chain); TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL, NULL); TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL, NULL); TEST_LOOKUP(44, NULL, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(45, chain, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(46, chain2, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(47, chain3, "raw", NULL, NULL, NULL); TEST_LOOKUP(48, NULL, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(49, chain, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(50, chain2, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(51, chain3, absraw, NULL, NULL, NULL); TEST_LOOKUP(52, NULL, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(53, chain, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(54, chain2, NULL, chain3->path, chain3, chain2); TEST_LOOKUP(55, chain3, NULL, NULL, NULL, NULL); /* Use link to wrap with cross-directory relative backing */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", "-F", "qcow2", "-b", "../qcow2", "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; /* Test behavior of chain lookups, relative backing */ virObjectUnref(chain); chain = testStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCOW2, -1, -1); if (!chain) { ret = -1; goto cleanup; } chain2 = chain->backingStore; chain3 = chain2->backingStore; TEST_LOOKUP(56, NULL, "bogus", NULL, NULL, NULL); TEST_LOOKUP(57, NULL, "sub/link2", chain->path, chain, NULL); TEST_LOOKUP(58, NULL, "wrap", chain->path, chain, NULL); TEST_LOOKUP(59, NULL, abswrap, chain->path, chain, NULL); TEST_LOOKUP(60, NULL, "../qcow2", chain2->path, chain2, chain); TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(62, NULL, absqcow2, chain2->path, chain2, chain); TEST_LOOKUP(63, NULL, "raw", chain3->path, chain3, chain2); TEST_LOOKUP(64, NULL, absraw, chain3->path, chain3, chain2); TEST_LOOKUP(65, NULL, NULL, chain3->path, chain3, chain2); TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain->path, chain, NULL); TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2->path, chain2, chain); TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2->path, chain2, chain); TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 1, NULL, NULL, NULL); TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 1, NULL, NULL, NULL); TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3->path, chain3, chain2); TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3->path, chain3, chain2); TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3->path, chain3, chain2); TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 2, NULL, NULL, NULL); TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 3, NULL, NULL, NULL); #define TEST_PATH_CANONICALIZE(id, PATH, EXPECT) \ do { \ data3.path = PATH; \ data3.expect = EXPECT; \ if (virTestRun("Path canonicalize " #id, \ testPathCanonicalize, &data3) < 0) \ ret = -1; \ } while (0) TEST_PATH_CANONICALIZE(1, "/", "/"); TEST_PATH_CANONICALIZE(2, "/path", "/path"); TEST_PATH_CANONICALIZE(3, "/path/to/blah", "/path/to/blah"); TEST_PATH_CANONICALIZE(4, "/path/", "/path"); TEST_PATH_CANONICALIZE(5, "///////", "/"); TEST_PATH_CANONICALIZE(6, "//", "//"); TEST_PATH_CANONICALIZE(7, "", ""); TEST_PATH_CANONICALIZE(8, ".", "."); TEST_PATH_CANONICALIZE(9, "../", ".."); TEST_PATH_CANONICALIZE(10, "../../", "../.."); TEST_PATH_CANONICALIZE(11, "../../blah", "../../blah"); TEST_PATH_CANONICALIZE(12, "/./././blah", "/blah"); TEST_PATH_CANONICALIZE(13, ".././../././../blah", "../../../blah"); TEST_PATH_CANONICALIZE(14, "/././", "/"); TEST_PATH_CANONICALIZE(15, "./././", "."); TEST_PATH_CANONICALIZE(16, "blah/../foo", "foo"); TEST_PATH_CANONICALIZE(17, "foo/bar/../blah", "foo/blah"); TEST_PATH_CANONICALIZE(18, "foo/bar/.././blah", "foo/blah"); TEST_PATH_CANONICALIZE(19, "/path/to/foo/bar/../../../../../../../../baz", "/baz"); TEST_PATH_CANONICALIZE(20, "path/to/foo/bar/../../../../../../../../baz", "../../../../baz"); TEST_PATH_CANONICALIZE(21, "path/to/foo/bar", "path/to/foo/bar"); TEST_PATH_CANONICALIZE(22, "//foo//bar", "//foo/bar"); TEST_PATH_CANONICALIZE(23, "/bar//foo", "/bar/foo"); TEST_PATH_CANONICALIZE(24, "//../blah", "//blah"); /* test paths with symlinks */ TEST_PATH_CANONICALIZE(25, "/path/blah", "/other/path/huzah"); TEST_PATH_CANONICALIZE(26, "/path/to/relative/symlink", "/path/actual/file"); TEST_PATH_CANONICALIZE(27, "/path/to/relative/symlink/blah", "/path/actual/file/blah"); TEST_PATH_CANONICALIZE(28, "/path/blah/yippee", "/other/path/huzah/yippee"); TEST_PATH_CANONICALIZE(29, "/cycle", NULL); TEST_PATH_CANONICALIZE(30, "/cycle2/link", NULL); TEST_PATH_CANONICALIZE(31, "///", "/"); #define TEST_RELATIVE_BACKING(id, TOP, BASE, EXPECT) \ do { \ data4.top = &TOP; \ data4.base = &BASE; \ data4.expect = EXPECT; \ if (virTestRun("Path relative resolve " #id, \ testPathRelative, &data4) < 0) \ ret = -1; \ } while (0) testPathRelativePrepare(); /* few negative tests first */ /* a non-relative image is in the backing chain span */ TEST_RELATIVE_BACKING(1, backingchain[0], backingchain[1], NULL); TEST_RELATIVE_BACKING(2, backingchain[0], backingchain[2], NULL); TEST_RELATIVE_BACKING(3, backingchain[0], backingchain[3], NULL); TEST_RELATIVE_BACKING(4, backingchain[1], backingchain[5], NULL); /* image is not in chain (specified backwards) */ TEST_RELATIVE_BACKING(5, backingchain[2], backingchain[1], NULL); /* positive tests */ TEST_RELATIVE_BACKING(6, backingchain[1], backingchain[1], "asdf"); TEST_RELATIVE_BACKING(7, backingchain[1], backingchain[2], "test"); TEST_RELATIVE_BACKING(8, backingchain[1], backingchain[3], "blah"); TEST_RELATIVE_BACKING(9, backingchain[2], backingchain[2], "test"); TEST_RELATIVE_BACKING(10, backingchain[2], backingchain[3], "blah"); TEST_RELATIVE_BACKING(11, backingchain[3], backingchain[3], "blah"); /* oVirt spelling */ TEST_RELATIVE_BACKING(12, backingchain[5], backingchain[5], "../volume/image2"); TEST_RELATIVE_BACKING(13, backingchain[5], backingchain[6], "../volume/../volume/image3"); TEST_RELATIVE_BACKING(14, backingchain[5], backingchain[7], "../volume/../volume/../volume/image4"); TEST_RELATIVE_BACKING(15, backingchain[6], backingchain[6], "../volume/image3"); TEST_RELATIVE_BACKING(16, backingchain[6], backingchain[7], "../volume/../volume/image4"); TEST_RELATIVE_BACKING(17, backingchain[7], backingchain[7], "../volume/image4"); /* crazy spellings */ TEST_RELATIVE_BACKING(17, backingchain[9], backingchain[9], "directory/stuff/volumes/garbage/image2"); TEST_RELATIVE_BACKING(18, backingchain[9], backingchain[10], "directory/stuff/volumes/garbage/../../../image3"); TEST_RELATIVE_BACKING(19, backingchain[9], backingchain[11], "directory/stuff/volumes/garbage/../../../../blah/image4"); TEST_RELATIVE_BACKING(20, backingchain[10], backingchain[10], "../../../image3"); TEST_RELATIVE_BACKING(21, backingchain[10], backingchain[11], "../../../../blah/image4"); TEST_RELATIVE_BACKING(22, backingchain[11], backingchain[11], "../blah/image4"); virTestCounterReset("Backing store parse "); #define TEST_BACKING_PARSE_FULL(bck, xml, rc) \ do { \ data5.backing = bck; \ data5.expect = xml; \ data5.rv = rc; \ if (virTestRun(virTestCounterNext(), \ testBackingParse, &data5) < 0) \ ret = -1; \ } while (0) #define TEST_BACKING_PARSE(bck, xml) \ TEST_BACKING_PARSE_FULL(bck, xml, 0) TEST_BACKING_PARSE("path", "<source file='path'/>\n"); TEST_BACKING_PARSE("fat:/somedir", "<source dir='/somedir'/>\n"); TEST_BACKING_PARSE("://", NULL); TEST_BACKING_PARSE("http://example.com", "<source protocol='http' name=''>\n" " <host name='example.com' port='80'/>\n" "</source>\n"); TEST_BACKING_PARSE("http://example.com/", "<source protocol='http' name=''>\n" " <host name='example.com' port='80'/>\n" "</source>\n"); TEST_BACKING_PARSE("http://example.com/file", "<source protocol='http' name='file'>\n" " <host name='example.com' port='80'/>\n" "</source>\n"); TEST_BACKING_PARSE_FULL("http://user:[email protected]/file", "<source protocol='http' name='file'>\n" " <host name='example.com' port='80'/>\n" "</source>\n", 1); TEST_BACKING_PARSE("rbd:testshare:id=asdf:mon_host=example.com", "<source protocol='rbd' name='testshare'>\n" " <host name='example.com'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd:example.org:6000:exportname=blah", "<source protocol='nbd' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:", "<source protocol='nbd' name=':'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd:example.org:6000:exportname=:test", "<source protocol='nbd' name=':test'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd:unix:/tmp/sock:exportname=/", "<source protocol='nbd' name='/'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd://example.org:1234", "<source protocol='nbd'>\n" " <host name='example.org' port='1234'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd://example.org:1234/", "<source protocol='nbd'>\n" " <host name='example.org' port='1234'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd://example.org:1234/exportname", "<source protocol='nbd' name='exportname'>\n" " <host name='example.org' port='1234'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd+unix://?socket=/tmp/sock", "<source protocol='nbd'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd+unix:///?socket=/tmp/sock", "<source protocol='nbd'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd+unix:////?socket=/tmp/sock", "<source protocol='nbd' name='/'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd+unix:///exp?socket=/tmp/sock", "<source protocol='nbd' name='exp'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE("nbd+unix:////exp?socket=/tmp/sock", "<source protocol='nbd' name='/exp'>\n" " <host transport='unix' socket='/tmp/sock'/>\n" "</source>\n"); TEST_BACKING_PARSE_FULL("iscsi://testuser:[email protected]:1234/exportname", "<source protocol='iscsi' name='exportname'>\n" " <host name='example.org' port='1234'/>\n" "</source>\n", 1); #ifdef WITH_YAJL TEST_BACKING_PARSE("json:", NULL); TEST_BACKING_PARSE("json:asdgsdfg", NULL); TEST_BACKING_PARSE("json:{}", NULL); TEST_BACKING_PARSE("json: { \"file.driver\":\"blah\"}", NULL); TEST_BACKING_PARSE("json:{\"file.driver\":\"file\"}", NULL); TEST_BACKING_PARSE("json:{\"file.driver\":\"file\", " "\"file.filename\":\"/path/to/file\"}", "<source file='/path/to/file'/>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"file\", " "\"filename\":\"/path/to/file\"}", NULL); TEST_BACKING_PARSE("json:{\"file\" : { \"driver\":\"file\"," "\"filename\":\"/path/to/file\"" "}" "}", "<source file='/path/to/file'/>\n"); TEST_BACKING_PARSE("json:{\"driver\":\"file\"," "\"filename\":\"/path/to/file\"" "}", "<source file='/path/to/file'/>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"host_device\", " "\"file.filename\":\"/path/to/dev\"}", "<source dev='/path/to/dev'/>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"host_cdrom\", " "\"file.filename\":\"/path/to/cdrom\"}", "<source dev='/path/to/cdrom'/>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"http\", " "\"file.url\":\"http://example.com/file\"}", "<source protocol='http' name='file'>\n" " <host name='example.com' port='80'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{ \"driver\":\"http\"," "\"url\":\"http://example.com/file\"" "}" "}", "<source protocol='http' name='file'>\n" " <host name='example.com' port='80'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"ftp\", " "\"file.url\":\"http://example.com/file\"}", NULL); TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\", " "\"file.filename\":\"gluster://example.com/vol/file\"}", "<source protocol='gluster' name='vol/file'>\n" " <host name='example.com' port='24007'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"gluster\"," "\"volume\":\"testvol\"," "\"path\":\"img.qcow2\"," "\"server\":[ { \"type\":\"tcp\"," "\"host\":\"example.com\"," "\"port\":\"1234\"" "}," "{ \"type\":\"unix\"," "\"socket\":\"/path/socket\"" "}," "{ \"type\":\"tcp\"," "\"host\":\"example.com\"" "}" "]" "}" "}", "<source protocol='gluster' name='testvol/img.qcow2'>\n" " <host name='example.com' port='1234'/>\n" " <host transport='unix' socket='/path/socket'/>\n" " <host name='example.com' port='24007'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"gluster\"," "\"file.volume\":\"testvol\"," "\"file.path\":\"img.qcow2\"," "\"file.server\":[ { \"type\":\"tcp\"," "\"host\":\"example.com\"," "\"port\":\"1234\"" "}," "{ \"type\":\"unix\"," "\"socket\":\"/path/socket\"" "}," "{ \"type\":\"inet\"," "\"host\":\"example.com\"" "}" "]" "}", "<source protocol='gluster' name='testvol/img.qcow2'>\n" " <host name='example.com' port='1234'/>\n" " <host transport='unix' socket='/path/socket'/>\n" " <host name='example.com' port='24007'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"driver\": \"raw\"," "\"file\": {\"server.0.host\": \"A.A.A.A\"," "\"server.1.host\": \"B.B.B.B\"," "\"server.2.host\": \"C.C.C.C\"," "\"driver\": \"gluster\"," "\"path\": \"raw\"," "\"server.0.type\": \"tcp\"," "\"server.1.type\": \"tcp\"," "\"server.2.type\": \"tcp\"," "\"server.0.port\": \"24007\"," "\"server.1.port\": \"24007\"," "\"server.2.port\": \"24007\"," "\"volume\": \"vol1\"}}", "<source protocol='gluster' name='vol1/raw'>\n" " <host name='A.A.A.A' port='24007'/>\n" " <host name='B.B.B.B' port='24007'/>\n" " <host name='C.C.C.C' port='24007'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," "\"path\":\"/path/to/socket\"" "}" "}", "<source protocol='nbd'>\n" " <host transport='unix' socket='/path/to/socket'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"driver\":\"nbd\"," "\"path\":\"/path/to/socket\"" "}", "<source protocol='nbd'>\n" " <host transport='unix' socket='/path/to/socket'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"nbd\"," "\"file.path\":\"/path/to/socket\"" "}", "<source protocol='nbd'>\n" " <host transport='unix' socket='/path/to/socket'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," "\"export\":\"blah\"," "\"host\":\"example.org\"," "\"port\":\"6000\"" "}" "}", "<source protocol='nbd' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"nbd\"," "\"file.export\":\"blah\"," "\"file.host\":\"example.org\"," "\"file.port\":\"6000\"" "}", "<source protocol='nbd' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," "\"export\":\"blah\"," "\"server\": { \"type\":\"inet\"," "\"host\":\"example.org\"," "\"port\":\"6000\"" "}" "}" "}", "<source protocol='nbd' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"nbd\"," "\"server\": { \"type\":\"unix\"," "\"path\":\"/path/socket\"" "}" "}" "}", "<source protocol='nbd'>\n" " <host transport='unix' socket='/path/socket'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\"," "\"host\":\"example.org\"," "\"port\":\"6000\"," "\"path\":\"blah\"," "\"user\":\"user\"" "}" "}", "<source protocol='ssh' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"ssh\"," "\"file.host\":\"example.org\"," "\"file.port\":\"6000\"," "\"file.path\":\"blah\"," "\"file.user\":\"user\"" "}", "<source protocol='ssh' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"ssh\"," "\"path\":\"blah\"," "\"server\":{ \"host\":\"example.org\"," "\"port\":\"6000\"" "}," "\"user\":\"user\"" "}" "}", "<source protocol='ssh' name='blah'>\n" " <host name='example.org' port='6000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file.driver\":\"rbd\"," "\"file.filename\":\"rbd:testshare:id=asdf:mon_host=example.com\"" "}", "<source protocol='rbd' name='testshare'>\n" " <host name='example.com'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"rbd\"," "\"image\":\"test\"," "\"pool\":\"libvirt\"," "\"conf\":\"/path/to/conf\"," "\"snapshot\":\"snapshotname\"," "\"server\":[ {\"host\":\"example.com\"," "\"port\":\"1234\"" "}," "{\"host\":\"example2.com\"" "}" "]" "}" "}", "<source protocol='rbd' name='libvirt/test'>\n" " <host name='example.com' port='1234'/>\n" " <host name='example2.com'/>\n" " <snapshot name='snapshotname'/>\n" " <config file='/path/to/conf'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{ \"file\": { " "\"driver\": \"raw\"," "\"file\": {" "\"driver\": \"file\"," "\"filename\": \"/path/to/file\" } } }", "<source file='/path/to/file'/>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"test.org\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\"" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/0'>\n" " <host name='test.org' port='3260'/>\n" "</source>\n"); TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"test.org\"," "\"user\":\"testuser\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-auth.target\"" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-auth.target/0'>\n" " <host name='test.org' port='3260'/>\n" "</source>\n", 1); TEST_BACKING_PARSE_FULL("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"test.org\"," "\"password\":\"testpass\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-auth.target\"" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-auth.target/0'>\n" " <host name='test.org' port='3260'/>\n" "</source>\n", 1); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"test.org:1234\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\"," "\"lun\":\"6\"" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n" " <host name='test.org' port='1234'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"[2001::0]:1234\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\"," "\"lun\":6" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n" " <host name='[2001::0]' port='1234'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"iscsi\"," "\"transport\":\"tcp\"," "\"portal\":\"[2001::0]\"," "\"target\":\"iqn.2016-12.com.virttest:emulated-iscsi-noauth.target\"," "\"lun\":6" "}" "}", "<source protocol='iscsi' name='iqn.2016-12.com.virttest:emulated-iscsi-noauth.target/6'>\n" " <host name='[2001::0]' port='3260'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"sheepdog\"," "\"vdi\":\"test\"," "\"server\":{ \"type\":\"inet\"," "\"host\":\"example.com\"," "\"port\":\"321\"" "}" "}" "}", "<source protocol='sheepdog' name='test'>\n" " <host name='example.com' port='321'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"driver\": \"raw\"," "\"file\": {\"server.host\": \"10.10.10.10\"," "\"server.port\": \"7000\"," "\"tag\": \"\"," "\"driver\": \"sheepdog\"," "\"server.type\": \"inet\"," "\"vdi\": \"Alice\"}}", "<source protocol='sheepdog' name='Alice'>\n" " <host name='10.10.10.10' port='7000'/>\n" "</source>\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\"," "\"vdisk-id\":\"c6718f6b-0401-441d-a8c3-1f0064d75ee0\"," "\"server\": { \"host\":\"example.com\"," "\"port\":\"9999\"" "}" "}" "}", "<source protocol='vxhs' name='c6718f6b-0401-441d-a8c3-1f0064d75ee0'>\n" " <host name='example.com' port='9999'/>\n" "</source>\n"); TEST_BACKING_PARSE_FULL("json:{ \"driver\": \"raw\"," "\"offset\": 10752," "\"size\": 4063232," "\"file\": { \"driver\": \"file\"," "\"filename\": \"/tmp/testfle\"" "}" "}", "<source file='/tmp/testfle'>\n" " <slices>\n" " <slice type='storage' offset='10752' size='4063232'/>\n" " </slices>\n" "</source>\n", 0); TEST_BACKING_PARSE_FULL("json:{ \"file.cookie\": \"vmware_soap_session=\\\"0c8db85112873a79b7ef74f294cb70ef7f\\\"\"," "\"file.sslverify\": false," "\"file.driver\": \"https\"," "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&amp;dsName=esx6.5-matrix'>\n" " <host name='host' port='443'/>\n" " <ssl verify='no'/>\n" " <cookies>\n" " <cookie name='vmware_soap_session'>&quot;0c8db85112873a79b7ef74f294cb70ef7f&quot;</cookie>\n" " </cookies>\n" " <timeout seconds='2000'/>\n" "</source>\n", 0); TEST_BACKING_PARSE_FULL("json:{ \"file.cookie\": \"vmware_soap_session=\\\"0c8db85112873a79b7ef74f294cb70ef7f\\\"\"," "\"file.sslverify\": \"off\"," "\"file.driver\": \"https\"," "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&amp;dsName=esx6.5-matrix'>\n" " <host name='host' port='443'/>\n" " <ssl verify='no'/>\n" " <cookies>\n" " <cookie name='vmware_soap_session'>&quot;0c8db85112873a79b7ef74f294cb70ef7f&quot;</cookie>\n" " </cookies>\n" " <timeout seconds='2000'/>\n" "</source>\n", 0); TEST_BACKING_PARSE("json:{\"file\":{\"driver\": \"nvme\"," "\"device\": \"0000:01:00.0\"," "\"namespace\": 1" "}" "}", "<source type='pci' namespace='1'>\n" " <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>\n" "</source>\n"); #endif /* WITH_YAJL */ cleanup: /* Final cleanup */ testCleanupImages(); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
0
[ "CWE-212" ]
libvirt
524de6cc35d3b222f0e940bb0fd027f5482572c5
170,089,631,547,918,630,000,000,000,000,000,000,000
1,041
virstoragetest: testBackingParse: Use VIR_DOMAIN_DEF_FORMAT_SECURE when formatting xml We want to format even the secure information in tests. Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
ccss_property (CRDocHandler * a_handler, CRString * a_name, CRTerm * a_expr, gboolean a_important) { CSSUserData *user_data; gchar *name = NULL; size_t len = 0; g_return_if_fail (a_handler); user_data = (CSSUserData *) a_handler->app_data; if (a_name && a_expr && user_data->selector) { CRSelector *cur; for (cur = user_data->selector; cur; cur = cur->next) { if (cur->simple_sel) { gchar *selector = (gchar *) cr_simple_sel_to_string (cur->simple_sel); if (selector) { gchar *style_name, *style_value; name = (gchar *) cr_string_peek_raw_str (a_name); len = cr_string_peek_raw_str_len (a_name); style_name = g_strndup (name, len); style_value = (gchar *)cr_term_to_string (a_expr); rsvg_css_define_style (user_data->ctx, selector, style_name, style_value, a_important); g_free (selector); g_free (style_name); g_free (style_value); } } } } }
0
[ "CWE-20" ]
librsvg
d1c9191949747f6dcfd207831d15dd4ba00e31f2
132,042,564,647,118,780,000,000,000,000,000,000,000
34
state: Store mask as reference Instead of immediately looking up the mask, store the reference and look it up on use.
static void kvm_ioapic_reset(struct kvm_ioapic *ioapic) { int i; cancel_delayed_work_sync(&ioapic->eoi_inject); for (i = 0; i < IOAPIC_NUM_PINS; i++) ioapic->redirtbl[i].fields.mask = 1; ioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS; ioapic->ioregsel = 0; ioapic->irr = 0; ioapic->irr_delivered = 0; ioapic->id = 0; memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi)); rtc_irq_eoi_tracking_reset(ioapic); }
0
[ "CWE-703", "CWE-125" ]
linux
81cdb259fb6d8c1c4ecfeea389ff5a73c07f5755
166,721,495,299,928,740,000,000,000,000,000,000,000
15
KVM: x86: fix out-of-bounds accesses of rtc_eoi map KVM was using arrays of size KVM_MAX_VCPUS with vcpu_id, but ID can be bigger that the maximal number of VCPUs, resulting in out-of-bounds access. Found by syzkaller: BUG: KASAN: slab-out-of-bounds in __apic_accept_irq+0xb33/0xb50 at addr [...] Write of size 1 by task a.out/27101 CPU: 1 PID: 27101 Comm: a.out Not tainted 4.9.0-rc5+ #49 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [...] Call Trace: [...] __apic_accept_irq+0xb33/0xb50 arch/x86/kvm/lapic.c:905 [...] kvm_apic_set_irq+0x10e/0x180 arch/x86/kvm/lapic.c:495 [...] kvm_irq_delivery_to_apic+0x732/0xc10 arch/x86/kvm/irq_comm.c:86 [...] ioapic_service+0x41d/0x760 arch/x86/kvm/ioapic.c:360 [...] ioapic_set_irq+0x275/0x6c0 arch/x86/kvm/ioapic.c:222 [...] kvm_ioapic_inject_all arch/x86/kvm/ioapic.c:235 [...] kvm_set_ioapic+0x223/0x310 arch/x86/kvm/ioapic.c:670 [...] kvm_vm_ioctl_set_irqchip arch/x86/kvm/x86.c:3668 [...] kvm_arch_vm_ioctl+0x1a08/0x23c0 arch/x86/kvm/x86.c:3999 [...] kvm_vm_ioctl+0x1fa/0x1a70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3099 Reported-by: Dmitry Vyukov <[email protected]> Cc: [email protected] Fixes: af1bae5497b9 ("KVM: x86: bump KVM_MAX_VCPU_ID to 1023") Reviewed-by: Paolo Bonzini <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Signed-off-by: Radim Krčmář <[email protected]>
static int ZEND_FASTCALL ZEND_IS_NOT_IDENTICAL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *result = &EX_T(opline->result.u.var).tmp_var; is_identical_function(result, _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC), _get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC) TSRMLS_CC); Z_LVAL_P(result) = !Z_LVAL_P(result); zval_dtor(free_op1.var); ZEND_VM_NEXT_OPCODE(); }
0
[]
php-src
ce96fd6b0761d98353761bf78d5bfb55291179fd
74,194,294,258,575,030,000,000,000,000,000,000,000
14
- fix #39863, do not accept paths with NULL in them. See http://news.php.net/php.internals/50191, trunk will have the patch later (adding a macro and/or changing (some) APIs. Patch by Rasmus
static void PreservePSDOpacityMask(Image *image,LayerInfo* layer_info, ExceptionInfo *exception) { char *key; RandomInfo *random_info; StringInfo *key_info; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " preserving opacity mask"); random_info=AcquireRandomInfo(); key_info=GetRandomKey(random_info,2+1); key=(char *) GetStringInfoDatum(key_info); key[8]=(char ) layer_info->mask.background; key[9]='\0'; layer_info->mask.image->page.x+=layer_info->page.x; layer_info->mask.image->page.y+=layer_info->page.y; (void) SetImageRegistry(ImageRegistryType,(const char *) key, layer_info->mask.image,exception); (void) SetImageArtifact(layer_info->image,"psd:opacity-mask", (const char *) key); key_info=DestroyStringInfo(key_info); random_info=DestroyRandomInfo(random_info); }
0
[ "CWE-399", "CWE-401" ]
ImageMagick
8a43abefb38c5e29138e1c9c515b313363541c06
79,428,252,036,048,290,000,000,000,000,000,000,000
29
https://github.com/ImageMagick/ImageMagick/issues/1451
struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned int family) { struct xfrm_state_afinfo *afinfo; if (unlikely(family >= NPROTO)) return NULL; rcu_read_lock(); afinfo = rcu_dereference(xfrm_state_afinfo[family]); if (unlikely(!afinfo)) rcu_read_unlock(); return afinfo; }
0
[ "CWE-416" ]
linux
dbb2483b2a46fbaf833cfb5deb5ed9cace9c7399
86,227,765,158,545,270,000,000,000,000,000,000,000
11
xfrm: clean up xfrm protocol checks In commit 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") I introduced a check for xfrm protocol, but according to Herbert IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so it should be removed from validate_tmpl(). And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific protocols, this is why xfrm_state_flush() could still miss IPPROTO_ROUTING, which leads that those entries are left in net->xfrm.state_all before exit net. Fix this by replacing IPSEC_PROTO_ANY with zero. This patch also extracts the check from validate_tmpl() to xfrm_id_proto_valid() and uses it in parse_ipsecrequest(). With this, no other protocols should be added into xfrm. Fixes: 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") Reported-by: [email protected] Cc: Steffen Klassert <[email protected]> Cc: Herbert Xu <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
static int segmented_read(struct x86_emulate_ctxt *ctxt, struct segmented_address addr, void *data, unsigned size) { int rc; ulong linear; rc = linearize(ctxt, addr, size, false, &linear); if (rc != X86EMUL_CONTINUE) return rc; return read_emulated(ctxt, linear, data, size); }
0
[]
kvm
e28ba7bb020f07193bc000453c8775e9d2c0dda7
145,038,736,722,429,470,000,000,000,000,000,000,000
13
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]>
DLLIMPORT int cfg_setlist(cfg_t *cfg, const char *name, unsigned int nvalues, ...) { va_list ap; cfg_opt_t *opt = cfg_getopt(cfg, name); if (!opt || !is_set(CFGF_LIST, opt->flags)) { errno = EINVAL; return CFG_FAIL; } cfg_free_value(opt); va_start(ap, nvalues); cfg_addlist_internal(opt, nvalues, ap); va_end(ap); return CFG_SUCCESS; }
0
[]
libconfuse
d73777c2c3566fb2647727bb56d9a2295b81669b
215,499,405,682,784,350,000,000,000,000,000,000,000
17
Fix #163: unterminated username used with getpwnam() Signed-off-by: Joachim Wiberg <[email protected]>
read_mysql_variables_from_result(MYSQL_RES *mysql_result, mysql_variable *vars, bool vertical_result) { MYSQL_ROW row; mysql_variable *var; ut_ad(!vertical_result || mysql_num_fields(mysql_result) == 2); int rows_read = 0; if (vertical_result) { while ((row = mysql_fetch_row(mysql_result))) { ++rows_read; char *name = row[0]; char *value = row[1]; for (var = vars; var->name; var++) { if (strcmp(var->name, name) == 0 && value != NULL) { *(var->value) = strdup(value); } } } } else { MYSQL_FIELD *field; if ((row = mysql_fetch_row(mysql_result)) != NULL) { mysql_field_seek(mysql_result, 0); ++rows_read; int i = 0; while ((field = mysql_fetch_field(mysql_result)) != NULL) { char *name = field->name; char *value = row[i]; for (var = vars; var->name; var++) { if (strcmp(var->name, name) == 0 && value != NULL) { *(var->value) = strdup(value); } } ++i; } } } return rows_read; }
0
[ "CWE-200" ]
percona-xtrabackup
7742f875bb289a874246fb4653b7cd9f14b588fe
35,391,834,231,759,937,000,000,000,000,000,000,000
43
PXB-2722 password is written into xtrabackup_info https://jira.percona.com/browse/PXB-2722 Analysis: password passed with -p option is written into backup tool_command in xtrabackup_info Fix: mask password before writting into xtrabackup_info
GF_Err gf_odf_write_descriptor(GF_BitStream *bs, GF_Descriptor *desc) { switch(desc->tag) { case GF_ODF_IOD_TAG : return gf_odf_write_iod(bs, (GF_InitialObjectDescriptor *)desc); case GF_ODF_ESD_TAG : return gf_odf_write_esd(bs, (GF_ESD *)desc); case GF_ODF_DCD_TAG : return gf_odf_write_dcd(bs, (GF_DecoderConfig *)desc); case GF_ODF_SLC_TAG : return gf_odf_write_slc(bs, (GF_SLConfig *)desc); case GF_ODF_ESD_INC_TAG: return gf_odf_write_esd_inc(bs, (GF_ES_ID_Inc *)desc); case GF_ODF_ESD_REF_TAG: return gf_odf_write_esd_ref(bs, (GF_ES_ID_Ref *)desc); case GF_ODF_ISOM_IOD_TAG: return gf_odf_write_isom_iod(bs, (GF_IsomInitialObjectDescriptor *)desc); case GF_ODF_ISOM_OD_TAG: return gf_odf_write_isom_od(bs, (GF_IsomObjectDescriptor *)desc); case GF_ODF_OD_TAG: return gf_odf_write_od(bs, (GF_ObjectDescriptor *)desc); case GF_ODF_SEGMENT_TAG: return gf_odf_write_segment(bs, (GF_Segment *) desc); case GF_ODF_MUXINFO_TAG: return gf_odf_write_muxinfo(bs, (GF_MuxInfo *) desc); case GF_ODF_AUX_VIDEO_DATA: return gf_odf_write_auxvid(bs, (GF_AuxVideoDescriptor *)desc); case GF_ODF_LANG_TAG: case GF_ODF_GPAC_LANG: return gf_odf_write_lang(bs, (GF_Language *)desc); #ifndef GPAC_MINIMAL_ODF case GF_ODF_MEDIATIME_TAG: return gf_odf_write_mediatime(bs, (GF_MediaTime *) desc); case GF_ODF_CC_TAG: return gf_odf_write_cc(bs, (GF_CCDescriptor *)desc); case GF_ODF_CC_DATE_TAG: return gf_odf_write_cc_date(bs, (GF_CC_Date *)desc); case GF_ODF_CC_NAME_TAG: return gf_odf_write_cc_name(bs, (GF_CC_Name *)desc); case GF_ODF_CI_TAG: return gf_odf_write_ci(bs, (GF_CIDesc *)desc); case GF_ODF_TEXT_TAG: return gf_odf_write_exp_text(bs, (GF_ExpandedTextual *)desc); case GF_ODF_EXT_PL_TAG: return gf_odf_write_pl_ext(bs, (GF_PLExt *)desc); case GF_ODF_IPI_PTR_TAG: case GF_ODF_ISOM_IPI_PTR_TAG: return gf_odf_write_ipi_ptr(bs, (GF_IPIPtr *)desc); case GF_ODF_IPMP_TAG: return gf_odf_write_ipmp(bs, (GF_IPMP_Descriptor *)desc); case GF_ODF_IPMP_PTR_TAG: return gf_odf_write_ipmp_ptr(bs, (GF_IPMPPtr *)desc); case GF_ODF_KW_TAG: return gf_odf_write_kw(bs, (GF_KeyWord *)desc); case GF_ODF_OCI_DATE_TAG: return gf_odf_write_oci_date(bs, (GF_OCI_Data *)desc); case GF_ODF_OCI_NAME_TAG: return gf_odf_write_oci_name(bs, (GF_OCICreators *)desc); case GF_ODF_PL_IDX_TAG: return gf_odf_write_pl_idx(bs, (GF_PL_IDX *)desc); case GF_ODF_QOS_TAG: return gf_odf_write_qos(bs, (GF_QoS_Descriptor *)desc); case GF_ODF_RATING_TAG: return gf_odf_write_rating(bs, (GF_Rating *)desc); case GF_ODF_REG_TAG: return gf_odf_write_reg(bs, (GF_Registration *)desc); case GF_ODF_SHORT_TEXT_TAG: return gf_odf_write_short_text(bs, (GF_ShortTextual *)desc); case GF_ODF_SMPTE_TAG: return gf_odf_write_smpte_camera(bs, (GF_SMPTECamera *)desc); case GF_ODF_SCI_TAG: return gf_odf_write_sup_cid(bs, (GF_SCIDesc *)desc); case GF_ODF_IPMP_TL_TAG: return gf_odf_write_ipmp_tool_list(bs, (GF_IPMP_ToolList *)desc); case GF_ODF_IPMP_TOOL_TAG: return gf_odf_write_ipmp_tool(bs, (GF_IPMP_Tool *)desc); #endif /*GPAC_MINIMAL_ODF*/ default: /*don't write out internal descriptors*/ if ((desc->tag>=GF_ODF_MUXINFO_TAG) && (desc->tag<=GF_ODF_LASER_CFG_TAG)) return GF_OK; return gf_odf_write_default(bs, (GF_DefaultDescriptor *)desc); } return GF_OK; }
0
[ "CWE-787" ]
gpac
4e56ad72ac1afb4e049a10f2d99e7512d7141f9d
237,100,867,371,593,070,000,000,000,000,000,000,000
92
fixed #2216
mode_t MirrorJob::get_mode_mask() { mode_t mode_mask=0; if(!FlagSet(ALLOW_SUID)) mode_mask|=S_ISUID|S_ISGID; if(!FlagSet(NO_UMASK)) { if(target_is_local) { mode_t u=umask(022); // get+set umask(u); // retore mode_mask|=u; } else mode_mask|=022; // sane default. } return mode_mask; }
0
[ "CWE-20", "CWE-401" ]
lftp
a27e07d90a4608ceaf928b1babb27d4d803e1992
136,009,336,711,029,650,000,000,000,000,000,000,000
18
mirror: prepend ./ to rm and chmod arguments to avoid URL recognition (fix #452)
static int acurite_986_decode(r_device *decoder, bitbuffer_t *bitbuffer) { int const browlen = 5; uint8_t *bb, sensor_num, status, crc, crcc; uint8_t br[8]; int8_t tempf; // Raw Temp is 8 bit signed Fahrenheit uint16_t sensor_id, valid_cnt = 0; char sensor_type; char *channel_str; int battery_low; data_t *data; int result = 0; for (uint16_t brow = 0; brow < bitbuffer->num_rows; ++brow) { decoder_logf(decoder, 2, __func__, "row %u bits %u, bytes %d", brow, bitbuffer->bits_per_row[brow], browlen); if (bitbuffer->bits_per_row[brow] < 39 || bitbuffer->bits_per_row[brow] > 43 ) { if (bitbuffer->bits_per_row[brow] > 16) decoder_log(decoder, 2, __func__,"skipping wrong len"); result = DECODE_ABORT_LENGTH; continue; // DECODE_ABORT_LENGTH } bb = bitbuffer->bb[brow]; // Reduce false positives // may eliminate these with a better PPM (precise?) demod. if ((bb[0] == 0xff && bb[1] == 0xff && bb[2] == 0xff) || (bb[0] == 0x00 && bb[1] == 0x00 && bb[2] == 0x00)) { result = DECODE_ABORT_EARLY; continue; // DECODE_ABORT_EARLY } // Reverse the bits, msg sent LSB first for (int i = 0; i < browlen; i++) br[i] = reverse8(bb[i]); decoder_log_bitrow(decoder, 1, __func__, br, browlen * 8, "reversed"); tempf = br[0]; sensor_id = (br[1] << 8) + br[2]; status = br[3]; sensor_num = (status & 0x01) + 1; status = status >> 1; battery_low = ((status & 1) == 1); // By default Sensor 1 is the Freezer, 2 Refrigerator sensor_type = sensor_num == 2 ? 'F' : 'R'; channel_str = sensor_num == 2 ? "2F" : "1R"; crc = br[4]; crcc = crc8le(br, 4, 0x07, 0); if (crcc != crc) { decoder_logf_bitrow(decoder, 2, __func__, br, browlen * 8, "bad CRC: %02x -", crc8le(br, 4, 0x07, 0)); // HACK: rct 2018-04-22 // the message is often missing the last 1 bit either due to a // problem with the device or demodulator // Add 1 (0x80 because message is LSB) and retry CRC. if (crcc == (crc | 0x80)) { decoder_logf(decoder, 2, __func__, "CRC fix %02x - %02x", crc, crcc); } else { continue; // DECODE_FAIL_MIC } } if (tempf & 0x80) { tempf = (tempf & 0x7f) * -1; } decoder_logf(decoder, 1, __func__, "sensor 0x%04x - %d%c: %d F", sensor_id, sensor_num, sensor_type, tempf); /* clang-format off */ data = data_make( "model", "", DATA_STRING, "Acurite-986", "id", NULL, DATA_INT, sensor_id, "channel", NULL, DATA_STRING, channel_str, "battery_ok", "Battery", DATA_INT, !battery_low, "temperature_F", "temperature", DATA_FORMAT, "%f F", DATA_DOUBLE, (float)tempf, "status", "status", DATA_INT, status, "mic", "Integrity", DATA_STRING, "CRC", NULL); /* clang-format on */ decoder_output_data(decoder, data); valid_cnt++; } if (valid_cnt) return 1; return result; }
0
[ "CWE-703" ]
rtl_433
37455483889bd1c641bdaafc493d1cc236b74904
257,769,237,696,529,180,000,000,000,000,000,000,000
97
Fix overflow in Acurite-00275rm (closes #2012)
TEST_P(ProtocolIntegrationTest, 200HeadResponseWithContentLength) { initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); auto response = codec_client_->makeHeaderOnlyRequest( Http::TestRequestHeaderMapImpl{{":method", "HEAD"}, {":path", "/test/long/url"}, {":scheme", "http"}, {":authority", "host"}, {"if-none-match", "\"1234567890\""}}); waitForNextUpstreamRequest(); upstream_request_->encodeHeaders( Http::TestResponseHeaderMapImpl{{":status", "200"}, {"content-length", "123"}}, true); ASSERT_TRUE(response->waitForEndStream()); EXPECT_TRUE(response->complete()); EXPECT_EQ("200", response->headers().getStatusValue()); EXPECT_EQ( "123", response->headers().get(Http::LowerCaseString("content-length"))[0]->value().getStringView()); }
0
[ "CWE-416" ]
envoy
148de954ed3585d8b4298b424aa24916d0de6136
282,576,099,122,646,400,000,000,000,000,000,000,000
19
CVE-2021-43825 Response filter manager crash Signed-off-by: Yan Avlasov <[email protected]>
SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(ULONG* pcPackages, PSecPkgInfoW* ppPackageInfo) { int index; size_t size; UINT32 cPackages; SecPkgInfoW* pPackageInfo; cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); size = sizeof(SecPkgInfoW) * cPackages; pPackageInfo = (SecPkgInfoW*) sspi_ContextBufferAlloc(EnumerateSecurityPackagesIndex, size); for (index = 0; index < (int) cPackages; index++) { pPackageInfo[index].fCapabilities = SecPkgInfoW_LIST[index]->fCapabilities; pPackageInfo[index].wVersion = SecPkgInfoW_LIST[index]->wVersion; pPackageInfo[index].wRPCID = SecPkgInfoW_LIST[index]->wRPCID; pPackageInfo[index].cbMaxToken = SecPkgInfoW_LIST[index]->cbMaxToken; pPackageInfo[index].Name = _wcsdup(SecPkgInfoW_LIST[index]->Name); pPackageInfo[index].Comment = _wcsdup(SecPkgInfoW_LIST[index]->Comment); } *(pcPackages) = cPackages; *(ppPackageInfo) = pPackageInfo; return SEC_E_OK; }
0
[ "CWE-476", "CWE-125" ]
FreeRDP
0773bb9303d24473fe1185d85a424dfe159aff53
213,442,982,409,643,300,000,000,000,000,000,000,000
27
nla: invalidate sec handle after creation If sec pointer isn't invalidated after creation it is not possible to check if the upper and lower pointers are valid. This fixes a segfault in the server part if the client disconnects before the authentication was finished.
PHP_FUNCTION(imagerectangle) { zval *IM; zend_long x1, y1, x2, y2, col; gdImagePtr im; if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlllll", &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) { return; } if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) { RETURN_FALSE; } gdImageRectangle(im, x1, y1, x2, y2, col); RETURN_TRUE; }
0
[ "CWE-787" ]
php-src
28022c9b1fd937436ab67bb3d61f652c108baf96
152,578,409,641,872,330,000,000,000,000,000,000,000
17
Fix bug#72697 - select_colors write out-of-bounds (cherry picked from commit b6f13a5ef9d6280cf984826a5de012a32c396cd4) Conflicts: ext/gd/gd.c
BSONObj operand1() { return BSON("" << numeric_limits<int>::max()); }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
318,045,053,393,576,160,000,000,000,000,000,000,000
3
SERVER-38070 fix infinite loop in agg expression
dissect_kafka_elect_leaders_request_topic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, kafka_api_version_t api_version) { proto_item *subti, *subsubti; proto_tree *subtree, *subsubtree; subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_kafka_topic, &subti, "Topic"); subsubtree = proto_tree_add_subtree(subtree, tvb, offset, -1, ett_kafka_partitions, &subsubti, "Partitions"); offset = dissect_kafka_array(subsubtree, tvb, pinfo, offset, api_version >= 2, api_version, &dissect_kafka_elect_leaders_request_partition, NULL); proto_item_set_end(subsubti, tvb, offset); if (api_version >= 2) { offset = dissect_kafka_tagged_fields(tvb, pinfo, subtree, offset, 0); } proto_item_set_end(subti, tvb, offset); return offset; }
0
[ "CWE-401" ]
wireshark
f4374967bbf9c12746b8ec3cd54dddada9dd353e
6,448,972,303,125,661,000,000,000,000,000,000,000
25
Kafka: Limit our decompression size. Don't assume that the Internet has our best interests at heart when it gives us the size of our decompression buffer. Assign an arbitrary limit of 50 MB. This fixes #16739 in that it takes care of ** (process:17681): WARNING **: 20:03:07.440: Dissector bug, protocol Kafka, in packet 31: ../epan/proto.c:7043: failed assertion "end >= fi->start" which is different from the original error output. It looks like *that* might have taken care of in one of the other recent Kafka bug fixes. The decompression routines return a success or failure status. Use gbooleans instead of ints for that.
GF_EXPORT GF_Err gf_isom_apple_enum_tag(GF_ISOFile *mov, u32 idx, GF_ISOiTunesTag *out_tag, const u8 **data, u32 *data_len, u64 *out_int_val, u32 *out_int_val2, u32 *out_flags) { u32 i, child_index; GF_ListItemBox *info; GF_ItemListBox *ilst; GF_MetaBox *meta; GF_DataBox *dbox = NULL; u32 itype, tag_val; s32 tag_idx; *data = NULL; *data_len = 0; meta = (GF_MetaBox *) gf_isom_get_meta_extensions(mov, GF_FALSE); if (!meta) return GF_URL_ERROR; ilst = gf_ismo_locate_box(meta->child_boxes, GF_ISOM_BOX_TYPE_ILST, NULL); if (!ilst) return GF_URL_ERROR; child_index = i = 0; while ( (info=(GF_ListItemBox*)gf_list_enum(ilst->child_boxes, &i))) { GF_DataBox *data_box = NULL; if (gf_itags_find_by_itag(info->type)<0) { if (info->type==GF_ISOM_BOX_TYPE_UNKNOWN) { data_box = (GF_DataBox *) gf_isom_box_find_child(info->child_boxes, GF_ISOM_BOX_TYPE_DATA); if (!data_box) continue; tag_val = ((GF_UnknownBox *)info)->original_4cc; } } else { data_box = info->data; tag_val = info->type; } if (child_index==idx) { dbox = data_box; break; } child_index++; } if (!dbox) return GF_URL_ERROR; *out_flags = dbox->flags; *out_tag = tag_val; if (!dbox->data) { *data = NULL; *data_len = 1; return GF_OK; } tag_idx = gf_itags_find_by_itag(info->type); if (tag_idx<0) { *data = dbox->data; *data_len = dbox->dataSize; return GF_OK; } if ((tag_val == GF_ISOM_ITUNE_GENRE) && (dbox->flags == 0) && (dbox->dataSize>2)) { u32 int_val = dbox->data[0]; int_val <<= 8; int_val |= dbox->data[1]; *data = NULL; *data_len = 0; *out_int_val = int_val; return GF_OK; } itype = gf_itags_get_type((u32) tag_idx); switch (itype) { case GF_ITAG_BOOL: case GF_ITAG_INT8: if (dbox->dataSize) *out_int_val = dbox->data[0]; break; case GF_ITAG_INT16: if (dbox->dataSize>1) { u16 v = dbox->data[0]; v<<=8; v |= dbox->data[1]; *out_int_val = v; } break; case GF_ITAG_INT32: if (dbox->dataSize>3) { u32 v = dbox->data[0]; v<<=8; v |= dbox->data[1]; v<<=8; v |= dbox->data[2]; v<<=8; v |= dbox->data[3]; *out_int_val = v; } break; case GF_ITAG_INT64: if (dbox->dataSize>3) { u64 v = dbox->data[0]; v<<=8; v |= dbox->data[1]; v<<=8; v |= dbox->data[2]; v<<=8; v |= dbox->data[3]; v<<=8; v |= dbox->data[4]; v<<=8; v |= dbox->data[5]; v<<=8; v |= dbox->data[6]; v<<=8; v |= dbox->data[7]; *out_int_val = v; } break; case GF_ITAG_FRAC6: case GF_ITAG_FRAC8: if (dbox->dataSize>3) { u32 v = dbox->data[2]; v<<=8; v |= dbox->data[3]; *out_int_val = v; v = dbox->data[4]; v<<=8; v |= dbox->data[5]; *out_int_val2 = v; } break; default: *data = dbox->data; *data_len = dbox->dataSize; break; } return GF_OK;
0
[ "CWE-476" ]
gpac
ebfa346eff05049718f7b80041093b4c5581c24e
328,505,991,615,475,480,000,000,000,000,000,000,000
130
fixed #1706
struct file *fget_raw(unsigned int fd) { return __fget(fd, 0, 1); }
0
[]
linux
0f2122045b946241a9e549c2a76cea54fa58a7ff
249,930,183,169,841,620,000,000,000,000,000,000,000
4
io_uring: don't rely on weak ->files references Grab actual references to the files_struct. To avoid circular references issues due to this, we add a per-task note that keeps track of what io_uring contexts a task has used. When the tasks execs or exits its assigned files, we cancel requests based on this tracking. With that, we can grab proper references to the files table, and no longer need to rely on stashing away ring_fd and ring_file to check if the ring_fd may have been closed. Cc: [email protected] # v5.5+ Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) { int rc = 0; struct validate_negotiate_info_req vneg_inbuf; struct validate_negotiate_info_rsp *pneg_rsp; u32 rsplen; cifs_dbg(FYI, "validate negotiate\n"); /* * validation ioctl must be signed, so no point sending this if we * can not sign it. We could eventually change this to selectively * sign just this, the first and only signed request on a connection. * This is good enough for now since a user who wants better security * would also enable signing on the mount. Having validation of * negotiate info for signed connections helps reduce attack vectors */ if (tcon->ses->server->sign == false) return 0; /* validation requires signing */ vneg_inbuf.Capabilities = cpu_to_le32(tcon->ses->server->vals->req_capabilities); memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid, SMB2_CLIENT_GUID_SIZE); if (tcon->ses->sign) vneg_inbuf.SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_REQUIRED); else if (global_secflags & CIFSSEC_MAY_SIGN) vneg_inbuf.SecurityMode = cpu_to_le16(SMB2_NEGOTIATE_SIGNING_ENABLED); else vneg_inbuf.SecurityMode = 0; vneg_inbuf.DialectCount = cpu_to_le16(1); vneg_inbuf.Dialects[0] = cpu_to_le16(tcon->ses->server->vals->protocol_id); rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, FSCTL_VALIDATE_NEGOTIATE_INFO, true /* is_fsctl */, (char *)&vneg_inbuf, sizeof(struct validate_negotiate_info_req), (char **)&pneg_rsp, &rsplen); if (rc != 0) { cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc); return -EIO; } if (rsplen != sizeof(struct validate_negotiate_info_rsp)) { cifs_dbg(VFS, "invalid size of protocol negotiate response\n"); return -EIO; } /* check validate negotiate info response matches what we got earlier */ if (pneg_rsp->Dialect != cpu_to_le16(tcon->ses->server->vals->protocol_id)) goto vneg_out; if (pneg_rsp->SecurityMode != cpu_to_le16(tcon->ses->server->sec_mode)) goto vneg_out; /* do not validate server guid because not saved at negprot time yet */ if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND | SMB2_LARGE_FILES) != tcon->ses->server->capabilities) goto vneg_out; /* validate negotiate successful */ cifs_dbg(FYI, "validate negotiate info successful\n"); return 0; vneg_out: cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n"); return -EIO; }
0
[ "CWE-476" ]
linux
cabfb3680f78981d26c078a26e5c748531257ebb
45,738,316,819,872,000,000,000,000,000,000,000,000
75
CIFS: Enable encryption during session setup phase In order to allow encryption on SMB connection we need to exchange a session key and generate encryption and decryption keys. Signed-off-by: Pavel Shilovsky <[email protected]>
static int vnc_refresh_server_surface(VncDisplay *vd) { int width = pixman_image_get_width(vd->guest.fb); int height = pixman_image_get_height(vd->guest.fb); int y; uint8_t *guest_row0 = NULL, *server_row0; int guest_stride = 0, server_stride; int cmp_bytes; VncState *vs; int has_dirty = 0; pixman_image_t *tmpbuf = NULL; struct timeval tv = { 0, 0 }; if (!vd->non_adaptive) { gettimeofday(&tv, NULL); has_dirty = vnc_update_stats(vd, &tv); } /* * Walk through the guest dirty map. * Check and copy modified bits from guest to server surface. * Update server dirty map. */ cmp_bytes = VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES; if (cmp_bytes > vnc_server_fb_stride(vd)) { cmp_bytes = vnc_server_fb_stride(vd); } if (vd->guest.format != VNC_SERVER_FB_FORMAT) { int width = pixman_image_get_width(vd->server); tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width); } else { guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb); guest_stride = pixman_image_get_stride(vd->guest.fb); } server_row0 = (uint8_t *)pixman_image_get_data(vd->server); server_stride = pixman_image_get_stride(vd->server); y = 0; for (;;) { int x; uint8_t *guest_ptr, *server_ptr; unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty, height * VNC_DIRTY_BPL(&vd->guest), y * VNC_DIRTY_BPL(&vd->guest)); if (offset == height * VNC_DIRTY_BPL(&vd->guest)) { /* no more dirty bits */ break; } y = offset / VNC_DIRTY_BPL(&vd->guest); x = offset % VNC_DIRTY_BPL(&vd->guest); server_ptr = server_row0 + y * server_stride + x * cmp_bytes; if (vd->guest.format != VNC_SERVER_FB_FORMAT) { qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y); guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf); } else { guest_ptr = guest_row0 + y * guest_stride; } guest_ptr += x * cmp_bytes; for (; x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT); x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) { if (!test_and_clear_bit(x, vd->guest.dirty[y])) { continue; } if (memcmp(server_ptr, guest_ptr, cmp_bytes) == 0) { continue; } memcpy(server_ptr, guest_ptr, cmp_bytes); if (!vd->non_adaptive) { vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT, y, &tv); } QTAILQ_FOREACH(vs, &vd->clients, next) { set_bit(x, vs->dirty[y]); } has_dirty++; } y++; } qemu_pixman_image_unref(tmpbuf); return has_dirty; }
1
[ "CWE-125" ]
qemu
bea60dd7679364493a0d7f5b54316c767cf894ef
233,754,734,555,049,500,000,000,000,000,000,000,000
86
ui/vnc: fix potential memory corruption issues this patch makes the VNC server work correctly if the server surface and the guest surface have different sizes. Basically the server surface is adjusted to not exceed VNC_MAX_WIDTH x VNC_MAX_HEIGHT and additionally the width is rounded up to multiple of VNC_DIRTY_PIXELS_PER_BIT. If we have a resolution whose width is not dividable by VNC_DIRTY_PIXELS_PER_BIT we now get a small black bar on the right of the screen. If the surface is too big to fit the limits only the upper left area is shown. On top of that this fixes 2 memory corruption issues: The first was actually discovered during playing around with a Windows 7 vServer. During resolution change in Windows 7 it happens sometimes that Windows changes to an intermediate resolution where server_stride % cmp_bytes != 0 (in vnc_refresh_server_surface). This happens only if width % VNC_DIRTY_PIXELS_PER_BIT != 0. The second is a theoretical issue, but is maybe exploitable by the guest. If for some reason the guest surface size is bigger than VNC_MAX_WIDTH x VNC_MAX_HEIGHT we end up in severe corruption since this limit is nowhere enforced. Signed-off-by: Peter Lieven <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
broadcast_timeout(void *arg) { BroadcastDestination *destination; NTP_int64 orig_ts; struct timeval recv_ts; destination = ARR_GetElement(broadcasts, (long)arg); orig_ts.hi = 0; orig_ts.lo = 0; recv_ts.tv_sec = 0; recv_ts.tv_usec = 0; transmit_packet(MODE_BROADCAST, 6 /* FIXME: should this be log2(interval)? */, NTP_VERSION, 0, 0, &orig_ts, &recv_ts, NULL, NULL, &destination->addr, &destination->local_addr); /* Requeue timeout. We don't care if interval drifts gradually. */ SCH_AddTimeoutInClass(destination->interval, SAMPLING_SEPARATION, SAMPLING_RANDOMNESS, SCH_NtpBroadcastClass, broadcast_timeout, arg); }
0
[]
chrony
a78bf9725a7b481ebff0e0c321294ba767f2c1d8
334,900,453,881,958,850,000,000,000,000,000,000,000
21
ntp: restrict authentication of server/peer to specified key When a server/peer was specified with a key number to enable authentication with a symmetric key, packets received from the server/peer were accepted if they were authenticated with any of the keys contained in the key file and not just the specified key. This allowed an attacker who knew one key of a client/peer to modify packets from its servers/peers that were authenticated with other keys in a man-in-the-middle (MITM) attack. For example, in a network where each NTP association had a separate key and all hosts had only keys they needed, a client of a server could not attack other clients of the server, but it could attack the server and also attack its own clients (i.e. modify packets from other servers). To not allow the server/peer to be authenticated with other keys extend the authentication test to check if the key ID in the received packet is equal to the configured key number. As a consequence, it's no longer possible to authenticate two peers to each other with two different keys, both peers have to be configured to use the same key. This issue was discovered by Matt Street of Cisco ASIG.
xmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra) { xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { if (ctxt->serror != NULL) schannel = ctxt->serror; else channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; } if (extra) __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n"); }
0
[ "CWE-134" ]
libxml2
502f6a6d08b08c04b3ddfb1cd21b2f699c1b7f5b
118,372,042,732,785,280,000,000,000,000,000,000,000
26
More format string warnings with possible format string vulnerability For https://bugzilla.gnome.org/show_bug.cgi?id=761029 adds a new xmlEscapeFormatString() function to escape composed format strings
TORRENT_TEST(gzip) { std::vector<char> zipped; error_code ec; load_file(combine_path("..", "zeroes.gz"), zipped, ec, 1000000); if (ec) fprintf(stderr, "failed to open file: (%d) %s\n", ec.value() , ec.message().c_str()); TEST_CHECK(!ec); std::vector<char> inflated; inflate_gzip(&zipped[0], zipped.size(), inflated, 1000000, ec); if (ec) { fprintf(stderr, "failed to unzip: %s\n", ec.message().c_str()); } TEST_CHECK(!ec); TEST_CHECK(inflated.size() > 0); for (int i = 0; i < int(inflated.size()); ++i) TEST_EQUAL(inflated[i], 0); }
1
[ "CWE-20" ]
libtorrent
debf3c6e3688aab8394fe5c47737625faffe6f9e
185,965,949,769,921,300,000,000,000,000,000,000,000
20
update puff.c for gzip inflation (#1022) update puff.c for gzip inflation
int Segment::WriteFramesAll() { if (frames_ == NULL) return 0; if (cluster_list_size_ < 1) return -1; Cluster* const cluster = cluster_list_[cluster_list_size_ - 1]; if (!cluster) return -1; for (int32_t i = 0; i < frames_size_; ++i) { Frame*& frame = frames_[i]; // TODO(jzern/vigneshv): using Segment::AddGenericFrame here would limit the // places where |doc_type_version_| needs to be updated. if (frame->discard_padding() != 0) doc_type_version_ = 4; if (!cluster->AddFrame(frame)) return -1; if (new_cuepoint_ && cues_track_ == frame->track_number()) { if (!AddCuePoint(frame->timestamp(), cues_track_)) return -1; } if (frame->timestamp() > last_timestamp_) { last_timestamp_ = frame->timestamp(); last_track_timestamp_[frame->track_number() - 1] = frame->timestamp(); } delete frame; frame = NULL; } const int result = frames_size_; frames_size_ = 0; return result; }
0
[ "CWE-20" ]
libvpx
f00890eecdf8365ea125ac16769a83aa6b68792d
195,706,879,499,623,330,000,000,000,000,000,000,000
40
update libwebm to libwebm-1.0.0.27-352-g6ab9fcf https://chromium.googlesource.com/webm/libwebm/+log/af81f26..6ab9fcf Change-Id: I9d56e1fbaba9b96404b4fbabefddc1a85b79c25d
int PE_(r_bin_pe_get_image_size)(struct PE_(r_bin_pe_obj_t)* bin) { return bin->nt_headers->optional_header.SizeOfImage; }
0
[ "CWE-125" ]
radare2
4e1cf0d3e6f6fe2552a269def0af1cd2403e266c
338,088,145,548,479,370,000,000,000,000,000,000,000
3
Fix crash in pe
TEST(QuantizedUInt8PoolingOpTest, MaxPool) { // Choose the input ranges carefully so that the dequantized output matches // the results of the float model above. // Input Range[0, 15.9375] --> [Scale{0.0625}, zero_point{0}] QuantizedPoolingOpModel m( BuiltinOperator_MAX_POOL_2D, /*input=*/{TensorType_UINT8, {1, 2, 4, 1}, 0, 15.9375}, /*filter_width=*/2, /*filter_height=*/2, /*output=*/{TensorType_UINT8, {}, 0, 15.9375}); m.SetInput({ 0, 6, 2, 4, // 3, 2, 10, 7, // }); m.Invoke(); EXPECT_THAT(m.GetDequantizedOutput(), ElementsAreArray(ArrayFloatNear({6, 10}))); EXPECT_THAT(m.GetOutput(), ElementsAreArray({96, 160})); }
0
[ "CWE-369" ]
tensorflow
5f7975d09eac0f10ed8a17dbb6f5964977725adc
168,206,259,329,307,460,000,000,000,000,000,000,000
19
Prevent another div by 0 in optimized pooling implementations TFLite PiperOrigin-RevId: 370800091 Change-Id: I2119352f57fb5ca4f2051e0e2d749403304a979b
issuerAndThisUpdateCheck( struct berval *in, struct berval *is, struct berval *tu, void *ctx ) { int numdquotes = 0; struct berval x = *in; struct berval ni = BER_BVNULL; /* Parse GSER format */ enum { HAVE_NONE = 0x0, HAVE_ISSUER = 0x1, HAVE_THISUPDATE = 0x2, HAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE ) } have = HAVE_NONE; if ( in->bv_len < STRLENOF( "{issuer \"\",thisUpdate \"YYMMDDhhmmssZ\"}" ) ) return LDAP_INVALID_SYNTAX; if ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) { return LDAP_INVALID_SYNTAX; } x.bv_val++; x.bv_len -= STRLENOF("{}"); do { /* eat leading spaces */ for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) { /* empty */; } /* should be at issuer or thisUpdate */ if ( strncasecmp( x.bv_val, "issuer", STRLENOF("issuer") ) == 0 ) { if ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX; /* parse issuer */ x.bv_val += STRLENOF("issuer"); x.bv_len -= STRLENOF("issuer"); if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX; x.bv_val++; x.bv_len--; /* eat leading spaces */ for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) { /* empty */; } /* For backward compatibility, this part is optional */ if ( strncasecmp( x.bv_val, "rdnSequence:", STRLENOF("rdnSequence:") ) != 0 ) { return LDAP_INVALID_SYNTAX; } x.bv_val += STRLENOF("rdnSequence:"); x.bv_len -= STRLENOF("rdnSequence:"); if ( x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX; x.bv_val++; x.bv_len--; is->bv_val = x.bv_val; is->bv_len = 0; for ( ; is->bv_len < x.bv_len; ) { if ( is->bv_val[is->bv_len] != '"' ) { is->bv_len++; continue; } if ( is->bv_val[is->bv_len+1] == '"' ) { /* double dquote */ numdquotes++; is->bv_len += 2; continue; } break; } x.bv_val += is->bv_len + 1; x.bv_len -= is->bv_len + 1; have |= HAVE_ISSUER; } else if ( strncasecmp( x.bv_val, "thisUpdate", STRLENOF("thisUpdate") ) == 0 ) { if ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX; /* parse thisUpdate */ x.bv_val += STRLENOF("thisUpdate"); x.bv_len -= STRLENOF("thisUpdate"); if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX; x.bv_val++; x.bv_len--; /* eat leading spaces */ for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) { /* empty */; } if ( !x.bv_len || x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX; x.bv_val++; x.bv_len--; tu->bv_val = x.bv_val; tu->bv_len = 0; for ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) { if ( tu->bv_val[tu->bv_len] == '"' ) { break; } } x.bv_val += tu->bv_len + 1; x.bv_len -= tu->bv_len + 1; have |= HAVE_THISUPDATE; } else { return LDAP_INVALID_SYNTAX; } /* eat leading spaces */ for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) { /* empty */; } if ( have == HAVE_ALL ) { break; } if ( x.bv_val[0] != ',' ) { return LDAP_INVALID_SYNTAX; } x.bv_val++; x.bv_len--; } while ( 1 ); /* should have no characters left... */ if ( x.bv_len ) return LDAP_INVALID_SYNTAX; if ( numdquotes == 0 ) { ber_dupbv_x( &ni, is, ctx ); } else { ber_len_t src, dst; ni.bv_len = is->bv_len - numdquotes; ni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx ); for ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) { if ( is->bv_val[src] == '"' ) { src++; } ni.bv_val[dst] = is->bv_val[src]; } ni.bv_val[dst] = '\0'; } *is = ni; return 0; }
1
[ "CWE-617" ]
openldap
3539fc33212b528c56b716584f2c2994af7c30b0
296,580,747,977,289,520,000,000,000,000,000,000,000
161
ITS#9454 fix issuerAndThisUpdateCheck
static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c) { if (c->x86_vendor == X86_VENDOR_AMD) { mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV); mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR); mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA); if (mce_flags.smca) { msr_ops.ctl = smca_ctl_reg; msr_ops.status = smca_status_reg; msr_ops.addr = smca_addr_reg; msr_ops.misc = smca_misc_reg; } } }
0
[ "CWE-362" ]
linux
b3b7c4795ccab5be71f080774c45bbbcc75c2aaf
102,538,346,524,045,240,000,000,000,000,000,000,000
15
x86/MCE: Serialize sysfs changes The check_interval file in /sys/devices/system/machinecheck/machinecheck<cpu number> directory is a global timer value for MCE polling. If it is changed by one CPU, mce_restart() broadcasts the event to other CPUs to delete and restart the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the mce_timer variable. If more than one CPU writes a specific value to the check_interval file concurrently, mce_timer is not protected from such concurrent accesses and all kinds of explosions happen. Since only root can write to those sysfs variables, the issue is not a big deal security-wise. However, concurrent writes to these configuration variables is void of reason so the proper thing to do is to serialize the access with a mutex. Boris: - Make store_int_with_restart() use device_store_ulong() to filter out negative intervals - Limit min interval to 1 second - Correct locking - Massage commit message Signed-off-by: Seunghun Han <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Tony Luck <[email protected]> Cc: linux-edac <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
static int get_client_hello(SSL *s) { int i, n; unsigned long len; unsigned char *p; STACK_OF(SSL_CIPHER) *cs; /* a stack of SSL_CIPHERS */ STACK_OF(SSL_CIPHER) *cl; /* the ones we want to use */ STACK_OF(SSL_CIPHER) *prio, *allow; int z; /* * This is a bit of a hack to check for the correct packet type the first * time round. */ if (s->state == SSL2_ST_GET_CLIENT_HELLO_A) { s->first_packet = 1; s->state = SSL2_ST_GET_CLIENT_HELLO_B; } p = (unsigned char *)s->init_buf->data; if (s->state == SSL2_ST_GET_CLIENT_HELLO_B) { i = ssl2_read(s, (char *)&(p[s->init_num]), 9 - s->init_num); if (i < (9 - s->init_num)) return (ssl2_part_read(s, SSL_F_GET_CLIENT_HELLO, i)); s->init_num = 9; if (*(p++) != SSL2_MT_CLIENT_HELLO) { if (p[-1] != SSL2_MT_ERROR) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_READ_WRONG_PACKET_TYPE); } else SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_PEER_ERROR); return (-1); } n2s(p, i); if (i < s->version) s->version = i; n2s(p, i); s->s2->tmp.cipher_spec_length = i; n2s(p, i); s->s2->tmp.session_id_length = i; n2s(p, i); s->s2->challenge_length = i; if ((i < SSL2_MIN_CHALLENGE_LENGTH) || (i > SSL2_MAX_CHALLENGE_LENGTH)) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_INVALID_CHALLENGE_LENGTH); return (-1); } s->state = SSL2_ST_GET_CLIENT_HELLO_C; } /* SSL2_ST_GET_CLIENT_HELLO_C */ p = (unsigned char *)s->init_buf->data; len = 9 + (unsigned long)s->s2->tmp.cipher_spec_length + (unsigned long)s->s2->challenge_length + (unsigned long)s->s2->tmp.session_id_length; if (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); SSLerr(SSL_F_GET_CLIENT_HELLO, 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_HELLO, i)); if (s->msg_callback) { /* CLIENT-HELLO */ s->msg_callback(0, s->version, 0, p, (size_t)len, s, s->msg_callback_arg); } p += 9; /* * get session-id before cipher stuff so we can get out session structure * if it is cached */ /* session-id */ if ((s->s2->tmp.session_id_length != 0) && (s->s2->tmp.session_id_length != SSL2_SSL_SESSION_ID_LENGTH)) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_BAD_SSL_SESSION_ID_LENGTH); return (-1); } if (s->s2->tmp.session_id_length == 0) { if (!ssl_get_new_session(s, 1)) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); return (-1); } } else { i = ssl_get_prev_session(s, &(p[s->s2->tmp.cipher_spec_length]), s->s2->tmp.session_id_length, NULL); if (i == 1) { /* previous session */ s->hit = 1; } else if (i == -1) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); return (-1); } else { if (s->cert == NULL) { ssl2_return_error(s, SSL2_PE_NO_CERTIFICATE); SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_NO_CERTIFICATE_SET); return (-1); } if (!ssl_get_new_session(s, 1)) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); return (-1); } } } if (!s->hit) { cs = ssl_bytes_to_cipher_list(s, p, s->s2->tmp.cipher_spec_length, &s->session->ciphers); if (cs == NULL) goto mem_err; cl = SSL_get_ciphers(s); if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) { prio = sk_SSL_CIPHER_dup(cl); if (prio == NULL) goto mem_err; allow = cs; } else { prio = cs; allow = cl; } for (z = 0; z < sk_SSL_CIPHER_num(prio); z++) { if (sk_SSL_CIPHER_find(allow, sk_SSL_CIPHER_value(prio, z)) < 0) { (void)sk_SSL_CIPHER_delete(prio, z); z--; } } if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) { sk_SSL_CIPHER_free(s->session->ciphers); s->session->ciphers = prio; } /* * s->session->ciphers should now have a list of ciphers that are on * both the client and server. This list is ordered by the order the * client sent the ciphers or in the order of the server's preference * if SSL_OP_CIPHER_SERVER_PREFERENCE was set. */ } p += s->s2->tmp.cipher_spec_length; /* done cipher selection */ /* session id extracted already */ p += s->s2->tmp.session_id_length; /* challenge */ if (s->s2->challenge_length > sizeof s->s2->challenge) { ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR); SSLerr(SSL_F_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); return -1; } memcpy(s->s2->challenge, p, (unsigned int)s->s2->challenge_length); return (1); mem_err: SSLerr(SSL_F_GET_CLIENT_HELLO, ERR_R_MALLOC_FAILURE); return (0); }
0
[ "CWE-20" ]
openssl
86f8fb0e344d62454f8daf3e15236b2b59210756
46,914,357,020,654,390,000,000,000,000,000,000,000
165
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]>
ast_for_arg(struct compiling *c, const node *n) { identifier name; expr_ty annotation = NULL; node *ch; arg_ty ret; assert(TYPE(n) == tfpdef || TYPE(n) == vfpdef); ch = CHILD(n, 0); name = NEW_IDENTIFIER(ch); if (!name) return NULL; if (forbidden_name(c, name, ch, 0)) return NULL; if (NCH(n) == 3 && TYPE(CHILD(n, 1)) == COLON) { annotation = ast_for_expr(c, CHILD(n, 2)); if (!annotation) return NULL; } ret = arg(name, annotation, LINENO(n), n->n_col_offset, n->n_end_lineno, n->n_end_col_offset, c->c_arena); if (!ret) return NULL; return ret; }
1
[ "CWE-125" ]
cpython
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
273,713,360,742,469,220,000,000,000,000,000,000,000
27
bpo-35766: Merge typed_ast back into CPython (GH-11645)
static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, uint32 imagelength, uint32 imagewidth, uint32 tw, uint32 tl, uint16 spp, uint16 bps) { int i, status = 1, sample; int shift_width, bytes_per_pixel; uint16 bytes_per_sample; uint32 row, col; /* Current row and col of image */ uint32 nrow, ncol; /* Number of rows and cols in current tile */ uint32 row_offset, col_offset; /* Output buffer offsets */ tsize_t tbytes = 0, tilesize = TIFFTileSize(in); tsample_t s; uint8* bufp = (uint8*)obuf; unsigned char *srcbuffs[MAX_SAMPLES]; unsigned char *tbuff = NULL; bytes_per_sample = (bps + 7) / 8; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { srcbuffs[sample] = NULL; tbuff = (unsigned char *)_TIFFmalloc(tilesize + 8); if (!tbuff) { TIFFError ("readSeparateTilesIntoBuffer", "Unable to allocate tile read buffer for sample %d", sample); for (i = 0; i < sample; i++) _TIFFfree (srcbuffs[i]); return 0; } srcbuffs[sample] = tbuff; } /* Each tile contains only the data for a single plane * arranged in scanlines of tw * bytes_per_sample bytes. */ for (row = 0; row < imagelength; row += tl) { nrow = (row + tl > imagelength) ? imagelength - row : tl; for (col = 0; col < imagewidth; col += tw) { for (s = 0; s < spp && s < MAX_SAMPLES; s++) { /* Read each plane of a tile set into srcbuffs[s] */ tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s); if (tbytes < 0 && !ignore) { TIFFError(TIFFFileName(in), "Error, can't read tile for row %lu col %lu, " "sample %lu", (unsigned long) col, (unsigned long) row, (unsigned long) s); status = 0; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { tbuff = srcbuffs[sample]; if (tbuff != NULL) _TIFFfree(tbuff); } return status; } } /* Tiles on the right edge may be padded out to tw * which must be a multiple of 16. * Ncol represents the visible (non padding) portion. */ if (col + tw > imagewidth) ncol = imagewidth - col; else ncol = tw; row_offset = row * (((imagewidth * spp * bps) + 7) / 8); col_offset = ((col * spp * bps) + 7) / 8; bufp = obuf + row_offset + col_offset; if ((bps % 8) == 0) { if (combineSeparateTileSamplesBytes(srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } } else { bytes_per_pixel = ((bps * spp) + 7) / 8; if (bytes_per_pixel < (bytes_per_sample + 1)) shift_width = bytes_per_pixel; else shift_width = bytes_per_sample + 1; switch (shift_width) { case 1: if (combineSeparateTileSamples8bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 2: if (combineSeparateTileSamples16bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 3: if (combineSeparateTileSamples24bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 4: case 5: case 6: case 7: case 8: if (combineSeparateTileSamples32bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); status = 0; break; } } } } for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { tbuff = srcbuffs[sample]; if (tbuff != NULL) _TIFFfree(tbuff); } return status; }
0
[ "CWE-125" ]
libtiff
21d39de1002a5e69caa0574b2cc05d795d6fbfad
87,115,765,316,486,540,000,000,000,000,000,000,000
146
* tools/tiffcrop.c: fix multiple uint32 overflows in writeBufferToSeparateStrips(), writeBufferToContigTiles() and writeBufferToSeparateTiles() that could cause heap buffer overflows. Reported by Henri Salo from Nixu Corporation. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2592
void beginFetchPhase() { fassert(17191, !_authzManager->_isFetchPhaseBusy); _isThisGuardInFetchPhase = true; _authzManager->_isFetchPhaseBusy = true; _startGeneration = _authzManager->_cacheGeneration; _lock.unlock(); }
0
[ "CWE-613" ]
mongo
6dfb92b1299de04677d0bd2230e89a52eb01003c
59,885,575,418,764,630,000,000,000,000,000,000,000
7
SERVER-38984 Validate unique User ID on UserCache hit (cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, const char *queryString) { Relation rel; ParseState *pstate; CreateStmtContext cxt; List *result; List *save_alist; ListCell *lcmd, *l; List *newcmds = NIL; bool skipValidation = true; AlterTableCmd *newcmd; RangeTblEntry *rte; /* * We must not scribble on the passed-in AlterTableStmt, so copy it. (This * is overkill, but easy.) */ stmt = copyObject(stmt); /* Caller is responsible for locking the relation */ rel = relation_open(relid, NoLock); /* Set up pstate */ pstate = make_parsestate(NULL); pstate->p_sourcetext = queryString; rte = addRangeTableEntryForRelation(pstate, rel, NULL, false, true); addRTEtoQuery(pstate, rte, false, true, true); /* Set up CreateStmtContext */ cxt.pstate = pstate; if (stmt->relkind == OBJECT_FOREIGN_TABLE) { cxt.stmtType = "ALTER FOREIGN TABLE"; cxt.isforeign = true; } else { cxt.stmtType = "ALTER TABLE"; cxt.isforeign = false; } cxt.relation = stmt->relation; cxt.rel = rel; cxt.inhRelations = NIL; cxt.isalter = true; cxt.hasoids = false; /* need not be right */ cxt.columns = NIL; cxt.ckconstraints = NIL; cxt.fkconstraints = NIL; cxt.ixconstraints = NIL; cxt.likeclauses = NIL; cxt.extstats = NIL; cxt.blist = NIL; cxt.alist = NIL; cxt.pkey = NULL; cxt.ispartitioned = (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE); cxt.partbound = NULL; cxt.ofType = false; /* * The only subtypes that currently require parse transformation handling * are ADD COLUMN, ADD CONSTRAINT and SET DATA TYPE. These largely re-use * code from CREATE TABLE. */ foreach(lcmd, stmt->cmds) { AlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd); switch (cmd->subtype) { case AT_AddColumn: case AT_AddColumnToView: { ColumnDef *def = castNode(ColumnDef, cmd->def); transformColumnDefinition(&cxt, def); /* * If the column has a non-null default, we can't skip * validation of foreign keys. */ if (def->raw_default != NULL) skipValidation = false; /* * All constraints are processed in other ways. Remove the * original list */ def->constraints = NIL; newcmds = lappend(newcmds, cmd); break; } case AT_AddConstraint: /* * The original AddConstraint cmd node doesn't go to newcmds */ if (IsA(cmd->def, Constraint)) { transformTableConstraint(&cxt, (Constraint *) cmd->def); if (((Constraint *) cmd->def)->contype == CONSTR_FOREIGN) skipValidation = false; } else elog(ERROR, "unrecognized node type: %d", (int) nodeTag(cmd->def)); break; case AT_ProcessedConstraint: /* * Already-transformed ADD CONSTRAINT, so just make it look * like the standard case. */ cmd->subtype = AT_AddConstraint; newcmds = lappend(newcmds, cmd); break; case AT_AlterColumnType: { ColumnDef *def = (ColumnDef *) cmd->def; AttrNumber attnum; /* * For ALTER COLUMN TYPE, transform the USING clause if * one was specified. */ if (def->raw_default) { def->cooked_default = transformExpr(pstate, def->raw_default, EXPR_KIND_ALTER_COL_TRANSFORM); } /* * For identity column, create ALTER SEQUENCE command to * change the data type of the sequence. */ attnum = get_attnum(relid, cmd->name); /* * if attribute not found, something will error about it * later */ if (attnum > 0 && get_attidentity(relid, attnum)) { Oid seq_relid = getOwnedSequence(relid, attnum); Oid typeOid = typenameTypeId(pstate, def->typeName); AlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt); altseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)), get_rel_name(seq_relid), -1); altseqstmt->options = list_make1(makeDefElem("as", (Node *) makeTypeNameFromOid(typeOid, -1), -1)); altseqstmt->for_identity = true; cxt.blist = lappend(cxt.blist, altseqstmt); } newcmds = lappend(newcmds, cmd); break; } case AT_AddIdentity: { Constraint *def = castNode(Constraint, cmd->def); ColumnDef *newdef = makeNode(ColumnDef); AttrNumber attnum; newdef->colname = cmd->name; newdef->identity = def->generated_when; cmd->def = (Node *) newdef; attnum = get_attnum(relid, cmd->name); /* * if attribute not found, something will error about it * later */ if (attnum != InvalidAttrNumber) generateSerialExtraStmts(&cxt, newdef, get_atttype(relid, attnum), def->options, true, NULL, NULL); newcmds = lappend(newcmds, cmd); break; } case AT_SetIdentity: { /* * Create an ALTER SEQUENCE statement for the internal * sequence of the identity column. */ ListCell *lc; List *newseqopts = NIL; List *newdef = NIL; List *seqlist; AttrNumber attnum; /* * Split options into those handled by ALTER SEQUENCE and * those for ALTER TABLE proper. */ foreach(lc, castNode(List, cmd->def)) { DefElem *def = lfirst_node(DefElem, lc); if (strcmp(def->defname, "generated") == 0) newdef = lappend(newdef, def); else newseqopts = lappend(newseqopts, def); } attnum = get_attnum(relid, cmd->name); if (attnum) { seqlist = getOwnedSequences(relid, attnum); if (seqlist) { AlterSeqStmt *seqstmt; Oid seq_relid; seqstmt = makeNode(AlterSeqStmt); seq_relid = linitial_oid(seqlist); seqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)), get_rel_name(seq_relid), -1); seqstmt->options = newseqopts; seqstmt->for_identity = true; seqstmt->missing_ok = false; cxt.alist = lappend(cxt.alist, seqstmt); } } /* * If column was not found or was not an identity column, * we just let the ALTER TABLE command error out later. */ cmd->def = (Node *) newdef; newcmds = lappend(newcmds, cmd); break; } case AT_AttachPartition: case AT_DetachPartition: { PartitionCmd *partcmd = (PartitionCmd *) cmd->def; transformPartitionCmd(&cxt, partcmd); /* assign transformed value of the partition bound */ partcmd->bound = cxt.partbound; } newcmds = lappend(newcmds, cmd); break; default: newcmds = lappend(newcmds, cmd); break; } } /* * transformIndexConstraints wants cxt.alist to contain only index * statements, so transfer anything we already have into save_alist * immediately. */ save_alist = cxt.alist; cxt.alist = NIL; /* Postprocess constraints */ transformIndexConstraints(&cxt); transformFKConstraints(&cxt, skipValidation, true); transformCheckConstraints(&cxt, false); /* * Push any index-creation commands into the ALTER, so that they can be * scheduled nicely by tablecmds.c. Note that tablecmds.c assumes that * the IndexStmt attached to an AT_AddIndex or AT_AddIndexConstraint * subcommand has already been through transformIndexStmt. */ foreach(l, cxt.alist) { IndexStmt *idxstmt = lfirst_node(IndexStmt, l); idxstmt = transformIndexStmt(relid, idxstmt, queryString); newcmd = makeNode(AlterTableCmd); newcmd->subtype = OidIsValid(idxstmt->indexOid) ? AT_AddIndexConstraint : AT_AddIndex; newcmd->def = (Node *) idxstmt; newcmds = lappend(newcmds, newcmd); } cxt.alist = NIL; /* Append any CHECK or FK constraints to the commands list */ foreach(l, cxt.ckconstraints) { newcmd = makeNode(AlterTableCmd); newcmd->subtype = AT_AddConstraint; newcmd->def = (Node *) lfirst(l); newcmds = lappend(newcmds, newcmd); } foreach(l, cxt.fkconstraints) { newcmd = makeNode(AlterTableCmd); newcmd->subtype = AT_AddConstraint; newcmd->def = (Node *) lfirst(l); newcmds = lappend(newcmds, newcmd); } /* Append extended statistic objects */ transformExtendedStatistics(&cxt); /* Close rel */ relation_close(rel, NoLock); /* * Output results. */ stmt->cmds = newcmds; result = lappend(cxt.blist, stmt); result = list_concat(result, cxt.alist); result = list_concat(result, save_alist); return result; }
0
[ "CWE-94" ]
postgres
f52d2fbd8c62f667191b61228acf9d8aa53607b9
99,019,033,964,640,300,000,000,000,000,000,000,000
336
In extensions, don't replace objects not belonging to the extension. Previously, if an extension script did CREATE OR REPLACE and there was an existing object not belonging to the extension, it would overwrite the object and adopt it into the extension. This is problematic, first because the overwrite is probably unintentional, and second because we didn't change the object's ownership. Thus a hostile user could create an object in advance of an expected CREATE EXTENSION command, and would then have ownership rights on an extension object, which could be modified for trojan-horse-type attacks. Hence, forbid CREATE OR REPLACE of an existing object unless it already belongs to the extension. (Note that we've always forbidden replacing an object that belongs to some other extension; only the behavior for previously-free-standing objects changes here.) For the same reason, also fail CREATE IF NOT EXISTS when there is an existing object that doesn't belong to the extension. Our thanks to Sven Klemm for reporting this problem. Security: CVE-2022-2625
void dn_dev_down(struct net_device *dev) { struct dn_dev *dn_db = rtnl_dereference(dev->dn_ptr); struct dn_ifaddr *ifa; if (dn_db == NULL) return; while ((ifa = rtnl_dereference(dn_db->ifa_list)) != NULL) { dn_dev_del_ifa(dn_db, &dn_db->ifa_list, 0); dn_dev_free_ifa(ifa); } dn_dev_delete(dev); }
0
[ "CWE-264" ]
net
90f62cf30a78721641e08737bda787552428061e
106,461,782,343,690,860,000,000,000,000,000,000,000
15
net: Use netlink_ns_capable to verify the permisions of netlink messages It is possible by passing a netlink socket to a more privileged executable and then to fool that executable into writing to the socket data that happens to be valid netlink message to do something that privileged executable did not intend to do. To keep this from happening replace bare capable and ns_capable calls with netlink_capable, netlink_net_calls and netlink_ns_capable calls. Which act the same as the previous calls except they verify that the opener of the socket had the desired permissions as well. Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
ZEND_VM_HANDLER(86, ZEND_FETCH_RW, CONST|TMPVAR|CV, UNUSED, VAR_FETCH) { ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_RW); }
0
[ "CWE-787" ]
php-src
f1ce8d5f5839cb2069ea37ff424fb96b8cd6932d
93,045,557,758,983,430,000,000,000,000,000,000,000
4
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.
parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, FunctionCallInfo fcinfo) { int nargs; int i; int numAFormats; int16 *aformats = NULL; StringInfoData abuf; /* Get the argument format codes */ numAFormats = pq_getmsgint(msgBuf, 2); if (numAFormats > 0) { aformats = (int16 *) palloc(numAFormats * sizeof(int16)); for (i = 0; i < numAFormats; i++) aformats[i] = pq_getmsgint(msgBuf, 2); } nargs = pq_getmsgint(msgBuf, 2); /* # of arguments */ if (fip->flinfo.fn_nargs != nargs || nargs > FUNC_MAX_ARGS) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("function call message contains %d arguments but function requires %d", nargs, fip->flinfo.fn_nargs))); fcinfo->nargs = nargs; if (numAFormats > 1 && numAFormats != nargs) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("function call message contains %d argument formats but %d arguments", numAFormats, nargs))); initStringInfo(&abuf); /* * Copy supplied arguments into arg vector. */ for (i = 0; i < nargs; ++i) { int argsize; int16 aformat; argsize = pq_getmsgint(msgBuf, 4); if (argsize == -1) { fcinfo->argnull[i] = true; } else { fcinfo->argnull[i] = false; if (argsize < 0) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("invalid argument size %d in function call message", argsize))); /* Reset abuf to empty, and insert raw data into it */ resetStringInfo(&abuf); appendBinaryStringInfo(&abuf, pq_getmsgbytes(msgBuf, argsize), argsize); } if (numAFormats > 1) aformat = aformats[i]; else if (numAFormats > 0) aformat = aformats[0]; else aformat = 0; /* default = text */ if (aformat == 0) { Oid typinput; Oid typioparam; char *pstring; getTypeInputInfo(fip->argtypes[i], &typinput, &typioparam); /* * Since stringinfo.c keeps a trailing null in place even for * binary data, the contents of abuf are a valid C string. We * have to do encoding conversion before calling the typinput * routine, though. */ if (argsize == -1) pstring = NULL; else pstring = pg_client_to_server(abuf.data, argsize); fcinfo->arg[i] = OidInputFunctionCall(typinput, pstring, typioparam, -1); /* Free result of encoding conversion, if any */ if (pstring && pstring != abuf.data) pfree(pstring); } else if (aformat == 1) { Oid typreceive; Oid typioparam; StringInfo bufptr; /* Call the argument type's binary input converter */ getTypeBinaryInputInfo(fip->argtypes[i], &typreceive, &typioparam); if (argsize == -1) bufptr = NULL; else bufptr = &abuf; fcinfo->arg[i] = OidReceiveFunctionCall(typreceive, bufptr, typioparam, -1); /* Trouble if it didn't eat the whole buffer */ if (argsize != -1 && abuf.cursor != abuf.len) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("incorrect binary data format in function argument %d", i + 1))); } else ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", aformat))); } /* Return result format code */ return (int16) pq_getmsgint(msgBuf, 2); }
0
[ "CWE-89" ]
postgres
2b3a8b20c2da9f39ffecae25ab7c66974fbc0d3b
229,976,588,420,453,870,000,000,000,000,000,000,000
130
Be more careful to not lose sync in the FE/BE protocol. If any error occurred while we were in the middle of reading a protocol message from the client, we could lose sync, and incorrectly try to interpret a part of another message as a new protocol message. That will usually lead to an "invalid frontend message" error that terminates the connection. However, this is a security issue because an attacker might be able to deliberately cause an error, inject a Query message in what's supposed to be just user data, and have the server execute it. We were quite careful to not have CHECK_FOR_INTERRUPTS() calls or other operations that could ereport(ERROR) in the middle of processing a message, but a query cancel interrupt or statement timeout could nevertheless cause it to happen. Also, the V2 fastpath and COPY handling were not so careful. It's very difficult to recover in the V2 COPY protocol, so we will just terminate the connection on error. In practice, that's what happened previously anyway, as we lost protocol sync. To fix, add a new variable in pqcomm.c, PqCommReadingMsg, that is set whenever we're in the middle of reading a message. When it's set, we cannot safely ERROR out and continue running, because we might've read only part of a message. PqCommReadingMsg acts somewhat similarly to critical sections in that if an error occurs while it's set, the error handler will force the connection to be terminated, as if the error was FATAL. It's not implemented by promoting ERROR to FATAL in elog.c, like ERROR is promoted to PANIC in critical sections, because we want to be able to use PG_TRY/CATCH to recover and regain protocol sync. pq_getmessage() takes advantage of that to prevent an OOM error from terminating the connection. To prevent unnecessary connection terminations, add a holdoff mechanism similar to HOLD/RESUME_INTERRUPTS() that can be used hold off query cancel interrupts, but still allow die interrupts. The rules on which interrupts are processed when are now a bit more complicated, so refactor ProcessInterrupts() and the calls to it in signal handlers so that the signal handlers always call it if ImmediateInterruptOK is set, and ProcessInterrupts() can decide to not do anything if the other conditions are not met. Reported by Emil Lenngren. Patch reviewed by Noah Misch and Andres Freund. Backpatch to all supported versions. Security: CVE-2015-0244
static inline int __init dccp_mib_init(void) { dccp_statistics = alloc_percpu(struct dccp_mib); if (!dccp_statistics) return -ENOMEM; return 0; }
0
[ "CWE-416" ]
linux
69c64866ce072dea1d1e59a0d61e0f66c0dffb76
258,341,019,482,156,770,000,000,000,000,000,000,000
7
dccp: CVE-2017-8824: use-after-free in DCCP code Whenever the sock object is in DCCP_CLOSED state, dccp_disconnect() must free dccps_hc_tx_ccid and dccps_hc_rx_ccid and set to NULL. Signed-off-by: Mohamed Ghannam <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
com_nopager(String *buffer __attribute__((unused)), char *line __attribute__((unused))) { strmov(pager, "stdout"); opt_nopager=1; PAGER= stdout; tee_fprintf(stdout, "PAGER set to stdout\n"); return 0; }
0
[ "CWE-295" ]
mysql-server
b3e9211e48a3fb586e88b0270a175d2348935424
139,320,333,727,455,260,000,000,000,000,000,000,000
9
WL#9072: Backport WL#8785 to 5.5
void DataReaderImpl::InnerDataReaderListener::on_liveliness_changed( RTPSReader* /*reader*/, const fastrtps::LivelinessChangedStatus& status) { data_reader_->update_liveliness_status(status); DataReaderListener* listener = data_reader_->get_listener_for(StatusMask::liveliness_changed()); if (listener != nullptr) { LivelinessChangedStatus callback_status; if (data_reader_->get_liveliness_changed_status(callback_status) == ReturnCode_t::RETCODE_OK) { listener->on_liveliness_changed(data_reader_->user_datareader_, callback_status); } } }
0
[ "CWE-284" ]
Fast-DDS
d2aeab37eb4fad4376b68ea4dfbbf285a2926384
115,873,048,511,542,260,000,000,000,000,000,000,000
15
check remote permissions (#1387) * Refs 5346. Blackbox test Signed-off-by: Iker Luengo <[email protected]> * Refs 5346. one-way string compare Signed-off-by: Iker Luengo <[email protected]> * Refs 5346. Do not add partition separator on last partition Signed-off-by: Iker Luengo <[email protected]> * Refs 5346. Uncrustify Signed-off-by: Iker Luengo <[email protected]> * Refs 5346. Uncrustify Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Access control unit testing It only covers Partition and Topic permissions Signed-off-by: Iker Luengo <[email protected]> * Refs #3680. Fix partition check on Permissions plugin. Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Uncrustify Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Fix tests on mac Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Fix windows tests Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Avoid memory leak on test Signed-off-by: Iker Luengo <[email protected]> * Refs 3680. Proxy data mocks should not return temporary objects Signed-off-by: Iker Luengo <[email protected]> * refs 3680. uncrustify Signed-off-by: Iker Luengo <[email protected]> Co-authored-by: Miguel Company <[email protected]>
static void rng_backend_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); ucc->complete = rng_backend_complete; }
0
[ "CWE-119" ]
qemu
60253ed1e6ec6d8e5ef2efe7bf755f475dce9956
184,802,412,740,585,060,000,000,000,000,000,000,000
6
rng: add request queue support to rng-random Requests are now created in the RngBackend parent class and the code path is shared by both rng-egd and rng-random. This commit fixes the rng-random implementation which processed only one request at a time and simply discarded all but the most recent one. In the guest this manifested as delayed completion of reads from virtio-rng, i.e. a read was completed only after another read was issued. By switching rng-random to use the same request queue as rng-egd, the unsafe stack-based allocation of the entropy buffer is eliminated and replaced with g_malloc. Signed-off-by: Ladi Prosek <[email protected]> Reviewed-by: Amit Shah <[email protected]> Message-Id: <[email protected]> Signed-off-by: Amit Shah <[email protected]>
//! Insert n copies of the list \c list at position \c pos of the current list \newinstance. template<typename t> CImgList<T> get_insert(const unsigned int n, const CImgList<t>& list, const unsigned int pos=~0U,
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
31,517,797,552,538,963,000,000,000,000,000,000,000
4
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
static void vmx_disable_intercept_for_msr(u32 msr, bool longmode_only) { if (!longmode_only) __vmx_disable_intercept_for_msr(vmx_msr_bitmap_legacy, msr, MSR_TYPE_R | MSR_TYPE_W); __vmx_disable_intercept_for_msr(vmx_msr_bitmap_longmode, msr, MSR_TYPE_R | MSR_TYPE_W); }
0
[]
kvm
a642fc305053cc1c6e47e4f4df327895747ab485
203,331,319,302,529,930,000,000,000,000,000,000,000
8
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]>
static av_always_inline int filter_3800(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int start, const int shift) { int32_t predictionA, predictionB, sign; int32_t d0, d1, d2, d3, d4; p->buf[delayA] = p->lastA[filter]; p->buf[delayB] = p->filterB[filter]; if (p->sample_pos < start) { predictionA = decoded + p->filterA[filter]; p->lastA[filter] = decoded; p->filterB[filter] = decoded; p->filterA[filter] = predictionA; return predictionA; } d2 = p->buf[delayA]; d1 = (p->buf[delayA] - p->buf[delayA - 1]) << 1; d0 = p->buf[delayA] + ((p->buf[delayA - 2] - p->buf[delayA - 1]) << 3); d3 = p->buf[delayB] * 2 - p->buf[delayB - 1]; d4 = p->buf[delayB]; predictionA = d0 * p->coeffsA[filter][0] + d1 * p->coeffsA[filter][1] + d2 * p->coeffsA[filter][2]; sign = APESIGN(decoded); p->coeffsA[filter][0] += (((d0 >> 30) & 2) - 1) * sign; p->coeffsA[filter][1] += (((d1 >> 28) & 8) - 4) * sign; p->coeffsA[filter][2] += (((d2 >> 28) & 8) - 4) * sign; predictionB = d3 * p->coeffsB[filter][0] - d4 * p->coeffsB[filter][1]; p->lastA[filter] = decoded + (predictionA >> 11); sign = APESIGN(p->lastA[filter]); p->coeffsB[filter][0] += (((d3 >> 29) & 4) - 2) * sign; p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign; p->filterB[filter] = p->lastA[filter] + (predictionB >> shift); p->filterA[filter] = p->filterB[filter] + ((p->filterA[filter] * 31) >> 5); return p->filterA[filter]; }
0
[ "CWE-125" ]
FFmpeg
ba4beaf6149f7241c8bd85fe853318c2f6837ad0
35,755,922,819,107,494,000,000,000,000,000,000,000
44
avcodec/apedec: Fix integer overflow Fixes: out of array access Fixes: PoC.ape and others Found-by: Bingchang, Liu@VARAS of IIE Signed-off-by: Michael Niedermayer <[email protected]>
static void GTextFieldChanged(GTextField *gt,int src) { GEvent e; e.type = et_controlevent; e.w = gt->g.base; e.u.control.subtype = et_textchanged; e.u.control.g = &gt->g; e.u.control.u.tf_changed.from_pulldown = src; if ( gt->g.handle_controlevent != NULL ) (gt->g.handle_controlevent)(&gt->g,&e); else GDrawPostEvent(&e); }
0
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
98,040,305,594,331,140,000,000,000,000,000,000,000
13
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, ext4_lblk_t iblock, unsigned int max_blocks, struct buffer_head *bh_result, int flags) { struct ext4_ext_path *path = NULL; struct ext4_extent_header *eh; struct ext4_extent newex, *ex, *last_ex; ext4_fsblk_t newblock; int err = 0, depth, ret, cache_type; unsigned int allocated = 0; struct ext4_allocation_request ar; ext4_io_end_t *io = EXT4_I(inode)->cur_aio_dio; __clear_bit(BH_New, &bh_result->b_state); ext_debug("blocks %u/%u requested for inode %lu\n", iblock, max_blocks, inode->i_ino); /* check in cache */ cache_type = ext4_ext_in_cache(inode, iblock, &newex); if (cache_type) { if (cache_type == EXT4_EXT_CACHE_GAP) { if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { /* * block isn't allocated yet and * user doesn't want to allocate it */ goto out2; } /* we should allocate requested block */ } else if (cache_type == EXT4_EXT_CACHE_EXTENT) { /* block is already allocated */ newblock = iblock - le32_to_cpu(newex.ee_block) + ext_pblock(&newex); /* number of remaining blocks in the extent */ allocated = ext4_ext_get_actual_len(&newex) - (iblock - le32_to_cpu(newex.ee_block)); goto out; } else { BUG(); } } /* find extent for this block */ path = ext4_ext_find_extent(inode, iblock, NULL); if (IS_ERR(path)) { err = PTR_ERR(path); path = NULL; goto out2; } depth = ext_depth(inode); /* * consistent leaf must not be empty; * this situation is possible, though, _during_ tree modification; * this is why assert can't be put in ext4_ext_find_extent() */ if (path[depth].p_ext == NULL && depth != 0) { ext4_error(inode->i_sb, "bad extent address " "inode: %lu, iblock: %d, depth: %d", inode->i_ino, iblock, depth); err = -EIO; goto out2; } eh = path[depth].p_hdr; ex = path[depth].p_ext; if (ex) { ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block); ext4_fsblk_t ee_start = ext_pblock(ex); unsigned short ee_len; /* * Uninitialized extents are treated as holes, except that * we split out initialized portions during a write. */ ee_len = ext4_ext_get_actual_len(ex); /* if found extent covers block, simply return it */ if (iblock >= ee_block && iblock < ee_block + ee_len) { newblock = iblock - ee_block + ee_start; /* number of remaining blocks in the extent */ allocated = ee_len - (iblock - ee_block); ext_debug("%u fit into %u:%d -> %llu\n", iblock, ee_block, ee_len, newblock); /* Do not put uninitialized extent in the cache */ if (!ext4_ext_is_uninitialized(ex)) { ext4_ext_put_in_cache(inode, ee_block, ee_len, ee_start, EXT4_EXT_CACHE_EXTENT); goto out; } ret = ext4_ext_handle_uninitialized_extents(handle, inode, iblock, max_blocks, path, flags, allocated, bh_result, newblock); return ret; } } /* * requested block isn't allocated yet; * we couldn't try to create block if create flag is zero */ if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { /* * put just found gap into cache to speed up * subsequent requests */ ext4_ext_put_gap_in_cache(inode, path, iblock); goto out2; } /* * Okay, we need to do block allocation. */ /* find neighbour allocated blocks */ ar.lleft = iblock; err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); if (err) goto out2; ar.lright = iblock; err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright); if (err) goto out2; /* * See if request is beyond maximum number of blocks we can have in * a single extent. For an initialized extent this limit is * EXT_INIT_MAX_LEN and for an uninitialized extent this limit is * EXT_UNINIT_MAX_LEN. */ if (max_blocks > EXT_INIT_MAX_LEN && !(flags & EXT4_GET_BLOCKS_UNINIT_EXT)) max_blocks = EXT_INIT_MAX_LEN; else if (max_blocks > EXT_UNINIT_MAX_LEN && (flags & EXT4_GET_BLOCKS_UNINIT_EXT)) max_blocks = EXT_UNINIT_MAX_LEN; /* Check if we can really insert (iblock)::(iblock+max_blocks) extent */ newex.ee_block = cpu_to_le32(iblock); newex.ee_len = cpu_to_le16(max_blocks); err = ext4_ext_check_overlap(inode, &newex, path); if (err) allocated = ext4_ext_get_actual_len(&newex); else allocated = max_blocks; /* allocate new block */ ar.inode = inode; ar.goal = ext4_ext_find_goal(inode, path, iblock); ar.logical = iblock; ar.len = allocated; if (S_ISREG(inode->i_mode)) ar.flags = EXT4_MB_HINT_DATA; else /* disable in-core preallocation for non-regular files */ ar.flags = 0; newblock = ext4_mb_new_blocks(handle, &ar, &err); if (!newblock) goto out2; ext_debug("allocate new block: goal %llu, found %llu/%u\n", ar.goal, newblock, allocated); /* try to insert new extent into found leaf and return */ ext4_ext_store_pblock(&newex, newblock); newex.ee_len = cpu_to_le16(ar.len); /* Mark uninitialized */ if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){ ext4_ext_mark_uninitialized(&newex); /* * io_end structure was created for every async * direct IO write to the middle of the file. * To avoid unecessary convertion for every aio dio rewrite * to the mid of file, here we flag the IO that is really * need the convertion. * For non asycn direct IO case, flag the inode state * that we need to perform convertion when IO is done. */ if (flags == EXT4_GET_BLOCKS_PRE_IO) { if (io) io->flag = EXT4_IO_UNWRITTEN; else ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); } } if (unlikely(EXT4_I(inode)->i_flags & EXT4_EOFBLOCKS_FL)) { if (eh->eh_entries) { last_ex = EXT_LAST_EXTENT(eh); if (iblock + ar.len > le32_to_cpu(last_ex->ee_block) + ext4_ext_get_actual_len(last_ex)) EXT4_I(inode)->i_flags &= ~EXT4_EOFBLOCKS_FL; } else { WARN_ON(eh->eh_entries == 0); ext4_error(inode->i_sb, __func__, "inode#%lu, eh->eh_entries = 0!", inode->i_ino); } } err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); if (err) { /* free data blocks we just allocated */ /* not a good idea to call discard here directly, * but otherwise we'd need to call it every free() */ ext4_discard_preallocations(inode); ext4_free_blocks(handle, inode, 0, ext_pblock(&newex), ext4_ext_get_actual_len(&newex), 0); goto out2; } /* previous routine could use block we allocated */ newblock = ext_pblock(&newex); allocated = ext4_ext_get_actual_len(&newex); if (allocated > max_blocks) allocated = max_blocks; set_buffer_new(bh_result); /* * Update reserved blocks/metadata blocks after successful * block allocation which had been deferred till now. */ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) ext4_da_update_reserve_space(inode, allocated, 1); /* * Cache the extent and update transaction to commit on fdatasync only * when it is _not_ an uninitialized extent. */ if ((flags & EXT4_GET_BLOCKS_UNINIT_EXT) == 0) { ext4_ext_put_in_cache(inode, iblock, allocated, newblock, EXT4_EXT_CACHE_EXTENT); ext4_update_inode_fsync_trans(handle, inode, 1); } else ext4_update_inode_fsync_trans(handle, inode, 0); out: if (allocated > max_blocks) allocated = max_blocks; ext4_ext_show_leaf(inode, path); set_buffer_mapped(bh_result); bh_result->b_bdev = inode->i_sb->s_bdev; bh_result->b_blocknr = newblock; out2: if (path) { ext4_ext_drop_refs(path); kfree(path); } return err ? err : allocated; }
1
[ "CWE-703" ]
linux
744692dc059845b2a3022119871846e74d4f6e11
13,168,939,870,586,630,000,000,000,000,000,000,000
250
ext4: use ext4_get_block_write in buffer write Allocate uninitialized extent before ext4 buffer write and convert the extent to initialized after io completes. The purpose is to make sure an extent can only be marked initialized after it has been written with new data so we can safely drop the i_mutex lock in ext4 DIO read without exposing stale data. This helps to improve multi-thread DIO read performance on high-speed disks. Skip the nobh and data=journal mount cases to make things simple for now. Signed-off-by: Jiaying Zhang <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]>
COMPS_MRTree * comps_mrtree_clone(COMPS_MRTree * rt) { COMPS_HSList * to_clone, *tmplist, *new_subnodes; COMPS_MRTree * ret; COMPS_HSListItem *it, *it2; COMPS_MRTreeData *rtdata; COMPS_HSList *new_data_list; to_clone = comps_hslist_create(); comps_hslist_init(to_clone, NULL, NULL, NULL); ret = comps_mrtree_create(rt->data_constructor, rt->data_cloner, rt->data_destructor); for (it = rt->subnodes->first; it != NULL; it = it->next) { rtdata = comps_mrtree_data_create(rt, ((COMPS_MRTreeData*)it->data)->key, NULL); new_data_list = comps_hslist_clone(((COMPS_MRTreeData*)it->data)->data); comps_hslist_destroy(&rtdata->data); comps_hslist_destroy(&rtdata->subnodes); rtdata->subnodes = ((COMPS_MRTreeData*)it->data)->subnodes; rtdata->data = new_data_list; comps_hslist_append(ret->subnodes, rtdata, 0); comps_hslist_append(to_clone, rtdata, 0); } while (to_clone->first) { it2 = to_clone->first; tmplist = ((COMPS_MRTreeData*)it2->data)->subnodes; comps_hslist_remove(to_clone, to_clone->first); new_subnodes = comps_hslist_create(); comps_hslist_init(new_subnodes, NULL, NULL, &comps_mrtree_data_destroy_v); for (it = tmplist->first; it != NULL; it = it->next) { rtdata = comps_mrtree_data_create(rt, ((COMPS_MRTreeData*)it->data)->key, NULL); new_data_list = comps_hslist_clone(((COMPS_MRTreeData*)it->data)->data); comps_hslist_destroy(&rtdata->subnodes); comps_hslist_destroy(&rtdata->data); rtdata->subnodes = ((COMPS_MRTreeData*)it->data)->subnodes; rtdata->data = new_data_list; comps_hslist_append(new_subnodes, rtdata, 0); comps_hslist_append(to_clone, rtdata, 0); } ((COMPS_MRTreeData*)it2->data)->subnodes = new_subnodes; free(it2); } comps_hslist_destroy(&to_clone); return ret; }
0
[ "CWE-416", "CWE-862" ]
libcomps
e3a5d056633677959ad924a51758876d415e7046
135,212,872,830,952,080,000,000,000,000,000,000,000
52
Fix UAF in comps_objmrtree_unite function The added field is not used at all in many places and it is probably the left-over of some copy-paste.
ssize_t qemu_receive_packet(NetClientState *nc, const uint8_t *buf, int size) { if (!qemu_can_receive_packet(nc)) { return 0; } return qemu_net_queue_receive(nc->incoming_queue, buf, size); }
0
[ "CWE-835" ]
qemu
705df5466c98f3efdd2b68d3b31dad86858acad7
160,161,094,941,050,240,000,000,000,000,000,000,000
8
net: introduce qemu_receive_packet() Some NIC supports loopback mode and this is done by calling nc->info->receive() directly which in fact suppresses the effort of reentrancy check that is done in qemu_net_queue_send(). Unfortunately we can't use qemu_net_queue_send() here since for loopback there's no sender as peer, so this patch introduce a qemu_receive_packet() which is used for implementing loopback mode for a NIC with this check. NIC that supports loopback mode will be converted to this helper. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Cc: [email protected] Signed-off-by: Jason Wang <[email protected]>
str_lower_case_match(OnigEncoding enc, int case_fold_flag, const UChar* t, const UChar* tend, const UChar* p, const UChar* end) { int lowlen; UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN]; while (t < tend) { lowlen = ONIGENC_MBC_CASE_FOLD(enc, case_fold_flag, &p, end, lowbuf); q = lowbuf; while (lowlen > 0) { if (*t++ != *q++) return 0; lowlen--; } } return 1; }
1
[ "CWE-125" ]
oniguruma
d3e402928b6eb3327f8f7d59a9edfa622fec557b
180,067,450,694,786,940,000,000,000,000,000,000,000
18
fix heap-buffer-overflow
return *this; }
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
233,995,471,937,811,400,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
static unsigned int spectrum512_FindIndex(i64 x, unsigned int c) { i64 x1; x1 = 10 * (i64)c; if (c & 1) /* If c is odd */ x1 = x1 - 5; else /* If c is even */ x1 = x1 + 1; if (x >= x1 && x < x1+160) c = c + 16; else if (x >= x1+160) c = c + 32; return c; }
0
[ "CWE-369" ]
deark
62acb7753b0e3c0d3ab3c15057b0a65222313334
165,763,841,123,276,250,000,000,000,000,000,000,000
18
pict,macrsrc: Fixed a bug that could cause division by 0 Found by F. Çelik.
GF_Err Media_ParseODFrame(GF_MediaBox *mdia, const GF_ISOSample *sample, GF_ISOSample **od_samp) { GF_TrackReferenceBox *tref; GF_TrackReferenceTypeBox *mpod; GF_Err e; GF_ODCom *com; GF_ODCodec *ODencode; GF_ODCodec *ODdecode; u32 i, j; //the commands we proceed GF_ESDUpdate *esdU, *esdU2; GF_ESDRemove *esdR, *esdR2; GF_ODUpdate *odU, *odU2; //the desc they contain GF_ObjectDescriptor *od; GF_IsomObjectDescriptor *isom_od; GF_ESD *esd; GF_ES_ID_Ref *ref; GF_Descriptor *desc; *od_samp = NULL; if (!mdia || !sample || !sample->data || !sample->dataLength) return GF_BAD_PARAM; //First find the references, and create them if none tref = mdia->mediaTrack->References; if (!tref) { tref = (GF_TrackReferenceBox *) gf_isom_box_new_parent(&mdia->mediaTrack->child_boxes, GF_ISOM_BOX_TYPE_TREF); if (!tref) return GF_OUT_OF_MEM; e = trak_on_child_box((GF_Box*)mdia->mediaTrack, (GF_Box *) tref, GF_FALSE); if (e) return e; } //then find the OD reference, and create it if none e = Track_FindRef(mdia->mediaTrack, GF_ISOM_BOX_TYPE_MPOD, &mpod); if (e) return e; if (!mpod) { mpod = (GF_TrackReferenceTypeBox *) gf_isom_box_new_parent(&tref->child_boxes, GF_ISOM_BOX_TYPE_REFT); if (!mpod) return GF_OUT_OF_MEM; mpod->reference_type = GF_ISOM_BOX_TYPE_MPOD; } //OK, create our codecs ODencode = gf_odf_codec_new(); if (!ODencode) return GF_OUT_OF_MEM; ODdecode = gf_odf_codec_new(); if (!ODdecode) return GF_OUT_OF_MEM; e = gf_odf_codec_set_au(ODdecode, sample->data, sample->dataLength); if (e) goto err_exit; e = gf_odf_codec_decode(ODdecode); if (e) goto err_exit; while (1) { com = gf_odf_codec_get_com(ODdecode); if (!com) break; //check our commands switch (com->tag) { //Rewrite OD Update case GF_ODF_OD_UPDATE_TAG: //duplicate our command odU = (GF_ODUpdate *) com; odU2 = (GF_ODUpdate *) gf_odf_com_new(GF_ODF_OD_UPDATE_TAG); i=0; while ((desc = (GF_Descriptor*)gf_list_enum(odU->objectDescriptors, &i))) { //both OD and IODs are accepted switch (desc->tag) { case GF_ODF_OD_TAG: case GF_ODF_IOD_TAG: break; default: e = GF_ODF_INVALID_DESCRIPTOR; goto err_exit; } //get the esd e = gf_odf_desc_copy(desc, (GF_Descriptor **)&od); if (e) goto err_exit; if (desc->tag == GF_ODF_OD_TAG) { isom_od = (GF_IsomObjectDescriptor *) gf_malloc(sizeof(GF_IsomObjectDescriptor)); if (!isom_od) return GF_OUT_OF_MEM; isom_od->tag = GF_ODF_ISOM_OD_TAG; } else { isom_od = (GF_IsomObjectDescriptor *) gf_malloc(sizeof(GF_IsomInitialObjectDescriptor)); if (!isom_od) return GF_OUT_OF_MEM; isom_od->tag = GF_ODF_ISOM_IOD_TAG; //copy PL ((GF_IsomInitialObjectDescriptor *)isom_od)->inlineProfileFlag = ((GF_InitialObjectDescriptor *)od)->inlineProfileFlag; ((GF_IsomInitialObjectDescriptor *)isom_od)->graphics_profileAndLevel = ((GF_InitialObjectDescriptor *)od)->graphics_profileAndLevel; ((GF_IsomInitialObjectDescriptor *)isom_od)->audio_profileAndLevel = ((GF_InitialObjectDescriptor *)od)->audio_profileAndLevel; ((GF_IsomInitialObjectDescriptor *)isom_od)->OD_profileAndLevel = ((GF_InitialObjectDescriptor *)od)->OD_profileAndLevel; ((GF_IsomInitialObjectDescriptor *)isom_od)->scene_profileAndLevel = ((GF_InitialObjectDescriptor *)od)->scene_profileAndLevel; ((GF_IsomInitialObjectDescriptor *)isom_od)->visual_profileAndLevel = ((GF_InitialObjectDescriptor *)od)->visual_profileAndLevel; ((GF_IsomInitialObjectDescriptor *)isom_od)->IPMPToolList = ((GF_InitialObjectDescriptor *)od)->IPMPToolList; ((GF_InitialObjectDescriptor *)od)->IPMPToolList = NULL; } //in OD stream only ref desc are accepted isom_od->ES_ID_RefDescriptors = gf_list_new(); isom_od->ES_ID_IncDescriptors = NULL; //TO DO: check that a given sampleDescription exists isom_od->extensionDescriptors = od->extensionDescriptors; od->extensionDescriptors = NULL; isom_od->IPMP_Descriptors = od->IPMP_Descriptors; od->IPMP_Descriptors = NULL; isom_od->OCIDescriptors = od->OCIDescriptors; od->OCIDescriptors = NULL; isom_od->URLString = od->URLString; od->URLString = NULL; isom_od->objectDescriptorID = od->objectDescriptorID; j=0; while ((esd = (GF_ESD*)gf_list_enum(od->ESDescriptors, &j))) { ref = (GF_ES_ID_Ref *) gf_odf_desc_new(GF_ODF_ESD_REF_TAG); if (!esd->ESID) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[ISOM] Missing ESID on ESD, cannot add track reference in OD frame")); e = GF_BAD_PARAM; goto err_exit; } //1 to 1 mapping trackID and ESID. Add this track to MPOD //if track does not exist, this will be remove while reading the OD stream e = reftype_AddRefTrack(mpod, esd->ESID, &ref->trackRef); if (e) goto err_exit; e = gf_odf_desc_add_desc((GF_Descriptor *)isom_od, (GF_Descriptor *)ref); if (e) goto err_exit; } //delete our desc gf_odf_desc_del((GF_Descriptor *)od); //and add the new one to our command gf_list_add(odU2->objectDescriptors, isom_od); } //delete the command gf_odf_com_del((GF_ODCom **)&odU); //and add the new one to the codec gf_odf_codec_add_com(ODencode, (GF_ODCom *)odU2); break; //Rewrite ESD Update case GF_ODF_ESD_UPDATE_TAG: esdU = (GF_ESDUpdate *) com; esdU2 = (GF_ESDUpdate *) gf_odf_com_new(GF_ODF_ESD_UPDATE_TAG); esdU2->ODID = esdU->ODID; i=0; while ((esd = (GF_ESD*)gf_list_enum(esdU->ESDescriptors, &i))) { ref = (GF_ES_ID_Ref *) gf_odf_desc_new(GF_ODF_ESD_REF_TAG); //1 to 1 mapping trackID and ESID e = reftype_AddRefTrack(mpod, esd->ESID, &ref->trackRef); if (e) goto err_exit; e = gf_list_add(esdU2->ESDescriptors, ref); if (e) goto err_exit; } gf_odf_com_del((GF_ODCom **)&esdU); gf_odf_codec_add_com(ODencode, (GF_ODCom *)esdU2); break; //Brand new case: the ESRemove has to be rewritten too according to the specs... case GF_ODF_ESD_REMOVE_TAG: esdR = (GF_ESDRemove *) com; esdR2 = (GF_ESDRemove *) gf_odf_com_new(GF_ODF_ESD_REMOVE_TAG); //change the tag for the file format esdR2->tag = GF_ODF_ESD_REMOVE_REF_TAG; esdR2->ODID = esdR->ODID; esdR2->NbESDs = esdR->NbESDs; if (esdR->NbESDs) { //alloc our stuff esdR2->ES_ID = (unsigned short*)gf_malloc(sizeof(u32) * esdR->NbESDs); if (!esdR2->ES_ID) { e = GF_OUT_OF_MEM; goto err_exit; } for (i = 0; i < esdR->NbESDs; i++) { //1 to 1 mapping trackID and ESID e = reftype_AddRefTrack(mpod, esdR->ES_ID[i], &esdR2->ES_ID[i]); if (e) goto err_exit; } } gf_odf_com_del(&com); gf_odf_codec_add_com(ODencode, (GF_ODCom *)esdR2); break; //Add the command as is default: e = gf_odf_codec_add_com(ODencode, com); if (e) goto err_exit; } } //encode our new AU e = gf_odf_codec_encode(ODencode, 1); if (e) goto err_exit; //and set the buffer in the sample *od_samp = gf_isom_sample_new(); (*od_samp)->CTS_Offset = sample->CTS_Offset; (*od_samp)->DTS = sample->DTS; (*od_samp)->IsRAP = sample->IsRAP; e = gf_odf_codec_get_au(ODencode, & (*od_samp)->data, & (*od_samp)->dataLength); if (e) { gf_isom_sample_del(od_samp); *od_samp = NULL; } err_exit: gf_odf_codec_del(ODencode); gf_odf_codec_del(ODdecode); return e; }
0
[ "CWE-476" ]
gpac
f0ba83717b6e4d7a15a1676d1fe06152e199b011
300,055,804,056,972,870,000,000,000,000,000,000,000
208
fixed #1772 (fuzz)
static void sctp_endpoint_bh_rcv(struct work_struct *work) { struct sctp_endpoint *ep = container_of(work, struct sctp_endpoint, base.inqueue.immediate); struct sctp_association *asoc; struct sock *sk; struct sctp_transport *transport; struct sctp_chunk *chunk; struct sctp_inq *inqueue; sctp_subtype_t subtype; sctp_state_t state; int error = 0; int first_time = 1; /* is this the first time through the looop */ if (ep->base.dead) return; asoc = NULL; inqueue = &ep->base.inqueue; sk = ep->base.sk; while (NULL != (chunk = sctp_inq_pop(inqueue))) { subtype = SCTP_ST_CHUNK(chunk->chunk_hdr->type); /* If the first chunk in the packet is AUTH, do special * processing specified in Section 6.3 of SCTP-AUTH spec */ if (first_time && (subtype.chunk == SCTP_CID_AUTH)) { struct sctp_chunkhdr *next_hdr; next_hdr = sctp_inq_peek(inqueue); if (!next_hdr) goto normal; /* If the next chunk is COOKIE-ECHO, skip the AUTH * chunk while saving a pointer to it so we can do * Authentication later (during cookie-echo * processing). */ if (next_hdr->type == SCTP_CID_COOKIE_ECHO) { chunk->auth_chunk = skb_clone(chunk->skb, GFP_ATOMIC); chunk->auth = 1; continue; } } normal: /* We might have grown an association since last we * looked, so try again. * * This happens when we've just processed our * COOKIE-ECHO chunk. */ if (NULL == chunk->asoc) { asoc = sctp_endpoint_lookup_assoc(ep, sctp_source(chunk), &transport); chunk->asoc = asoc; chunk->transport = transport; } state = asoc ? asoc->state : SCTP_STATE_CLOSED; if (sctp_auth_recv_cid(subtype.chunk, asoc) && !chunk->auth) continue; /* Remember where the last DATA chunk came from so we * know where to send the SACK. */ if (asoc && sctp_chunk_is_data(chunk)) asoc->peer.last_data_from = chunk->transport; else SCTP_INC_STATS(SCTP_MIB_INCTRLCHUNKS); if (chunk->transport) chunk->transport->last_time_heard = jiffies; error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state, ep, asoc, chunk, GFP_ATOMIC); if (error && chunk) chunk->pdiscard = 1; /* Check to see if the endpoint is freed in response to * the incoming chunk. If so, get out of the while loop. */ if (!sctp_sk(sk)->ep) break; if (first_time) first_time = 0; } }
0
[]
linux-2.6
5e739d1752aca4e8f3e794d431503bfca3162df4
212,683,153,357,637,250,000,000,000,000,000,000,000
93
sctp: fix potential panics in the SCTP-AUTH API. All of the SCTP-AUTH socket options could cause a panic if the extension is disabled and the API is envoked. Additionally, there were some additional assumptions that certain pointers would always be valid which may not always be the case. This patch hardens the API and address all of the crash scenarios. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
NOEXPORT char *sni_init(SERVICE_OPTIONS *section) { char *tmp_str; SERVICE_OPTIONS *tmpsrv; /* server mode: update servername_list based on the SNI option */ if(!section->option.client && section->sni) { tmp_str=strchr(section->sni, ':'); if(!tmp_str) return "Invalid SNI parameter format"; *tmp_str++='\0'; for(tmpsrv=new_service_options.next; tmpsrv; tmpsrv=tmpsrv->next) if(!strcmp(tmpsrv->servname, section->sni)) break; if(!tmpsrv) return "SNI section name not found"; if(tmpsrv->option.client) return "SNI master service is a TLS client"; if(tmpsrv->servername_list_tail) { tmpsrv->servername_list_tail->next=str_alloc_detached(sizeof(SERVERNAME_LIST)); tmpsrv->servername_list_tail=tmpsrv->servername_list_tail->next; } else { /* first virtual service */ tmpsrv->servername_list_head= tmpsrv->servername_list_tail= str_alloc_detached(sizeof(SERVERNAME_LIST)); tmpsrv->ssl_options_set|= SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; } /* a slave section reference is needed to prevent a race condition while switching to a section after configuration file reload */ service_up_ref(section); tmpsrv->servername_list_tail->servername=str_dup_detached(tmp_str); tmpsrv->servername_list_tail->opt=section; tmpsrv->servername_list_tail->next=NULL; /* always negotiate a new session on renegotiation, as the TLS * context settings (including access control) may be different */ section->ssl_options_set|= SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; } /* client mode: setup SNI default based on 'protocolHost' and 'connect' options */ if(section->option.client && !section->sni) { /* setup host_name for SNI, prefer SNI and protocolHost if specified */ if(section->protocol_host) /* 'protocolHost' option */ section->sni=str_dup_detached(section->protocol_host); else if(section->connect_addr.names) /* 'connect' option */ section->sni=str_dup_detached(section->connect_addr.names->name); /* first hostname */ if(section->sni) { /* either 'protocolHost' or 'connect' specified */ tmp_str=strrchr(section->sni, ':'); if(tmp_str) { /* 'host:port' -> drop ':port' */ *tmp_str='\0'; } else { /* 'port' -> default to 'localhost' */ str_free(section->sni); section->sni=str_dup_detached("localhost"); } } } return NULL; }
0
[ "CWE-295" ]
stunnel
ebad9ddc4efb2635f37174c9d800d06206f1edf9
318,740,309,603,706,040,000,000,000,000,000,000,000
58
stunnel-5.57
int snd_line6_hw_free(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); struct line6_pcm_stream *pstr = get_stream(line6pcm, substream->stream); mutex_lock(&line6pcm->state_mutex); line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM); mutex_unlock(&line6pcm->state_mutex); return snd_pcm_lib_free_pages(substream); }
0
[ "CWE-476" ]
linux
3450121997ce872eb7f1248417225827ea249710
242,826,173,576,202,500,000,000,000,000,000,000,000
10
ALSA: line6: Fix write on zero-sized buffer LINE6 drivers allocate the buffers based on the value returned from usb_maxpacket() calls. The manipulated device may return zero for this, and this results in the kmalloc() with zero size (and it may succeed) while the other part of the driver code writes the packet data with the fixed size -- which eventually overwrites. This patch adds a simple sanity check for the invalid buffer size for avoiding that problem. Reported-by: [email protected] Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>