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
exif_mnote_data_canon_get_title (ExifMnoteData *note, unsigned int i) { ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note; unsigned int m, s; if (!dc) return NULL; exif_mnote_data_canon_get_tags (dc, i, &m, &s); if (m >= dc->count) return NULL; return mnote_canon_tag_get_title_sub (dc->entries[m].tag, s, dc->options); }
0
[ "CWE-125" ]
libexif
435e21f05001fb03f9f186fa7cbc69454afd00d1
262,405,964,206,306,430,000,000,000,000,000,000,000
10
Fix MakerNote tag size overflow issues at read time. Check for a size overflow while reading tags, which ensures that the size is always consistent for the given components and type of the entry, making checking further down superfluous. This provides an alternate fix for https://sourceforge.net/p/libexif/bugs/125/ CVE-2016-6328 and for all the MakerNote types. Likely, this makes both commits 41bd0423 and 89e5b1c1 redundant as it ensures that MakerNote entries are well-formed when they're populated. Some improvements on top by Marcus Meissner <[email protected]> CVE-2020-13112
uint Field_blob::packed_col_length(const uchar *data_ptr, uint length) { if (length > 255) return uint2korr(data_ptr)+2; return (uint) *data_ptr + 1; }
0
[ "CWE-416", "CWE-703" ]
server
08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917
337,889,161,763,544,070,000,000,000,000,000,000,000
6
MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if() vcol_info->expr is allocated on expr_arena at parsing stage. Since expr item is allocated on expr_arena all its containee items must be allocated on expr_arena too. Otherwise fix_session_expr() will encounter prematurely freed item. When table is reopened from cache vcol_info contains stale expression. We refresh expression via TABLE::vcol_fix_exprs() but first we must prepare a proper context (Vcol_expr_context) which meets some requirements: 1. As noted above expr update must be done on expr_arena as there may be new items created. It was a bug in fix_session_expr_for_read() and was just not reproduced because of no second refix. Now refix is done for more cases so it does reproduce. Tests affected: vcol.binlog 2. Also name resolution context must be narrowed to the single table. Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes 3. sql_mode must be clean and not fail expr update. sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc must not affect vcol expression update. If the table was created successfully any further evaluation must not fail. Tests affected: main.func_like Reviewed by: Sergei Golubchik <[email protected]>
static int kill_ok_by_cred(struct task_struct *t) { const struct cred *cred = current_cred(); const struct cred *tcred = __task_cred(t); if (cred->user->user_ns == tcred->user->user_ns && (cred->euid == tcred->suid || cred->euid == tcred->uid || cred->uid == tcred->suid || cred->uid == tcred->uid)) return 1; if (ns_capable(tcred->user->user_ns, CAP_KILL)) return 1; return 0; }
0
[]
linux-2.6
243b422af9ea9af4ead07a8ad54c90d4f9b6081a
224,913,114,738,777,050,000,000,000,000,000,000,000
17
Relax si_code check in rt_sigqueueinfo and rt_tgsigqueueinfo Commit da48524eb206 ("Prevent rt_sigqueueinfo and rt_tgsigqueueinfo from spoofing the signal code") made the check on si_code too strict. There are several legitimate places where glibc wants to queue a negative si_code different from SI_QUEUE: - This was first noticed with glibc's aio implementation, which wants to queue a signal with si_code SI_ASYNCIO; the current kernel causes glibc's tst-aio4 test to fail because rt_sigqueueinfo() fails with EPERM. - Further examination of the glibc source shows that getaddrinfo_a() wants to use SI_ASYNCNL (which the kernel does not even define). The timer_create() fallback code wants to queue signals with SI_TIMER. As suggested by Oleg Nesterov <[email protected]>, loosen the check to forbid only the problematic SI_TKILL case. Reported-by: Klaus Dittrich <[email protected]> Acked-by: Julien Tinnes <[email protected]> Cc: <[email protected]> Signed-off-by: Roland Dreier <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
tr_variant* tr_variantListAddRaw(tr_variant* list, void const* val, size_t len) { tr_variant* child = tr_variantListAdd(list); tr_variantInitRaw(child, val, len); return child; }
0
[ "CWE-416", "CWE-284" ]
transmission
2123adf8e5e1c2b48791f9d22fc8c747e974180e
275,608,144,616,899,360,000,000,000,000,000,000,000
6
CVE-2018-10756: Fix heap-use-after-free in tr_variantWalk In libtransmission/variant.c, function tr_variantWalk, when the variant stack is reallocated, a pointer to the previously allocated memory region is kept. This address is later accessed (heap use-after-free) while walking back down the stack, causing the application to crash. The application can be any application which uses libtransmission, such as transmission-daemon, transmission-gtk, transmission-show, etc. Reported-by: Tom Richards <[email protected]>
static void BuildAndStoreBlockSwitchEntropyCodes(BlockEncoder* self, HuffmanTree* tree, size_t* storage_ix, uint8_t* storage) { BuildAndStoreBlockSplitCode(self->block_types_, self->block_lengths_, self->num_blocks_, self->num_block_types_, tree, &self->block_split_code_, storage_ix, storage); }
0
[ "CWE-120" ]
brotli
223d80cfbec8fd346e32906c732c8ede21f0cea6
165,631,419,958,904,250,000,000,000,000,000,000,000
6
Update (#826) * IMPORTANT: decoder: fix potential overflow when input chunk is >2GiB * simplify max Huffman table size calculation * eliminate symbol duplicates (static arrays in .h files) * minor combing in research/ code
int nfs_wb_page(struct inode *inode, struct page *page) { loff_t range_start = page_file_offset(page); loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1); struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = 0, .range_start = range_start, .range_end = range_end, }; int ret; for (;;) { wait_on_page_writeback(page); if (clear_page_dirty_for_io(page)) { ret = nfs_writepage_locked(page, &wbc); if (ret < 0) goto out_error; continue; } if (!PagePrivate(page)) break; ret = nfs_commit_inode(inode, FLUSH_SYNC); if (ret < 0) goto out_error; } return 0; out_error: return ret; }
0
[]
linux
c7559663e42f4294ffe31fe159da6b6a66b35d61
63,253,157,179,746,580,000,000,000,000,000,000,000
30
NFS: Allow nfs_updatepage to extend a write under additional circumstances Currently nfs_updatepage allows a write to be extended to cover a full page only if we don't have a byte range lock lock on the file... but if we have a write delegation on the file or if we have the whole file locked for writing then we should be allowed to extend the write as well. Signed-off-by: Scott Mayhew <[email protected]> [Trond: fix up call to nfs_have_delegation()] Signed-off-by: Trond Myklebust <[email protected]>
static int __videobuf_mmap_free(struct videobuf_queue *q) { unsigned int i; for (i = 0; i < VIDEO_MAX_FRAME; i++) { if (q->bufs[i]) { if (q->bufs[i]->map) return -EBUSY; } } return 0; }
0
[ "CWE-119", "CWE-787" ]
linux
0b29669c065f60501e7289e1950fa2a618962358
229,008,678,380,850,270,000,000,000,000,000,000,000
13
V4L/DVB (6751): V4L: Memory leak! Fix count in videobuf-vmalloc mmap This is pretty serious bug. map->count is never initialized after the call to kmalloc making the count start at some random trash value. The end result is leaking videobufs. Also, fix up the debug statements to print unsigned values. Pushed to http://ifup.org/hg/v4l-dvb too Signed-off-by: Brandon Philips <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
int lh_table_delete(struct lh_table *t, const void *k) { struct lh_entry *e = lh_table_lookup_entry(t, k); if(!e) return -1; return lh_table_delete_entry(t, e); }
0
[ "CWE-119", "CWE-310" ]
json-c
64e36901a0614bf64a19bc3396469c66dcd0b015
188,045,759,613,260,280,000,000,000,000,000,000,000
6
Patch to address the following issues: * CVE-2013-6371: hash collision denial of service * CVE-2013-6370: buffer overflow if size_t is larger than int
static void n_tty_packet_mode_flush(struct tty_struct *tty) { unsigned long flags; if (tty->link->packet) { spin_lock_irqsave(&tty->ctrl_lock, flags); tty->ctrl_status |= TIOCPKT_FLUSHREAD; spin_unlock_irqrestore(&tty->ctrl_lock, flags); wake_up_interruptible(&tty->link->read_wait); } }
0
[ "CWE-704" ]
linux
966031f340185eddd05affcf72b740549f056348
308,764,393,204,040,800,000,000,000,000,000,000,000
11
n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD) We added support for EXTPROC back in 2010 in commit 26df6d13406d ("tty: Add EXTPROC support for LINEMODE") and the intent was to allow it to override some (all?) ICANON behavior. Quoting from that original commit message: There is a new bit in the termios local flag word, EXTPROC. When this bit is set, several aspects of the terminal driver are disabled. Input line editing, character echo, and mapping of signals are all disabled. This allows the telnetd to turn off these functions when in linemode, but still keep track of what state the user wants the terminal to be in. but the problem turns out that "several aspects of the terminal driver are disabled" is a bit ambiguous, and you can really confuse the n_tty layer by setting EXTPROC and then causing some of the ICANON invariants to no longer be maintained. This fixes at least one such case (TIOCINQ) becoming unhappy because of the confusion over whether ICANON really means ICANON when EXTPROC is set. This basically makes TIOCINQ match the case of read: if EXTPROC is set, we ignore ICANON. Also, make sure to reset the ICANON state ie EXTPROC changes, not just if ICANON changes. Fixes: 26df6d13406d ("tty: Add EXTPROC support for LINEMODE") Reported-by: Tetsuo Handa <[email protected]> Reported-by: syzkaller <[email protected]> Cc: Jiri Slaby <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static inline uint32_t cirrus_src32(CirrusVGAState *s, uint32_t srcaddr) { uint32_t *src; if (s->cirrus_srccounter) { /* cputovideo */ src = (void *)&s->cirrus_bltbuf[srcaddr & (CIRRUS_BLTBUFSIZE - 1) & ~3]; } else { /* videotovideo */ src = (void *)&s->vga.vram_ptr[srcaddr & s->cirrus_addr_mask & ~3]; } return *src; }
0
[ "CWE-119" ]
qemu
ffaf857778286ca54e3804432a2369a279e73aa7
164,491,324,546,499,060,000,000,000,000,000,000,000
13
cirrus: stop passing around src pointers in the blitter Does basically the same as "cirrus: stop passing around dst pointers in the blitter", just for the src pointer instead of the dst pointer. For the src we have to care about cputovideo blits though and fetch the data from s->cirrus_bltbuf instead of vga memory. The cirrus_src*() helper functions handle that. Signed-off-by: Gerd Hoffmann <[email protected]> Message-id: [email protected]
static void rtreeCheckCount(RtreeCheck *pCheck, const char *zTbl, i64 nExpect){ if( pCheck->rc==SQLITE_OK ){ sqlite3_stmt *pCount; pCount = rtreeCheckPrepare(pCheck, "SELECT count(*) FROM %Q.'%q%s'", pCheck->zDb, pCheck->zTab, zTbl ); if( pCount ){ if( sqlite3_step(pCount)==SQLITE_ROW ){ i64 nActual = sqlite3_column_int64(pCount, 0); if( nActual!=nExpect ){ rtreeCheckAppendMsg(pCheck, "Wrong number of entries in %%%s table" " - expected %lld, actual %lld" , zTbl, nExpect, nActual ); } } pCheck->rc = sqlite3_finalize(pCount); } } }
0
[ "CWE-125" ]
sqlite
e41fd72acc7a06ce5a6a7d28154db1ffe8ba37a8
72,388,263,553,001,570,000,000,000,000,000,000,000
19
Enhance the rtreenode() function of rtree (used for testing) so that it uses the newer sqlite3_str object for better performance and improved error reporting. FossilOrigin-Name: 90acdbfce9c088582d5165589f7eac462b00062bbfffacdcc786eb9cf3ea5377
iperf_new_test() { struct iperf_test *test; test = (struct iperf_test *) malloc(sizeof(struct iperf_test)); if (!test) { i_errno = IENEWTEST; return NULL; } /* initialize everything to zero */ memset(test, 0, sizeof(struct iperf_test)); test->settings = (struct iperf_settings *) malloc(sizeof(struct iperf_settings)); if (!test->settings) { free(test); i_errno = IENEWTEST; return NULL; } memset(test->settings, 0, sizeof(struct iperf_settings)); return test; }
0
[ "CWE-120", "CWE-119", "CWE-787" ]
iperf
91f2fa59e8ed80dfbf400add0164ee0e508e412a
44,541,549,211,565,470,000,000,000,000,000,000,000
22
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]>
struct dentry *d_alloc_cursor(struct dentry * parent) { struct dentry *dentry = __d_alloc(parent->d_sb, NULL); if (dentry) { dentry->d_flags |= DCACHE_RCUACCESS | DCACHE_DENTRY_CURSOR; dentry->d_parent = dget(parent); } return dentry; }
0
[ "CWE-362", "CWE-399" ]
linux
49d31c2f389acfe83417083e1208422b4091cd9e
129,794,812,754,490,470,000,000,000,000,000,000,000
9
dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <[email protected]>
Value ExpressionSwitch::evaluate(const Document& root, Variables* variables) const { for (auto&& branch : _branches) { Value caseExpression(branch.first->evaluate(root, variables)); if (caseExpression.coerceToBool()) { return branch.second->evaluate(root, variables); } } uassert(40066, "$switch could not find a matching branch for an input, and no default was specified.", _default); return _default->evaluate(root, variables); }
0
[]
mongo
1772b9a0393b55e6a280a35e8f0a1f75c014f301
73,629,967,137,453,130,000,000,000,000,000,000,000
15
SERVER-49404 Enforce additional checks in $arrayToObject
static int orinoco_ioctl_get_encodeext(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct orinoco_private *priv = ndev_priv(dev); struct iw_point *encoding = &wrqu->encoding; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; int idx, max_key_len; unsigned long flags; int err; if (orinoco_lock(priv, &flags) != 0) return -EBUSY; err = -EINVAL; max_key_len = encoding->length - sizeof(*ext); if (max_key_len < 0) goto out; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) { if ((idx < 1) || (idx > 4)) goto out; idx--; } else idx = priv->tx_key; encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); switch (priv->encode_alg) { case ORINOCO_ALG_NONE: ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; encoding->flags |= IW_ENCODE_DISABLED; break; case ORINOCO_ALG_WEP: ext->alg = IW_ENCODE_ALG_WEP; ext->key_len = min(priv->keys[idx].key_len, max_key_len); memcpy(ext->key, priv->keys[idx].key, ext->key_len); encoding->flags |= IW_ENCODE_ENABLED; break; case ORINOCO_ALG_TKIP: ext->alg = IW_ENCODE_ALG_TKIP; ext->key_len = min(priv->keys[idx].key_len, max_key_len); memcpy(ext->key, priv->keys[idx].key, ext->key_len); encoding->flags |= IW_ENCODE_ENABLED; break; } err = 0; out: orinoco_unlock(priv, &flags); return err; }
0
[]
linux
0a54917c3fc295cb61f3fb52373c173fd3b69f48
238,225,557,273,334,400,000,000,000,000,000,000,000
57
orinoco: fix TKIP countermeasure behaviour Enable the port when disabling countermeasures, and disable it on enabling countermeasures. This bug causes the response of the system to certain attacks to be ineffective. It also prevents wpa_supplicant from getting scan results, as wpa_supplicant disables countermeasures on startup - preventing the hardware from scanning. wpa_supplicant works with ap_mode=2 despite this bug because the commit handler re-enables the port. The log tends to look like: State: DISCONNECTED -> SCANNING Starting AP scan for wildcard SSID Scan requested (ret=0) - scan timeout 5 seconds EAPOL: disable timer tick EAPOL: Supplicant port status: Unauthorized Scan timeout - try to get results Failed to get scan results Failed to get scan results - try scanning again Setting scan request: 1 sec 0 usec Starting AP scan for wildcard SSID Scan requested (ret=-1) - scan timeout 5 seconds Failed to initiate AP scan. Reported by: Giacomo Comes <[email protected]> Signed-off by: David Kilroy <[email protected]> Cc: [email protected] Signed-off-by: John W. Linville <[email protected]>
static int ref_module(struct module *a, struct module *b) { int err; if (b == NULL || already_uses(a, b)) return 0; /* If module isn't available, we fail. */ err = strong_try_module_get(b); if (err) return err; err = add_module_usage(a, b); if (err) { module_put(b); return err; } return 0; }
0
[ "CWE-362", "CWE-347" ]
linux
0c18f29aae7ce3dadd26d8ee3505d07cc982df75
122,327,729,927,737,470,000,000,000,000,000,000,000
19
module: limit enabling module.sig_enforce Irrespective as to whether CONFIG_MODULE_SIG is configured, specifying "module.sig_enforce=1" on the boot command line sets "sig_enforce". Only allow "sig_enforce" to be set when CONFIG_MODULE_SIG is configured. This patch makes the presence of /sys/module/module/parameters/sig_enforce dependent on CONFIG_MODULE_SIG=y. Fixes: fda784e50aac ("module: export module signature enforcement status") Reported-by: Nayna Jain <[email protected]> Tested-by: Mimi Zohar <[email protected]> Tested-by: Jessica Yu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Jessica Yu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static Bool on_crypt_event(void *_udta, GF_Event *evt) { Double progress; u32 *prev_progress = (u32 *)_udta; if (!_udta) return GF_FALSE; if (evt->type != GF_EVENT_PROGRESS) return GF_FALSE; if (!evt->progress.total) return GF_FALSE; progress = (Double) (100*evt->progress.done) / evt->progress.total; if ((u32) progress==*prev_progress) return GF_FALSE; *prev_progress = (u32) progress; #ifndef GPAC_DISABLE_LOG GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("Encrypting: % 2.2f %%%c", progress, gf_prog_lf)); #else fprintf(stderr, "Encrypting: % 2.2f %%%c", progress, gf_prog_lf); #endif return GF_FALSE; }
0
[ "CWE-787" ]
gpac
ea1eca00fd92fa17f0e25ac25652622924a9a6a0
57,828,990,984,066,380,000,000,000,000,000,000,000
20
fixed #2138
iperf_reporter_callback(struct iperf_test *test) { switch (test->state) { case TEST_RUNNING: case STREAM_RUNNING: /* print interval results for each stream */ iperf_print_intermediate(test); break; case TEST_END: case DISPLAY_RESULTS: iperf_print_intermediate(test); iperf_print_results(test); break; } }
0
[ "CWE-120", "CWE-119", "CWE-787" ]
iperf
91f2fa59e8ed80dfbf400add0164ee0e508e412a
260,077,864,289,979,830,000,000,000,000,000,000,000
16
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]>
ModuleExport size_t RegisterFLIFImage(void) { char version[MaxTextExtent]; MagickInfo *entry; *version='\0'; entry=SetMagickInfo("FLIF"); #if defined(MAGICKCORE_FLIF_DELEGATE) entry->decoder=(DecodeImageHandler *) ReadFLIFImage; entry->encoder=(EncodeImageHandler *) WriteFLIFImage; (void) FormatLocaleString(version,MaxTextExtent,"libflif %d.%d.%d [%04X]", (FLIF_VERSION >> 16) & 0xff, (FLIF_VERSION >> 8) & 0xff, (FLIF_VERSION >> 0) & 0xff,FLIF_ABI_VERSION); #endif entry->description=ConstantString("Free Lossless Image Format"); entry->adjoin=MagickTrue; entry->module=ConstantString("FLIF"); entry->mime_type=ConstantString("image/flif"); entry->magick=(IsImageFormatHandler *) IsFLIF; if (*version != '\0') entry->version=ConstantString(version); (void) RegisterMagickInfo(entry); return(MagickImageCoderSignature); }
0
[ "CWE-401" ]
ImageMagick6
210474b2fac6a661bfa7ed563213920e93e76395
46,893,813,634,193,850,000,000,000,000,000,000,000
28
Fix ultra rare but potential memory-leak
bool derive_edgeFlags_CTBRow(de265_image* img, int ctby) { const seq_parameter_set& sps = img->get_sps(); const pic_parameter_set& pps = img->get_pps(); const int minCbSize = sps.MinCbSizeY; bool deblocking_enabled=false; // whether deblocking is enabled in some part of the image int ctb_mask = (1<<sps.Log2CtbSizeY)-1; int picWidthInCtbs = sps.PicWidthInCtbsY; int ctbshift = sps.Log2CtbSizeY; int cb_y_start = ( ctby << sps.Log2CtbSizeY) >> sps.Log2MinCbSizeY; int cb_y_end = ((ctby+1) << sps.Log2CtbSizeY) >> sps.Log2MinCbSizeY; cb_y_end = std::min(cb_y_end, sps.PicHeightInMinCbsY); for (int cb_y=cb_y_start;cb_y<cb_y_end;cb_y++) for (int cb_x=0;cb_x<img->get_sps().PicWidthInMinCbsY;cb_x++) { int log2CbSize = img->get_log2CbSize_cbUnits(cb_x,cb_y); if (log2CbSize==0) { continue; } // we are now at the top corner of a CB int x0 = cb_x * minCbSize; int y0 = cb_y * minCbSize; int x0ctb = x0 >> ctbshift; int y0ctb = y0 >> ctbshift; // check for corrupted streams if (img->is_SliceHeader_available(x0,y0)==false) { return false; } // check whether we should filter this slice slice_segment_header* shdr = img->get_SliceHeader(x0,y0); // check whether to filter left and top edge uint8_t filterLeftCbEdge = DEBLOCK_FLAG_VERTI; uint8_t filterTopCbEdge = DEBLOCK_FLAG_HORIZ; if (x0 == 0) filterLeftCbEdge = 0; if (y0 == 0) filterTopCbEdge = 0; // check for slice and tile boundaries (8.7.2, step 2 in both processes) if (x0 && ((x0 & ctb_mask) == 0)) { // left edge at CTB boundary if (shdr->slice_loop_filter_across_slices_enabled_flag == 0 && img->is_SliceHeader_available(x0-1,y0) && // for corrupted streams shdr->SliceAddrRS != img->get_SliceHeader(x0-1,y0)->SliceAddrRS) { filterLeftCbEdge = 0; } else if (pps.loop_filter_across_tiles_enabled_flag == 0 && pps.TileIdRS[ x0ctb +y0ctb*picWidthInCtbs] != pps.TileIdRS[((x0-1)>>ctbshift)+y0ctb*picWidthInCtbs]) { filterLeftCbEdge = 0; } } if (y0 && ((y0 & ctb_mask) == 0)) { // top edge at CTB boundary if (shdr->slice_loop_filter_across_slices_enabled_flag == 0 && img->is_SliceHeader_available(x0,y0-1) && // for corrupted streams shdr->SliceAddrRS != img->get_SliceHeader(x0,y0-1)->SliceAddrRS) { filterTopCbEdge = 0; } else if (pps.loop_filter_across_tiles_enabled_flag == 0 && pps.TileIdRS[x0ctb+ y0ctb *picWidthInCtbs] != pps.TileIdRS[x0ctb+((y0-1)>>ctbshift)*picWidthInCtbs]) { filterTopCbEdge = 0; } } // mark edges if (shdr->slice_deblocking_filter_disabled_flag==0) { deblocking_enabled=true; markTransformBlockBoundary(img, x0,y0, log2CbSize,0, filterLeftCbEdge, filterTopCbEdge); markPredictionBlockBoundary(img, x0,y0, log2CbSize, filterLeftCbEdge, filterTopCbEdge); } } return deblocking_enabled; }
0
[ "CWE-703" ]
libde265
45904e5667c5bf59c67fcdc586dfba110832894c
86,608,240,226,398,510,000,000,000,000,000,000,000
96
fix reading invalid images where shdr references are NULL in part of the image (#302)
loop_break(codegen_scope *s, node *tree) { if (!s->loop) { codegen(s, tree, NOVAL); raise_error(s, "unexpected break"); } else { struct loopinfo *loop; loop = s->loop; if (tree) { if (loop->reg < 0) { codegen(s, tree, NOVAL); } else { gen_retval(s, tree); } } while (loop) { if (loop->type == LOOP_BEGIN) { loop = loop->prev; } else if (loop->type == LOOP_RESCUE) { loop = loop->prev; } else{ break; } } if (!loop) { raise_error(s, "unexpected break"); return; } if (loop->type == LOOP_NORMAL) { int tmp; if (loop->reg >= 0) { if (tree) { gen_move(s, loop->reg, cursp(), 0); } else { genop_1(s, OP_LOADNIL, loop->reg); } } tmp = genjmp(s, OP_JMPUW, loop->pc2); loop->pc2 = tmp; } else { if (!tree) { genop_1(s, OP_LOADNIL, cursp()); } gen_return(s, OP_BREAK, cursp()); } } }
0
[ "CWE-415", "CWE-122" ]
mruby
38b164ace7d6ae1c367883a3d67d7f559783faad
251,272,784,016,464,700,000,000,000,000,000,000,000
57
codegen.c: fix a bug in `gen_values()`. - Fix limit handling that fails 15 arguments method calls. - Fix too early argument packing in arrays.
static int cx24116_writeregN(struct cx24116_state *state, int reg, const u8 *data, u16 len) { int ret = -EREMOTEIO; struct i2c_msg msg; u8 *buf; buf = kmalloc(len + 1, GFP_KERNEL); if (buf == NULL) { printk("Unable to kmalloc\n"); ret = -ENOMEM; goto error; } *(buf) = reg; memcpy(buf + 1, data, len); msg.addr = state->config->demod_address; msg.flags = 0; msg.buf = buf; msg.len = len + 1; if (debug > 1) printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", __func__, reg, len); ret = i2c_transfer(state->i2c, &msg, 1); if (ret != 1) { printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x\n", __func__, ret, reg); ret = -EREMOTEIO; } error: kfree(buf); return ret; }
0
[ "CWE-476", "CWE-119", "CWE-125" ]
linux
1fa2337a315a2448c5434f41e00d56b01a22283c
252,477,692,205,497,070,000,000,000,000,000,000,000
38
[media] cx24116: fix a buffer overflow when checking userspace params The maximum size for a DiSEqC command is 6, according to the userspace API. However, the code allows to write up much more values: drivers/media/dvb-frontends/cx24116.c:983 cx24116_send_diseqc_msg() error: buffer overflow 'd->msg' 6 <= 23 Cc: [email protected] Signed-off-by: Mauro Carvalho Chehab <[email protected]>
istr_set_destroy (GHashTable *table) { g_hash_table_destroy (table); }
0
[]
nautilus
7632a3e13874a2c5e8988428ca913620a25df983
73,818,849,245,066,790,000,000,000,000,000,000,000
4
Check for trusted desktop file launchers. 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-directory-async.c: Check for trusted desktop file launchers. * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c: * libnautilus-private/nautilus-file.h: Add nautilus_file_is_trusted_link. Allow unsetting of custom display name. * libnautilus-private/nautilus-mime-actions.c: Display dialog when trying to launch a non-trusted desktop file. svn path=/trunk/; revision=15003
static WORD_DESC * parameter_brace_expand_rhs (name, value, c, quoted, pflags, qdollaratp, hasdollarat) char *name, *value; int c, quoted, pflags, *qdollaratp, *hasdollarat; { WORD_DESC *w; WORD_LIST *l; char *t, *t1, *temp, *vname; int l_hasdollat, sindex; /*itrace("parameter_brace_expand_rhs: %s:%s pflags = %d", name, value, pflags);*/ /* If the entire expression is between double quotes, we want to treat the value as a double-quoted string, with the exception that we strip embedded unescaped double quotes (for sh backwards compatibility). */ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *value) { sindex = 0; temp = string_extract_double_quoted (value, &sindex, SX_STRIPDQ); } else temp = value; w = alloc_word_desc (); l_hasdollat = 0; /* XXX was 0 not quoted */ l = *temp ? expand_string_for_rhs (temp, quoted, &l_hasdollat, (int *)NULL) : (WORD_LIST *)0; if (hasdollarat) *hasdollarat = l_hasdollat || (l && l->next); if (temp != value) free (temp); if (l) { /* If l->next is not null, we know that TEMP contained "$@", since that is the only expansion that creates more than one word. */ if (qdollaratp && ((l_hasdollat && quoted) || l->next)) { /*itrace("parameter_brace_expand_rhs: %s:%s: l != NULL, set *qdollaratp", name, value);*/ *qdollaratp = 1; } /* The expansion of TEMP returned something. We need to treat things slightly differently if L_HASDOLLAT is non-zero. If we have "$@", the individual words have already been quoted. We need to turn them into a string with the words separated by the first character of $IFS without any additional quoting, so string_list_dollar_at won't do the right thing. If IFS is null, we want "$@" to split into separate arguments, not be concatenated, so we use string_list_internal and mark the word to be split on spaces later. We use string_list_dollar_star for "$@" otherwise. */ if (l->next && ifs_is_null) { temp = string_list_internal (l, " "); w->flags |= W_SPLITSPACE; } else temp = (l_hasdollat || l->next) ? string_list_dollar_star (l) : string_list (l); /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) (which is more paranoia than anything else), we need to return the quoted null string and set the flags to indicate it. */ if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL (temp) && QUOTED_NULL (l->word->word) && (l->word->flags & W_HASQUOTEDNULL)) { w->flags |= W_HASQUOTEDNULL; /*itrace("parameter_brace_expand_rhs (%s:%s): returning quoted null, turning off qdollaratp", name, value);*/ /* If we return a quoted null with L_HASDOLLARAT, we either have a construct like "${@-$@}" or "${@-${@-$@}}" with no positional parameters or a quoted expansion of "$@" with $1 == ''. In either case, we don't want to enable special handling of $@. */ if (qdollaratp && l_hasdollat) *qdollaratp = 0; } dispose_words (l); } else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && l_hasdollat) { /* Posix interp 221 changed the rules on this. The idea is that something like "$xxx$@" should expand the same as "${foo-$xxx$@}" when foo and xxx are unset. The problem is that it's not in any way backwards compatible and few other shells do it. We're eventually going to try and split the difference (heh) a little bit here. */ /* l_hasdollat == 1 means we saw a quoted dollar at. */ /* The brace expansion occurred between double quotes and there was a $@ in TEMP. It does not matter if the $@ is quoted, as long as it does not expand to anything. In this case, we want to return a quoted empty string. Posix interp 888 */ temp = make_quoted_char ('\0'); w->flags |= W_HASQUOTEDNULL; /*itrace("parameter_brace_expand_rhs (%s:%s): returning quoted null", name, value);*/ } else temp = (char *)NULL; if (c == '-' || c == '+') { w->word = temp; return w; } /* c == '=' */ t = temp ? savestring (temp) : savestring (""); t1 = dequote_string (t); free (t); /* bash-4.4/5.0 */ vname = name; if (*name == '!' && (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1]) || VALID_INDIR_PARAM (name[1]))) { vname = parameter_brace_find_indir (name + 1, SPECIAL_VAR (name, 1), quoted, 1); if (vname == 0 || *vname == 0) { report_error (_("%s: invalid indirect expansion"), name); free (vname); dispose_word (w); return &expand_wdesc_error; } if (legal_identifier (vname) == 0) { report_error (_("%s: invalid variable name"), vname); free (vname); dispose_word (w); return &expand_wdesc_error; } } #if defined (ARRAY_VARS) if (valid_array_reference (vname, 0)) assign_array_element (vname, t1, 0); else #endif /* ARRAY_VARS */ bind_variable (vname, t1, 0); stupidly_hack_special_variables (vname); if (vname != name) free (vname); /* From Posix group discussion Feb-March 2010. Issue 7 0000221 */ free (temp); w->word = t1; return w;
0
[ "CWE-20" ]
bash
4f747edc625815f449048579f6e65869914dd715
134,184,726,679,493,770,000,000,000,000,000,000,000
147
Bash-4.4 patch 7
rsvg_node_path_free (RsvgNode * self) { RsvgNodePath *path = (RsvgNodePath *) self; if (path->path) rsvg_cairo_path_destroy (path->path); _rsvg_node_finalize (&path->super); g_free (path); }
0
[ "CWE-20", "CWE-119" ]
librsvg
40af93e6eb1c94b90c3b9a0b87e0840e126bb8df
16,242,869,613,128,898,000,000,000,000,000,000,000
8
bgo#738050 - Handle the case where a list of coordinate pairs has an odd number of elements Lists of points come in coordinate pairs, but we didn't have any checking for that. It was possible to try to fetch the 'last' coordinate in a list, i.e. the y coordinate of an x,y pair, that was in fact missing, leading to an out-of-bounds array read. In that case, we now reuse the last-known y coordinate. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=738050 Signed-off-by: Federico Mena Quintero <[email protected]>
SupportsServer2Client(rfbClient* client, int messageType) { return (client->supportedMessages.server2client[((messageType & 0xFF)/8)] & (1<<(messageType % 8)) ? TRUE : FALSE); }
0
[ "CWE-20" ]
libvncserver
85a778c0e45e87e35ee7199f1f25020648e8b812
124,836,584,149,616,990,000,000,000,000,000,000,000
4
Check for MallocFrameBuffer() return value If MallocFrameBuffer() returns FALSE, frame buffer pointer is left to NULL. Subsequent writes into that buffer could lead to memory corruption, or even arbitrary code execution.
static int snd_msnd_write_cfg_io0(int cfg, int num, u16 io) { if (snd_msnd_write_cfg(cfg, IREG_LOGDEVICE, num)) return -EIO; if (snd_msnd_write_cfg(cfg, IREG_IO0_BASEHI, HIBYTE(io))) return -EIO; if (snd_msnd_write_cfg(cfg, IREG_IO0_BASELO, LOBYTE(io))) return -EIO; return 0; }
0
[ "CWE-125", "CWE-401" ]
linux
20e2b791796bd68816fa115f12be5320de2b8021
168,287,629,667,549,150,000,000,000,000,000,000,000
10
ALSA: msnd: Optimize / harden DSP and MIDI loops The ISA msnd drivers have loops fetching the ring-buffer head, tail and size values inside the loops. Such codes are inefficient and fragile. This patch optimizes it, and also adds the sanity check to avoid the endless loops. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196131 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196133 Signed-off-by: Takashi Iwai <[email protected]>
xmlRelaxNGComputeInterleaves(xmlRelaxNGDefinePtr def, xmlRelaxNGParserCtxtPtr ctxt, xmlChar * name ATTRIBUTE_UNUSED) { xmlRelaxNGDefinePtr cur, *tmp; xmlRelaxNGPartitionPtr partitions = NULL; xmlRelaxNGInterleaveGroupPtr *groups = NULL; xmlRelaxNGInterleaveGroupPtr group; int i, j, ret, res; int nbgroups = 0; int nbchild = 0; int is_mixed = 0; int is_determinist = 1; /* * Don't run that check in case of error. Infinite recursion * becomes possible. */ if (ctxt->nbErrors != 0) return; #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, "xmlRelaxNGComputeInterleaves(%s)\n", name); #endif cur = def->content; while (cur != NULL) { nbchild++; cur = cur->next; } #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, " %d child\n", nbchild); #endif groups = (xmlRelaxNGInterleaveGroupPtr *) xmlMalloc(nbchild * sizeof(xmlRelaxNGInterleaveGroupPtr)); if (groups == NULL) goto error; cur = def->content; while (cur != NULL) { groups[nbgroups] = (xmlRelaxNGInterleaveGroupPtr) xmlMalloc(sizeof(xmlRelaxNGInterleaveGroup)); if (groups[nbgroups] == NULL) goto error; if (cur->type == XML_RELAXNG_TEXT) is_mixed++; groups[nbgroups]->rule = cur; groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 0); groups[nbgroups]->attrs = xmlRelaxNGGetElements(ctxt, cur, 1); nbgroups++; cur = cur->next; } #ifdef DEBUG_INTERLEAVE xmlGenericError(xmlGenericErrorContext, " %d groups\n", nbgroups); #endif /* * Let's check that all rules makes a partitions according to 7.4 */ partitions = (xmlRelaxNGPartitionPtr) xmlMalloc(sizeof(xmlRelaxNGPartition)); if (partitions == NULL) goto error; memset(partitions, 0, sizeof(xmlRelaxNGPartition)); partitions->nbgroups = nbgroups; partitions->triage = xmlHashCreate(nbgroups); for (i = 0; i < nbgroups; i++) { group = groups[i]; for (j = i + 1; j < nbgroups; j++) { if (groups[j] == NULL) continue; ret = xmlRelaxNGCompareElemDefLists(ctxt, group->defs, groups[j]->defs); if (ret == 0) { xmlRngPErr(ctxt, def->node, XML_RNGP_ELEM_TEXT_CONFLICT, "Element or text conflicts in interleave\n", NULL, NULL); } ret = xmlRelaxNGCompareElemDefLists(ctxt, group->attrs, groups[j]->attrs); if (ret == 0) { xmlRngPErr(ctxt, def->node, XML_RNGP_ATTR_CONFLICT, "Attributes conflicts in interleave\n", NULL, NULL); } } tmp = group->defs; if ((tmp != NULL) && (*tmp != NULL)) { while (*tmp != NULL) { if ((*tmp)->type == XML_RELAXNG_TEXT) { res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#text", NULL, (void *) (long) (i + 1)); if (res != 0) is_determinist = -1; } else if (((*tmp)->type == XML_RELAXNG_ELEMENT) && ((*tmp)->name != NULL)) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(partitions->triage, (*tmp)->name, NULL, (void *) (long) (i + 1)); else res = xmlHashAddEntry2(partitions->triage, (*tmp)->name, (*tmp)->ns, (void *) (long) (i + 1)); if (res != 0) is_determinist = -1; } else if ((*tmp)->type == XML_RELAXNG_ELEMENT) { if (((*tmp)->ns == NULL) || ((*tmp)->ns[0] == 0)) res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#any", NULL, (void *) (long) (i + 1)); else res = xmlHashAddEntry2(partitions->triage, BAD_CAST "#any", (*tmp)->ns, (void *) (long) (i + 1)); if ((*tmp)->nameClass != NULL) is_determinist = 2; if (res != 0) is_determinist = -1; } else { is_determinist = -1; } tmp++; } } else { is_determinist = 0; } } partitions->groups = groups; /* * and save the partition list back in the def */ def->data = partitions; if (is_mixed != 0) def->dflags |= IS_MIXED; if (is_determinist == 1) partitions->flags = IS_DETERMINIST; if (is_determinist == 2) partitions->flags = IS_DETERMINIST | IS_NEEDCHECK; return; error: xmlRngPErrMemory(ctxt, "in interleave computation\n"); if (groups != NULL) { for (i = 0; i < nbgroups; i++) if (groups[i] != NULL) { if (groups[i]->defs != NULL) xmlFree(groups[i]->defs); xmlFree(groups[i]); } xmlFree(groups); } xmlRelaxNGFreePartition(partitions); }
0
[ "CWE-134" ]
libxml2
502f6a6d08b08c04b3ddfb1cd21b2f699c1b7f5b
77,996,619,218,654,530,000,000,000,000,000,000,000
158
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
f_gettagstack(typval_T *argvars, typval_T *rettv) { win_T *wp = curwin; // default is current window if (rettv_dict_alloc(rettv) != OK) return; if (argvars[0].v_type != VAR_UNKNOWN) { wp = find_win_by_nr_or_id(&argvars[0]); if (wp == NULL) return; } get_tagstack(wp, rettv->vval.v_dict); }
0
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
294,843,310,956,329,820,000,000,000,000,000,000,000
16
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
int SSL_get_wfd(const SSL *s) { int ret = -1; BIO *b, *r; b = SSL_get_wbio(s); r = BIO_find_type(b, BIO_TYPE_DESCRIPTOR); if (r != NULL) BIO_get_fd(r, &ret); return (ret); }
0
[ "CWE-310" ]
openssl
56f1acf5ef8a432992497a04792ff4b3b2c6f286
232,894,790,856,220,300,000,000,000,000,000,000,000
11
Disable SSLv2 default build, default negotiation and weak ciphers. SSLv2 is by default disabled at build-time. Builds that are not configured with "enable-ssl2" will not support SSLv2. Even if "enable-ssl2" is used, users who want to negotiate SSLv2 via the version-flexible SSLv23_method() will need to explicitly call either of: SSL_CTX_clear_options(ctx, SSL_OP_NO_SSLv2); or SSL_clear_options(ssl, SSL_OP_NO_SSLv2); as appropriate. Even if either of those is used, or the application explicitly uses the version-specific SSLv2_method() or its client or server variants, SSLv2 ciphers vulnerable to exhaustive search key recovery have been removed. Specifically, the SSLv2 40-bit EXPORT ciphers, and SSLv2 56-bit DES are no longer available. Mitigation for CVE-2016-0800 Reviewed-by: Emilia Käsper <[email protected]>
Bcj2_Decode(struct _7zip *zip, uint8_t *outBuf, size_t outSize) { size_t inPos = 0, outPos = 0; const uint8_t *buf0, *buf1, *buf2, *buf3; size_t size0, size1, size2, size3; const uint8_t *buffer, *bufferLim; unsigned int i, j; size0 = zip->tmp_stream_bytes_remaining; buf0 = zip->tmp_stream_buff + zip->tmp_stream_bytes_avail - size0; size1 = zip->sub_stream_bytes_remaining[0]; buf1 = zip->sub_stream_buff[0] + zip->sub_stream_size[0] - size1; size2 = zip->sub_stream_bytes_remaining[1]; buf2 = zip->sub_stream_buff[1] + zip->sub_stream_size[1] - size2; size3 = zip->sub_stream_bytes_remaining[2]; buf3 = zip->sub_stream_buff[2] + zip->sub_stream_size[2] - size3; buffer = buf3; bufferLim = buffer + size3; if (zip->bcj_state == 0) { /* * Initialize. */ zip->bcj2_prevByte = 0; for (i = 0; i < sizeof(zip->bcj2_p) / sizeof(zip->bcj2_p[0]); i++) zip->bcj2_p[i] = kBitModelTotal >> 1; RC_INIT2; zip->bcj_state = 1; } /* * Gather the odd bytes of a previous call. */ for (i = 0; zip->odd_bcj_size > 0 && outPos < outSize; i++) { outBuf[outPos++] = zip->odd_bcj[i]; zip->odd_bcj_size--; } if (outSize == 0) { zip->bcj2_outPos += outPos; return (outPos); } for (;;) { uint8_t b; CProb *prob; uint32_t bound; uint32_t ttt; size_t limit = size0 - inPos; if (outSize - outPos < limit) limit = outSize - outPos; if (zip->bcj_state == 1) { while (limit != 0) { uint8_t bb = buf0[inPos]; outBuf[outPos++] = bb; if (IsJ(zip->bcj2_prevByte, bb)) { zip->bcj_state = 2; break; } inPos++; zip->bcj2_prevByte = bb; limit--; } } if (limit == 0 || outPos == outSize) break; zip->bcj_state = 1; b = buf0[inPos++]; if (b == 0xE8) prob = zip->bcj2_p + zip->bcj2_prevByte; else if (b == 0xE9) prob = zip->bcj2_p + 256; else prob = zip->bcj2_p + 257; IF_BIT_0(prob) { UPDATE_0(prob) zip->bcj2_prevByte = b; } else { uint32_t dest; const uint8_t *v; uint8_t out[4]; UPDATE_1(prob) if (b == 0xE8) { v = buf1; if (size1 < 4) return SZ_ERROR_DATA; buf1 += 4; size1 -= 4; } else { v = buf2; if (size2 < 4) return SZ_ERROR_DATA; buf2 += 4; size2 -= 4; } dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)zip->bcj2_outPos + (uint32_t)outPos + 4); out[0] = (uint8_t)dest; out[1] = (uint8_t)(dest >> 8); out[2] = (uint8_t)(dest >> 16); out[3] = zip->bcj2_prevByte = (uint8_t)(dest >> 24); for (i = 0; i < 4 && outPos < outSize; i++) outBuf[outPos++] = out[i]; if (i < 4) { /* * Save odd bytes which we could not add into * the output buffer because of out of space. */ zip->odd_bcj_size = 4 -i; for (; i < 4; i++) { j = i - 4 + (unsigned)zip->odd_bcj_size; zip->odd_bcj[j] = out[i]; } break; } } } zip->tmp_stream_bytes_remaining -= inPos; zip->sub_stream_bytes_remaining[0] = size1; zip->sub_stream_bytes_remaining[1] = size2; zip->sub_stream_bytes_remaining[2] = bufferLim - buffer; zip->bcj2_outPos += outPos; return ((ssize_t)outPos); }
0
[ "CWE-190", "CWE-125" ]
libarchive
e79ef306afe332faf22e9b442a2c6b59cb175573
246,326,971,032,270,500,000,000,000,000,000,000,000
138
Issue #718: Fix TALOS-CAN-152 If a 7-Zip archive declares a rediculously large number of substreams, it can overflow an internal counter, leading a subsequent memory allocation to be too small for the substream data. Thanks to the Open Source and Threat Intelligence project at Cisco for reporting this issue.
filter_data_internal(struct filter_session *fs, uint64_t token, uint64_t reqid, const char *line) { struct filter_chain *filter_chain; struct filter_entry *filter_entry; struct filter *filter; if (!token) fs->phase = FILTER_DATA_LINE; if (fs->phase != FILTER_DATA_LINE) fatalx("misbehaving filter"); /* based on token, identify the filter_entry we should apply */ filter_chain = dict_get(&filter_chains, fs->filter_name); filter_entry = TAILQ_FIRST(&filter_chain->chain[fs->phase]); if (token) { TAILQ_FOREACH(filter_entry, &filter_chain->chain[fs->phase], entries) if (filter_entry->id == token) break; if (filter_entry == NULL) fatalx("misbehaving filter"); filter_entry = TAILQ_NEXT(filter_entry, entries); } /* no filter_entry, we either had none or reached end of chain */ if (filter_entry == NULL) { io_printf(fs->io, "%s\n", line); return; } /* pass data to the filter */ filter = dict_get(&filters, filter_entry->name); filter_data_query(filter, filter_entry->id, reqid, line); }
0
[ "CWE-476" ]
src
6c3220444ed06b5796dedfd53a0f4becd903c0d1
263,812,017,969,014,870,000,000,000,000,000,000,000
33
smtpd's filter state machine can prematurely release resources leading to a crash. From gilles@
CDCCBounce::~CDCCBounce() { if (m_pPeer) { m_pPeer->Shutdown(); m_pPeer = NULL; } }
0
[ "CWE-399" ]
znc
11508aa72efab4fad0dbd8292b9614d9371b20a9
145,151,904,058,627,460,000,000,000,000,000,000,000
6
Fix crash in bouncedcc module. It happens when DCC RESUME is received. Affected ZNC versions: 0.200, 0.202. Thanks to howeyc for reporting this and providing the patch.
TEST(HttpStatusChecker, ExpectedRanges_204_304) { const std::string yaml = R"EOF( timeout: 1s interval: 1s unhealthy_threshold: 2 healthy_threshold: 2 http_health_check: service_name_matcher: prefix: locations path: /healthcheck expected_statuses: - start: 204 end: 205 - start: 304 end: 305 )EOF"; auto conf = parseHealthCheckFromV3Yaml(yaml); HttpHealthCheckerImpl::HttpStatusChecker http_status_checker( conf.http_health_check().expected_statuses(), conf.http_health_check().retriable_statuses(), 200); EXPECT_FALSE(http_status_checker.inExpectedRanges(200)); EXPECT_FALSE(http_status_checker.inExpectedRanges(203)); EXPECT_TRUE(http_status_checker.inExpectedRanges(204)); EXPECT_FALSE(http_status_checker.inExpectedRanges(205)); EXPECT_FALSE(http_status_checker.inExpectedRanges(303)); EXPECT_TRUE(http_status_checker.inExpectedRanges(304)); EXPECT_FALSE(http_status_checker.inExpectedRanges(305)); }
0
[ "CWE-476" ]
envoy
9b1c3962172a972bc0359398af6daa3790bb59db
118,107,288,818,957,030,000,000,000,000,000,000,000
31
healthcheck: fix grpc inline removal crashes (#749) Signed-off-by: Matt Klein <[email protected]> Signed-off-by: Pradeep Rao <[email protected]>
static void rbd_queue_workfn(struct work_struct *work) { struct rbd_img_request *img_request = container_of(work, struct rbd_img_request, work); struct rbd_device *rbd_dev = img_request->rbd_dev; enum obj_operation_type op_type = img_request->op_type; struct request *rq = blk_mq_rq_from_pdu(img_request); u64 offset = (u64)blk_rq_pos(rq) << SECTOR_SHIFT; u64 length = blk_rq_bytes(rq); u64 mapping_size; int result; /* Ignore/skip any zero-length requests */ if (!length) { dout("%s: zero-length request\n", __func__); result = 0; goto err_img_request; } blk_mq_start_request(rq); down_read(&rbd_dev->header_rwsem); mapping_size = rbd_dev->mapping.size; rbd_img_capture_header(img_request); up_read(&rbd_dev->header_rwsem); if (offset + length > mapping_size) { rbd_warn(rbd_dev, "beyond EOD (%llu~%llu > %llu)", offset, length, mapping_size); result = -EIO; goto err_img_request; } dout("%s rbd_dev %p img_req %p %s %llu~%llu\n", __func__, rbd_dev, img_request, obj_op_name(op_type), offset, length); if (op_type == OBJ_OP_DISCARD || op_type == OBJ_OP_ZEROOUT) result = rbd_img_fill_nodata(img_request, offset, length); else result = rbd_img_fill_from_bio(img_request, offset, length, rq->bio); if (result) goto err_img_request; rbd_img_handle_request(img_request, 0); return; err_img_request: rbd_img_request_destroy(img_request); if (result) rbd_warn(rbd_dev, "%s %llx at %llx result %d", obj_op_name(op_type), length, offset, result); blk_mq_end_request(rq, errno_to_blk_status(result)); }
0
[ "CWE-863" ]
linux
f44d04e696feaf13d192d942c4f14ad2e117065a
218,703,085,823,225,320,000,000,000,000,000,000,000
54
rbd: require global CAP_SYS_ADMIN for mapping and unmapping It turns out that currently we rely only on sysfs attribute permissions: $ ll /sys/bus/rbd/{add*,remove*} --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/add --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/add_single_major --w------- 1 root root 4096 Sep 3 20:37 /sys/bus/rbd/remove --w------- 1 root root 4096 Sep 3 20:38 /sys/bus/rbd/remove_single_major This means that images can be mapped and unmapped (i.e. block devices can be created and deleted) by a UID 0 process even after it drops all privileges or by any process with CAP_DAC_OVERRIDE in its user namespace as long as UID 0 is mapped into that user namespace. Be consistent with other virtual block devices (loop, nbd, dm, md, etc) and require CAP_SYS_ADMIN in the initial user namespace for mapping and unmapping, and also for dumping the configuration string and refreshing the image header. Cc: [email protected] Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
internal_format( int textwidth, int second_indent, int flags, int format_only, int c) // character to be inserted (can be NUL) { int cc; int save_char = NUL; int haveto_redraw = FALSE; int fo_ins_blank = has_format_option(FO_INS_BLANK); int fo_multibyte = has_format_option(FO_MBYTE_BREAK); int fo_white_par = has_format_option(FO_WHITE_PAR); int first_line = TRUE; colnr_T leader_len; int no_leader = FALSE; int do_comments = (flags & INSCHAR_DO_COM); #ifdef FEAT_LINEBREAK int has_lbr = curwin->w_p_lbr; // make sure win_lbr_chartabsize() counts correctly curwin->w_p_lbr = FALSE; #endif /* * When 'ai' is off we don't want a space under the cursor to be * deleted. Replace it with an 'x' temporarily. */ if (!curbuf->b_p_ai && !(State & VREPLACE_FLAG)) { cc = gchar_cursor(); if (VIM_ISWHITE(cc)) { save_char = cc; pchar_cursor('x'); } } /* * Repeat breaking lines, until the current line is not too long. */ while (!got_int) { int startcol; // Cursor column at entry int wantcol; // column at textwidth border int foundcol; // column for start of spaces int end_foundcol = 0; // column for start of word colnr_T len; colnr_T virtcol; int orig_col = 0; char_u *saved_text = NULL; colnr_T col; colnr_T end_col; int wcc; // counter for whitespace chars virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); if (virtcol <= (colnr_T)textwidth) break; if (no_leader) do_comments = FALSE; else if (!(flags & INSCHAR_FORMAT) && has_format_option(FO_WRAP_COMS)) do_comments = TRUE; // Don't break until after the comment leader if (do_comments) leader_len = get_leader_len(ml_get_curline(), NULL, FALSE, TRUE); else leader_len = 0; // If the line doesn't start with a comment leader, then don't // start one in a following broken line. Avoids that a %word // moved to the start of the next line causes all following lines // to start with %. if (leader_len == 0) no_leader = TRUE; if (!(flags & INSCHAR_FORMAT) && leader_len == 0 && !has_format_option(FO_WRAP)) break; if ((startcol = curwin->w_cursor.col) == 0) break; // find column of textwidth border coladvance((colnr_T)textwidth); wantcol = curwin->w_cursor.col; curwin->w_cursor.col = startcol; foundcol = 0; /* * Find position to break at. * Stop at first entered white when 'formatoptions' has 'v' */ while ((!fo_ins_blank && !has_format_option(FO_INS_VI)) || (flags & INSCHAR_FORMAT) || curwin->w_cursor.lnum != Insstart.lnum || curwin->w_cursor.col >= Insstart.col) { if (curwin->w_cursor.col == startcol && c != NUL) cc = c; else cc = gchar_cursor(); if (WHITECHAR(cc)) { // remember position of blank just before text end_col = curwin->w_cursor.col; // find start of sequence of blanks wcc = 0; while (curwin->w_cursor.col > 0 && WHITECHAR(cc)) { dec_cursor(); cc = gchar_cursor(); // Increment count of how many whitespace chars in this // group; we only need to know if it's more than one. if (wcc < 2) wcc++; } if (curwin->w_cursor.col == 0 && WHITECHAR(cc)) break; // only spaces in front of text // Don't break after a period when 'formatoptions' has 'p' and // there are less than two spaces. if (has_format_option(FO_PERIOD_ABBR) && cc == '.' && wcc < 2) continue; // Don't break until after the comment leader if (curwin->w_cursor.col < leader_len) break; if (has_format_option(FO_ONE_LETTER)) { // do not break after one-letter words if (curwin->w_cursor.col == 0) break; // one-letter word at begin // do not break "#a b" when 'tw' is 2 if (curwin->w_cursor.col <= leader_len) break; col = curwin->w_cursor.col; dec_cursor(); cc = gchar_cursor(); if (WHITECHAR(cc)) continue; // one-letter, continue curwin->w_cursor.col = col; } inc_cursor(); end_foundcol = end_col + 1; foundcol = curwin->w_cursor.col; if (curwin->w_cursor.col <= (colnr_T)wantcol) break; } else if (cc >= 0x100 && fo_multibyte) { // Break after or before a multi-byte character. if (curwin->w_cursor.col != startcol) { // Don't break until after the comment leader if (curwin->w_cursor.col < leader_len) break; col = curwin->w_cursor.col; inc_cursor(); // Don't change end_foundcol if already set. if (foundcol != curwin->w_cursor.col) { foundcol = curwin->w_cursor.col; end_foundcol = foundcol; if (curwin->w_cursor.col <= (colnr_T)wantcol) break; } curwin->w_cursor.col = col; } if (curwin->w_cursor.col == 0) break; col = curwin->w_cursor.col; dec_cursor(); cc = gchar_cursor(); if (WHITECHAR(cc)) continue; // break with space // Don't break until after the comment leader if (curwin->w_cursor.col < leader_len) break; curwin->w_cursor.col = col; foundcol = curwin->w_cursor.col; end_foundcol = foundcol; if (curwin->w_cursor.col <= (colnr_T)wantcol) break; } if (curwin->w_cursor.col == 0) break; dec_cursor(); } if (foundcol == 0) // no spaces, cannot break line { curwin->w_cursor.col = startcol; break; } // Going to break the line, remove any "$" now. undisplay_dollar(); /* * Offset between cursor position and line break is used by replace * stack functions. VREPLACE does not use this, and backspaces * over the text instead. */ if (State & VREPLACE_FLAG) orig_col = startcol; // Will start backspacing from here else replace_offset = startcol - end_foundcol; /* * adjust startcol for spaces that will be deleted and * characters that will remain on top line */ curwin->w_cursor.col = foundcol; while ((cc = gchar_cursor(), WHITECHAR(cc)) && (!fo_white_par || curwin->w_cursor.col < startcol)) inc_cursor(); startcol -= curwin->w_cursor.col; if (startcol < 0) startcol = 0; if (State & VREPLACE_FLAG) { /* * In VREPLACE mode, we will backspace over the text to be * wrapped, so save a copy now to put on the next line. */ saved_text = vim_strsave(ml_get_cursor()); curwin->w_cursor.col = orig_col; if (saved_text == NULL) break; // Can't do it, out of memory saved_text[startcol] = NUL; // Backspace over characters that will move to the next line if (!fo_white_par) backspace_until_column(foundcol); } else { // put cursor after pos. to break line if (!fo_white_par) curwin->w_cursor.col = foundcol; } /* * Split the line just before the margin. * Only insert/delete lines, but don't really redraw the window. */ open_line(FORWARD, OPENLINE_DELSPACES + OPENLINE_MARKFIX + (fo_white_par ? OPENLINE_KEEPTRAIL : 0) + (do_comments ? OPENLINE_DO_COM : 0) + ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0) , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent)); if (!(flags & INSCHAR_COM_LIST)) old_indent = 0; replace_offset = 0; if (first_line) { if (!(flags & INSCHAR_COM_LIST)) { /* * This section is for auto-wrap of numeric lists. When not * in insert mode (i.e. format_lines()), the INSCHAR_COM_LIST * flag will be set and open_line() will handle it (as seen * above). The code here (and in get_number_indent()) will * recognize comments if needed... */ if (second_indent < 0 && has_format_option(FO_Q_NUMBER)) second_indent = get_number_indent(curwin->w_cursor.lnum - 1); if (second_indent >= 0) { if (State & VREPLACE_FLAG) change_indent(INDENT_SET, second_indent, FALSE, NUL, TRUE); else if (leader_len > 0 && second_indent - leader_len > 0) { int i; int padding = second_indent - leader_len; // We started at the first_line of a numbered list // that has a comment. the open_line() function has // inserted the proper comment leader and positioned // the cursor at the end of the split line. Now we // add the additional whitespace needed after the // comment leader for the numbered list. for (i = 0; i < padding; i++) ins_str((char_u *)" "); } else { (void)set_indent(second_indent, SIN_CHANGED); } } } first_line = FALSE; } if (State & VREPLACE_FLAG) { /* * In VREPLACE mode we have backspaced over the text to be * moved, now we re-insert it into the new line. */ ins_bytes(saved_text); vim_free(saved_text); } else { /* * Check if cursor is not past the NUL off the line, cindent * may have added or removed indent. */ curwin->w_cursor.col += startcol; len = (colnr_T)STRLEN(ml_get_curline()); if (curwin->w_cursor.col > len) curwin->w_cursor.col = len; } haveto_redraw = TRUE; #ifdef FEAT_CINDENT can_cindent = TRUE; #endif // moved the cursor, don't autoindent or cindent now did_ai = FALSE; #ifdef FEAT_SMARTINDENT did_si = FALSE; can_si = FALSE; can_si_back = FALSE; #endif line_breakcheck(); } if (save_char != NUL) // put back space after cursor pchar_cursor(save_char); #ifdef FEAT_LINEBREAK curwin->w_p_lbr = has_lbr; #endif if (!format_only && haveto_redraw) { update_topline(); redraw_curbuf_later(VALID); } }
0
[]
vim
98a336dd497d3422e7efeef9f24cc9e25aeb8a49
177,879,941,465,865,170,000,000,000,000,000,000,000
362
patch 8.2.0133: invalid memory access with search command Problem: Invalid memory access with search command. Solution: When :normal runs out of characters in bracketed paste mode break out of the loop.(closes #5511)
**/ CImg<T>& histogram(const unsigned int nb_levels, const T& min_value, const T& max_value) { return get_histogram(nb_levels,min_value,max_value).move_to(*this);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
126,455,314,518,990,240,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
void write(bool value) { const char *str_value = value ? "true" : "false"; Arg::StringValue<char> str = { str_value, std::strlen(str_value) }; writer_.write_str(str, spec_); }
0
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
133,322,658,425,893,760,000,000,000,000,000,000,000
5
Fix segfault on complex pointer formatting (#642)
static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, int type, u32 pid, u32 seq, u32 change, unsigned int flags) { struct ifinfomsg *r; struct nlmsghdr *nlh; unsigned char *b = skb->tail; nlh = NLMSG_NEW(skb, pid, seq, type, sizeof(*r), flags); r = NLMSG_DATA(nlh); r->ifi_family = AF_UNSPEC; r->__ifi_pad = 0; r->ifi_type = dev->type; r->ifi_index = dev->ifindex; r->ifi_flags = dev_get_flags(dev); r->ifi_change = change; RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name); if (1) { u32 txqlen = dev->tx_queue_len; RTA_PUT(skb, IFLA_TXQLEN, sizeof(txqlen), &txqlen); } if (1) { u32 weight = dev->weight; RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight); } if (1) { struct rtnl_link_ifmap map = { .mem_start = dev->mem_start, .mem_end = dev->mem_end, .base_addr = dev->base_addr, .irq = dev->irq, .dma = dev->dma, .port = dev->if_port, }; RTA_PUT(skb, IFLA_MAP, sizeof(map), &map); } if (dev->addr_len) { RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr); RTA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast); } if (1) { u32 mtu = dev->mtu; RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu); } if (dev->ifindex != dev->iflink) { u32 iflink = dev->iflink; RTA_PUT(skb, IFLA_LINK, sizeof(iflink), &iflink); } if (dev->qdisc_sleeping) RTA_PUT(skb, IFLA_QDISC, strlen(dev->qdisc_sleeping->ops->id) + 1, dev->qdisc_sleeping->ops->id); if (dev->master) { u32 master = dev->master->ifindex; RTA_PUT(skb, IFLA_MASTER, sizeof(master), &master); } if (dev->get_stats) { unsigned long *stats = (unsigned long*)dev->get_stats(dev); if (stats) { struct rtattr *a; __u32 *s; int i; int n = sizeof(struct rtnl_link_stats)/4; a = __RTA_PUT(skb, IFLA_STATS, n*4); s = RTA_DATA(a); for (i=0; i<n; i++) s[i] = stats[i]; } } nlh->nlmsg_len = skb->tail - b; return skb->len; nlmsg_failure: rtattr_failure: skb_trim(skb, b - skb->data); return -1; }
0
[ "CWE-200" ]
linux-2.6
9ef1d4c7c7aca1cd436612b6ca785b726ffb8ed8
76,898,825,001,424,210,000,000,000,000,000,000,000
88
[NETLINK]: Missing initializations in dumped data Mostly missing initialization of padding fields of 1 or 2 bytes length, two instances of uninitialized nlmsgerr->msg of 16 bytes length. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
*/ void netdev_upper_dev_unlink(struct net_device *dev, struct net_device *upper_dev) { struct netdev_adjacent *i, *j; ASSERT_RTNL(); __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); /* Here is the tricky part. We must remove all dev's lower * devices from all upper_dev's upper devices and vice * versa, to maintain the graph relationship. */ list_for_each_entry(i, &dev->all_adj_list.lower, list) list_for_each_entry(j, &upper_dev->all_adj_list.upper, list) __netdev_adjacent_dev_unlink(i->dev, j->dev); /* remove also the devices itself from lower/upper device * list */ list_for_each_entry(i, &dev->all_adj_list.lower, list) __netdev_adjacent_dev_unlink(i->dev, upper_dev); list_for_each_entry(i, &upper_dev->all_adj_list.upper, list) __netdev_adjacent_dev_unlink(dev, i->dev); call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev);
0
[]
linux
7bced397510ab569d31de4c70b39e13355046387
132,559,626,469,409,760,000,000,000,000,000,000,000
27
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]>
static void mark_reg_not_init(struct bpf_verifier_env *env, struct bpf_reg_state *regs, u32 regno) { if (WARN_ON(regno >= MAX_BPF_REG)) { verbose(env, "mark_reg_not_init(regs, %u)\n", regno); /* Something bad happened, let's kill all regs except FP */ for (regno = 0; regno < BPF_REG_FP; regno++) __mark_reg_not_init(regs + regno); return; } __mark_reg_not_init(regs + regno); }
0
[ "CWE-125" ]
linux
b799207e1e1816b09e7a5920fbb2d5fcf6edd681
265,345,743,841,757,170,000,000,000,000,000,000,000
12
bpf: 32-bit RSH verification must truncate input before the ALU op When I wrote commit 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification"), I assumed that, in order to emulate 64-bit arithmetic with 32-bit logic, it is sufficient to just truncate the output to 32 bits; and so I just moved the register size coercion that used to be at the start of the function to the end of the function. That assumption is true for almost every op, but not for 32-bit right shifts, because those can propagate information towards the least significant bit. Fix it by always truncating inputs for 32-bit ops to 32 bits. Also get rid of the coerce_reg_to_size() after the ALU op, since that has no effect. Fixes: 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification") Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
encode_fh(__be32 *p, struct svc_fh *fhp) { unsigned int size = fhp->fh_handle.fh_size; *p++ = htonl(size); if (size) p[XDR_QUADLEN(size)-1]=0; memcpy(p, &fhp->fh_handle.fh_base, size); return p + XDR_QUADLEN(size); }
0
[ "CWE-119", "CWE-703" ]
linux
13bf9fbff0e5e099e2b6f003a0ab8ae145436309
46,086,312,843,279,960,000,000,000,000,000,000,000
8
nfsd: stricter decoding of write-like NFSv2/v3 ops The NFSv2/v3 code does not systematically check whether we decode past the end of the buffer. This generally appears to be harmless, but there are a few places where we do arithmetic on the pointers involved and don't account for the possibility that a length could be negative. Add checks to catch these. Reported-by: Tuomas Haanpää <[email protected]> Reported-by: Ari Kauppi <[email protected]> Reviewed-by: NeilBrown <[email protected]> Cc: [email protected] Signed-off-by: J. Bruce Fields <[email protected]>
void FullyConnectedInt8(const OpData* data, const TfLiteTensor* input, const TfLiteTensor* filter, const TfLiteTensor* bias, TfLiteTensor* output, CpuBackendContext* cpu_backend_context) { FullyConnectedParams op_params; op_params.input_offset = -input->params.zero_point; op_params.weights_offset = -filter->params.zero_point; op_params.output_offset = output->params.zero_point; op_params.output_multiplier = data->output_multiplier; op_params.output_shift = data->output_shift; op_params.quantized_activation_min = data->output_activation_min; op_params.quantized_activation_max = data->output_activation_max; op_params.lhs_cacheable = IsConstantTensor(filter); op_params.rhs_cacheable = IsConstantTensor(input); if (kernel_type == kReference) { reference_integer_ops::FullyConnected( op_params, GetTensorShape(input), GetTensorData<int8_t>(input), GetTensorShape(filter), GetTensorData<int8_t>(filter), GetTensorShape(bias), GetTensorData<int32_t>(bias), GetTensorShape(output), GetTensorData<int8_t>(output)); } else { optimized_integer_ops::FullyConnected( op_params, GetTensorShape(input), GetTensorData<int8_t>(input), GetTensorShape(filter), GetTensorData<int8_t>(filter), GetTensorShape(bias), GetTensorData<int32_t>(bias), GetTensorShape(output), GetTensorData<int8_t>(output), cpu_backend_context); } }
0
[ "CWE-369" ]
tensorflow
718721986aa137691ee23f03638867151f74935f
268,830,527,183,794,170,000,000,000,000,000,000,000
29
Prevent division by 0 in `fully_connected.cc` PiperOrigin-RevId: 385137282 Change-Id: If201e69b6e0048f0be001330b4b977e2b46db2cb
st_select_lex::build_pushable_cond_for_having_pushdown(THD *thd, Item *cond) { List<Item> equalities; /* Condition can't be pushed */ if (cond->get_extraction_flag() == NO_EXTRACTION_FL) return false; /** Condition can be pushed entirely. Transform its multiple equalities and add to attach_to_conds list. */ if (cond->get_extraction_flag() == FULL_EXTRACTION_FL) { Item *result= cond->transform(thd, &Item::multiple_equality_transformer, (uchar *)this); if (!result) return true; if (result->type() == Item::COND_ITEM && ((Item_cond*) result)->functype() == Item_func::COND_AND_FUNC) { List_iterator<Item> li(*((Item_cond*) result)->argument_list()); Item *item; while ((item= li++)) { if (attach_to_conds.push_back(item, thd->mem_root)) return true; } } else { if (attach_to_conds.push_back(result, thd->mem_root)) return true; } return false; } /** There is no flag set for this condition. It means that some part of this condition can be pushed. */ if (cond->type() != Item::COND_ITEM) return false; if (((Item_cond *)cond)->functype() != Item_cond::COND_AND_FUNC) { /* cond is not a conjunctive formula and it cannot be pushed into WHERE. Try to extract a formula that can be pushed. */ Item *fix= cond->build_pushable_cond(thd, 0, 0); if (!fix) return false; if (attach_to_conds.push_back(fix, thd->mem_root)) return true; } else { List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { if (item->get_extraction_flag() == NO_EXTRACTION_FL) continue; else if (item->get_extraction_flag() == FULL_EXTRACTION_FL) { Item *result= item->transform(thd, &Item::multiple_equality_transformer, (uchar *)item); if (!result) return true; if (result->type() == Item::COND_ITEM && ((Item_cond*) result)->functype() == Item_func::COND_AND_FUNC) { List_iterator<Item> li(*((Item_cond*) result)->argument_list()); Item *item; while ((item=li++)) { if (attach_to_conds.push_back(item, thd->mem_root)) return true; } } else { if (attach_to_conds.push_back(result, thd->mem_root)) return true; } } else { Item *fix= item->build_pushable_cond(thd, 0, 0); if (!fix) continue; if (attach_to_conds.push_back(fix, thd->mem_root)) return true; } } } return false; }
0
[ "CWE-703" ]
server
39feab3cd31b5414aa9b428eaba915c251ac34a2
153,522,529,134,576,430,000,000,000,000,000,000,000
101
MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT IF an INSERT/REPLACE SELECT statement contained an ON expression in the top level select and this expression used a subquery with a column reference that could not be resolved then an attempt to resolve this reference as an outer reference caused a crash of the server. This happened because the outer context field in the Name_resolution_context structure was not set to NULL for such references. Rather it pointed to the first element in the select_stack. Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select() method when parsing a SELECT construct. Approved by Oleksandr Byelkin <[email protected]>
static int ceph_x_should_authenticate(struct ceph_auth_client *ac) { struct ceph_x_info *xi = ac->private; int need; ceph_x_validate_tickets(ac, &need); dout("ceph_x_should_authenticate want=%d need=%d have=%d\n", ac->want_keys, need, xi->have_keys); return need != 0; }
0
[ "CWE-399", "CWE-119" ]
linux
c27a3e4d667fdcad3db7b104f75659478e0c68d8
194,102,474,297,710,330,000,000,000,000,000,000,000
10
libceph: do not hard code max auth ticket len We hard code cephx auth ticket buffer size to 256 bytes. This isn't enough for any moderate setups and, in case tickets themselves are not encrypted, leads to buffer overflows (ceph_x_decrypt() errors out, but ceph_decode_copy() doesn't - it's just a memcpy() wrapper). Since the buffer is allocated dynamically anyway, allocated it a bit later, at the point where we know how much is going to be needed. Fixes: http://tracker.ceph.com/issues/8979 Cc: [email protected] Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Sage Weil <[email protected]>
static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c) { struct net *net = xs_net(x); struct xfrm_usersa_info *p; struct xfrm_usersa_id *id; struct nlmsghdr *nlh; struct sk_buff *skb; unsigned int len = xfrm_sa_len(x); unsigned int headlen; int err; headlen = sizeof(*p); if (c->event == XFRM_MSG_DELSA) { len += nla_total_size(headlen); headlen = sizeof(*id); len += nla_total_size(sizeof(struct xfrm_mark)); } len += NLMSG_ALIGN(headlen); skb = nlmsg_new(len, GFP_ATOMIC); if (skb == NULL) return -ENOMEM; nlh = nlmsg_put(skb, c->portid, c->seq, c->event, headlen, 0); err = -EMSGSIZE; if (nlh == NULL) goto out_free_skb; p = nlmsg_data(nlh); if (c->event == XFRM_MSG_DELSA) { struct nlattr *attr; id = nlmsg_data(nlh); memset(id, 0, sizeof(*id)); memcpy(&id->daddr, &x->id.daddr, sizeof(id->daddr)); id->spi = x->id.spi; id->family = x->props.family; id->proto = x->id.proto; attr = nla_reserve(skb, XFRMA_SA, sizeof(*p)); err = -EMSGSIZE; if (attr == NULL) goto out_free_skb; p = nla_data(attr); } err = copy_to_user_state_extra(x, p, skb); if (err) goto out_free_skb; nlmsg_end(skb, nlh); return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_SA); out_free_skb: kfree_skb(skb); return err; }
0
[ "CWE-125" ]
linux
b805d78d300bcf2c83d6df7da0c818b0fee41427
284,836,879,061,359,750,000,000,000,000,000,000,000
58
xfrm: policy: Fix out-of-bound array accesses in __xfrm_policy_unlink UBSAN report this: UBSAN: Undefined behaviour in net/xfrm/xfrm_policy.c:1289:24 index 6 is out of range for type 'unsigned int [6]' CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.4.162-514.55.6.9.x86_64+ #13 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 0000000000000000 1466cf39b41b23c9 ffff8801f6b07a58 ffffffff81cb35f4 0000000041b58ab3 ffffffff83230f9c ffffffff81cb34e0 ffff8801f6b07a80 ffff8801f6b07a20 1466cf39b41b23c9 ffffffff851706e0 ffff8801f6b07ae8 Call Trace: <IRQ> [<ffffffff81cb35f4>] __dump_stack lib/dump_stack.c:15 [inline] <IRQ> [<ffffffff81cb35f4>] dump_stack+0x114/0x1a0 lib/dump_stack.c:51 [<ffffffff81d94225>] ubsan_epilogue+0x12/0x8f lib/ubsan.c:164 [<ffffffff81d954db>] __ubsan_handle_out_of_bounds+0x16e/0x1b2 lib/ubsan.c:382 [<ffffffff82a25acd>] __xfrm_policy_unlink+0x3dd/0x5b0 net/xfrm/xfrm_policy.c:1289 [<ffffffff82a2e572>] xfrm_policy_delete+0x52/0xb0 net/xfrm/xfrm_policy.c:1309 [<ffffffff82a3319b>] xfrm_policy_timer+0x30b/0x590 net/xfrm/xfrm_policy.c:243 [<ffffffff813d3927>] call_timer_fn+0x237/0x990 kernel/time/timer.c:1144 [<ffffffff813d8e7e>] __run_timers kernel/time/timer.c:1218 [inline] [<ffffffff813d8e7e>] run_timer_softirq+0x6ce/0xb80 kernel/time/timer.c:1401 [<ffffffff8120d6f9>] __do_softirq+0x299/0xe10 kernel/softirq.c:273 [<ffffffff8120e676>] invoke_softirq kernel/softirq.c:350 [inline] [<ffffffff8120e676>] irq_exit+0x216/0x2c0 kernel/softirq.c:391 [<ffffffff82c5edab>] exiting_irq arch/x86/include/asm/apic.h:652 [inline] [<ffffffff82c5edab>] smp_apic_timer_interrupt+0x8b/0xc0 arch/x86/kernel/apic/apic.c:926 [<ffffffff82c5c985>] apic_timer_interrupt+0xa5/0xb0 arch/x86/entry/entry_64.S:735 <EOI> [<ffffffff81188096>] ? native_safe_halt+0x6/0x10 arch/x86/include/asm/irqflags.h:52 [<ffffffff810834d7>] arch_safe_halt arch/x86/include/asm/paravirt.h:111 [inline] [<ffffffff810834d7>] default_idle+0x27/0x430 arch/x86/kernel/process.c:446 [<ffffffff81085f05>] arch_cpu_idle+0x15/0x20 arch/x86/kernel/process.c:437 [<ffffffff8132abc3>] default_idle_call+0x53/0x90 kernel/sched/idle.c:92 [<ffffffff8132b32d>] cpuidle_idle_call kernel/sched/idle.c:156 [inline] [<ffffffff8132b32d>] cpu_idle_loop kernel/sched/idle.c:251 [inline] [<ffffffff8132b32d>] cpu_startup_entry+0x60d/0x9a0 kernel/sched/idle.c:299 [<ffffffff8113e119>] start_secondary+0x3c9/0x560 arch/x86/kernel/smpboot.c:245 The issue is triggered as this: xfrm_add_policy -->verify_newpolicy_info //check the index provided by user with XFRM_POLICY_MAX //In my case, the index is 0x6E6BB6, so it pass the check. -->xfrm_policy_construct //copy the user's policy and set xfrm_policy_timer -->xfrm_policy_insert --> __xfrm_policy_link //use the orgin dir, in my case is 2 --> xfrm_gen_index //generate policy index, there is 0x6E6BB6 then xfrm_policy_timer be fired xfrm_policy_timer --> xfrm_policy_id2dir //get dir from (policy index & 7), in my case is 6 --> xfrm_policy_delete --> __xfrm_policy_unlink //access policy_count[dir], trigger out of range access Add xfrm_policy_id2dir check in verify_newpolicy_info, make sure the computed dir is valid, to fix the issue. Reported-by: Hulk Robot <[email protected]> Fixes: e682adf021be ("xfrm: Try to honor policy index if it's supplied by user") Signed-off-by: YueHaibing <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
static void megasas_setup_reply_map(struct megasas_instance *instance) { const struct cpumask *mask; unsigned int queue, cpu; for (queue = 0; queue < instance->msix_vectors; queue++) { mask = pci_irq_get_affinity(instance->pdev, queue); if (!mask) goto fallback; for_each_cpu(cpu, mask) instance->reply_map[cpu] = queue; } return; fallback: for_each_possible_cpu(cpu) instance->reply_map[cpu] = cpu % instance->msix_vectors; }
0
[ "CWE-476" ]
linux
bcf3b67d16a4c8ffae0aa79de5853435e683945c
108,963,655,921,073,600,000,000,000,000,000,000,000
19
scsi: megaraid_sas: return error when create DMA pool failed when create DMA pool for cmd frames failed, we should return -ENOMEM, instead of 0. In some case in: megasas_init_adapter_fusion() -->megasas_alloc_cmds() -->megasas_create_frame_pool create DMA pool failed, --> megasas_free_cmds() [1] -->megasas_alloc_cmds_fusion() failed, then goto fail_alloc_cmds. -->megasas_free_cmds() [2] we will call megasas_free_cmds twice, [1] will kfree cmd_list, [2] will use cmd_list.it will cause a problem: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ffffffc000f70000 [00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003, *pmd=0000001fbf894003, *pte=006000006d000707 Internal error: Oops: 96000005 [#1] SMP Modules linked in: CPU: 18 PID: 1 Comm: swapper/0 Not tainted task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000 PC is at megasas_free_cmds+0x30/0x70 LR is at megasas_free_cmds+0x24/0x70 ... Call trace: [<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70 [<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8 [<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760 [<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8 [<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4 [<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c [<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430 [<ffffffc00053a92c>] __driver_attach+0xa8/0xb0 [<ffffffc000538178>] bus_for_each_dev+0x74/0xc8 [<ffffffc000539e88>] driver_attach+0x28/0x34 [<ffffffc000539a18>] bus_add_driver+0x16c/0x248 [<ffffffc00053b234>] driver_register+0x6c/0x138 [<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c [<ffffffc000ce3868>] megasas_init+0xc0/0x1a8 [<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec [<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284 [<ffffffc0008d90b8>] kernel_init+0x1c/0xe4 Signed-off-by: Jason Yan <[email protected]> Acked-by: Sumit Saxena <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
matches_filtered_tree(const authz_user_rules_t *authz, const char *repos_name, const char *user) { /* Does the user match? */ if (user) { if (authz->user == NULL || strcmp(user, authz->user)) return FALSE; } else if (authz->user != NULL) return FALSE; /* Does the repository match as well? */ return strcmp(repos_name, authz->repository) == 0; }
0
[ "CWE-703" ]
subversion
e1b615840932fb46aefe1cd90d2115720af4600e
232,593,646,226,544,030,000,000,000,000,000,000,000
16
Fix issue #4880 "Use-after-free of object-pools when used as httpd module" Ensure that we initialize authz again if the pool which our authz caches depend on is cleared. Apache HTTPD may run pre/post config hooks multiple times and clear its global configuration pool which our authz caching pools depend on. Reported-by: Thomas Weißschuh (thomas {at} t-8ch dot de) Thomas has also confirmed that this patch fixes the problem. * subversion/libsvn_repos/authz.c (deinit_authz): New pool cleanup handler which resets authz initialization in case the parent pool of our authz caches is cleared. (synchronized_authz_initialize): Register new pool cleanup handler. git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1894734 13f79535-47bb-0310-9956-ffa450edef68
ipmi_sdr_print_sensor_mc_locator(struct sdr_record_mc_locator *mc) { char desc[17]; if (!mc) return -1; memset(desc, 0, sizeof (desc)); snprintf(desc, (mc->id_code & 0x1f) + 1, "%s", mc->id_string); if (verbose == 0) { if (csv_output) printf("%s,00h,ok,%d.%d\n", mc->id_code ? desc : "", mc->entity.id, mc->entity.instance); else if (sdr_extended) { printf("%-16s | 00h | ok | %2d.%1d | ", mc->id_code ? desc : "", mc->entity.id, mc->entity.instance); printf("%s MC @ %02Xh\n", (mc-> pwr_state_notif & 0x1) ? "Static" : "Dynamic", mc->dev_slave_addr); } else { printf("%-16s | %s MC @ %02Xh %s | ok\n", mc->id_code ? desc : "", (mc-> pwr_state_notif & 0x1) ? "Static" : "Dynamic", mc->dev_slave_addr, (mc->pwr_state_notif & 0x1) ? " " : ""); } return 0; /* done */ } printf("Device ID : %s\n", mc->id_string); printf("Entity ID : %d.%d (%s)\n", mc->entity.id, mc->entity.instance, val2str(mc->entity.id, entity_id_vals)); printf("Device Slave Address : %02Xh\n", mc->dev_slave_addr); printf("Channel Number : %01Xh\n", mc->channel_num); printf("ACPI System P/S Notif : %sRequired\n", (mc->pwr_state_notif & 0x4) ? "" : "Not "); printf("ACPI Device P/S Notif : %sRequired\n", (mc->pwr_state_notif & 0x2) ? "" : "Not "); printf("Controller Presence : %s\n", (mc->pwr_state_notif & 0x1) ? "Static" : "Dynamic"); printf("Logs Init Agent Errors : %s\n", (mc->global_init & 0x8) ? "Yes" : "No"); printf("Event Message Gen : "); if (!(mc->global_init & 0x3)) printf("Enable\n"); else if ((mc->global_init & 0x3) == 0x1) printf("Disable\n"); else if ((mc->global_init & 0x3) == 0x2) printf("Do Not Init Controller\n"); else printf("Reserved\n"); printf("Device Capabilities\n"); printf(" Chassis Device : %s\n", (mc->dev_support & 0x80) ? "Yes" : "No"); printf(" Bridge : %s\n", (mc->dev_support & 0x40) ? "Yes" : "No"); printf(" IPMB Event Generator : %s\n", (mc->dev_support & 0x20) ? "Yes" : "No"); printf(" IPMB Event Receiver : %s\n", (mc->dev_support & 0x10) ? "Yes" : "No"); printf(" FRU Inventory Device : %s\n", (mc->dev_support & 0x08) ? "Yes" : "No"); printf(" SEL Device : %s\n", (mc->dev_support & 0x04) ? "Yes" : "No"); printf(" SDR Repository : %s\n", (mc->dev_support & 0x02) ? "Yes" : "No"); printf(" Sensor Device : %s\n", (mc->dev_support & 0x01) ? "Yes" : "No"); printf("\n"); return 0; }
1
[ "CWE-120" ]
ipmitool
7ccea283dd62a05a320c1921e3d8d71a87772637
242,788,972,258,774,980,000,000,000,000,000,000,000
85
fru, sdr: Fix id_string buffer overflows Final part of the fixes for CVE-2020-5208, see https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp 9 variants of stack buffer overflow when parsing `id_string` field of SDR records returned from `CMD_GET_SDR` command. SDR record structs have an `id_code` field, and an `id_string` `char` array. The length of `id_string` is calculated as `(id_code & 0x1f) + 1`, which can be larger than expected 16 characters (if `id_code = 0xff`, then length will be `(0xff & 0x1f) + 1 = 32`). In numerous places, this can cause stack buffer overflow when copying into fixed buffer of size `17` bytes from this calculated length.
static void dns_connect(struct PgSocket *server) { struct sockaddr_un sa_un; struct sockaddr_in sa_in; struct sockaddr_in6 sa_in6; struct sockaddr *sa; struct PgDatabase *db = server->pool->db; const char *host = db->host; const char *unix_dir; int sa_len; if (!host || host[0] == '/') { slog_noise(server, "unix socket: %s", sa_un.sun_path); memset(&sa_un, 0, sizeof(sa_un)); sa_un.sun_family = AF_UNIX; unix_dir = host ? host : cf_unix_socket_dir; if (!unix_dir || !*unix_dir) { log_error("Unix socket dir not configured: %s", db->name); disconnect_server(server, false, "cannot connect"); return; } snprintf(sa_un.sun_path, sizeof(sa_un.sun_path), "%s/.s.PGSQL.%d", unix_dir, db->port); sa = (struct sockaddr *)&sa_un; sa_len = sizeof(sa_un); } else if (strchr(host, ':')) { // assume IPv6 address on any : in addr slog_noise(server, "inet6 socket: %s", db->host); memset(&sa_in6, 0, sizeof(sa_in6)); sa_in6.sin6_family = AF_INET6; inet_pton(AF_INET6, db->host, (void *) sa_in6.sin6_addr.s6_addr); sa_in6.sin6_port = htons(db->port); sa = (struct sockaddr *)&sa_in6; sa_len = sizeof(sa_in6); } else if (host[0] >= '0' && host[0] <= '9') { // else try IPv4 slog_noise(server, "inet socket: %s", db->host); memset(&sa_in, 0, sizeof(sa_in)); sa_in.sin_family = AF_INET; sa_in.sin_addr.s_addr = inet_addr(db->host); sa_in.sin_port = htons(db->port); sa = (struct sockaddr *)&sa_in; sa_len = sizeof(sa_in); } else { struct DNSToken *tk; slog_noise(server, "dns socket: %s", db->host); /* launch dns lookup */ tk = adns_resolve(adns, db->host, dns_callback, server); if (tk) server->dns_token = tk; return; } connect_server(server, sa, sa_len); }
0
[]
pgbouncer
4b92112b820830b30cd7bc91bef3dd8f35305525
188,229,234,415,311,850,000,000,000,000,000,000,000
53
add_database: fail gracefully if too long db name Truncating & adding can lead to fatal() later. It was not an issue before, but with audodb (* in [databases] section) the database name can some from network, thus allowing remote shutdown..
rtadv_prefix_free (struct rtadv_prefix *rtadv_prefix) { XFREE (MTYPE_RTADV_PREFIX, rtadv_prefix); }
0
[ "CWE-119", "CWE-787" ]
quagga
cfb1fae25f8c092e0d17073eaf7bd428ce1cd546
125,904,159,864,228,960,000,000,000,000,000,000,000
4
zebra: stack overrun in IPv6 RA receive code (CVE-2016-1245) The IPv6 RA code also receives ICMPv6 RS and RA messages. Unfortunately, by bad coding practice, the buffer size specified on receiving such messages mixed up 2 constants that in fact have different values. The code itself has: #define RTADV_MSG_SIZE 4096 While BUFSIZ is system-dependent, in my case (x86_64 glibc): /usr/include/_G_config.h:#define _G_BUFSIZ 8192 /usr/include/libio.h:#define _IO_BUFSIZ _G_BUFSIZ /usr/include/stdio.h:# define BUFSIZ _IO_BUFSIZ FreeBSD, OpenBSD, NetBSD and Illumos are not affected, since all of them have BUFSIZ == 1024. As the latter is passed to the kernel on recvmsg(), it's possible to overwrite 4kB of stack -- with ICMPv6 packets that can be globally sent to any of the system's addresses (using fragmentation to get to 8k). (The socket has filters installed limiting this to RS and RA packets, but does not have a filter for source address or TTL.) Issue discovered by trying to test other stuff, which randomly caused the stack to be smaller than 8kB in that code location, which then causes the kernel to report EFAULT (Bad address). Signed-off-by: David Lamparter <[email protected]> Reviewed-by: Donald Sharp <[email protected]>
static inline php_stream *phar_get_entrypufp(phar_entry_info *entry TSRMLS_DC) { if (!entry->is_persistent) { return entry->phar->ufp; } return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].ufp; }
0
[ "CWE-119" ]
php-src
f59b67ae50064560d7bfcdb0d6a8ab284179053c
2,728,845,202,211,094,000,000,000,000,000,000,000
7
Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod, Bool single_group, Bool hint_no_offset) { GF_ESD *esd; GF_InitialObjectDescriptor *iod; u32 i, val, res, streamType; u32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type; GF_Err e; char szPayload[30]; GF_RTPHinter *hinter; Bool copy, has_iod, single_av; u8 init_payt = BASE_PAYT; u32 mtype; GF_SDP_IODProfile iod_mode = GF_SDP_IOD_NONE; u32 media_group = 0; u8 media_prio = 0; tot_bw = 0; prev_ocr = 0; single_ocr = 1; has_iod = 1; iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file); if (!iod) has_iod = 0; else { if (!gf_list_count(iod->ESDescriptors)) has_iod = 0; gf_odf_desc_del((GF_Descriptor *) iod); } spec_type = gf_isom_guess_specification(file); single_av = single_group ? 1 : gf_isom_is_single_av(file); /*first make sure we use a systems track as base OCR*/ for (i=0; i<gf_isom_get_track_count(file); i++) { res = gf_isom_get_media_type(file, i+1); if ((res==GF_ISOM_MEDIA_SCENE) || (res==GF_ISOM_MEDIA_OD)) { if (gf_isom_is_track_in_root_od(file, i+1)) { gf_isom_set_default_sync_track(file, i+1); break; } } } nb_done = 0; for (i=0; i<gf_isom_get_track_count(file); i++) { sl_mode = base_flags; copy = copy_data; /*skip emty tracks (mainly MPEG-4 interaction streams...*/ if (!gf_isom_get_sample_count(file, i+1)) continue; if (!gf_isom_is_track_enabled(file, i+1)) { M4_LOG(GF_LOG_INFO, ("Track ID %d disabled - skipping hint\n", gf_isom_get_track_id(file, i+1) )); continue; } mtype = gf_isom_get_media_type(file, i+1); switch (mtype) { case GF_ISOM_MEDIA_VISUAL: if (single_av) { media_group = 2; media_prio = 2; } break; case GF_ISOM_MEDIA_AUXV: if (single_av) { media_group = 2; media_prio = 3; } break; case GF_ISOM_MEDIA_PICT: if (single_av) { media_group = 2; media_prio = 4; } break; case GF_ISOM_MEDIA_AUDIO: if (single_av) { media_group = 2; media_prio = 1; } break; case GF_ISOM_MEDIA_HINT: continue; default: /*no hinting of systems track on isma*/ if (spec_type==GF_ISOM_BRAND_ISMA) continue; } mtype = gf_isom_get_media_subtype(file, i+1, 1); if ((mtype==GF_ISOM_SUBTYPE_MPEG4) || (mtype==GF_ISOM_SUBTYPE_MPEG4_CRYP) ) mtype = gf_isom_get_mpeg4_subtype(file, i+1, 1); if (!single_av) { /*one media per group only (we should prompt user for group selection)*/ media_group ++; media_prio = 1; } streamType = 0; esd = gf_isom_get_esd(file, i+1, 1); if (esd && esd->decoderConfig) { streamType = esd->decoderConfig->streamType; if (!prev_ocr) { prev_ocr = esd->OCRESID; if (!esd->OCRESID) prev_ocr = esd->ESID; } else if (esd->OCRESID && prev_ocr != esd->OCRESID) { single_ocr = 0; } /*OD MUST BE WITHOUT REFERENCES*/ if (streamType==1) copy = 1; } gf_odf_desc_del((GF_Descriptor *) esd); if (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) { /*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*/ if (gf_isom_get_sample_count(file, i+1)==1) { GF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val); if (streamType) { res = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType); } else { /*not a system track, we shall hint it*/ res = 0; } if (samp) gf_isom_sample_del(&samp); if (res) continue; } } if (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING; hinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e); if (!hinter) { if (e) { M4_LOG(nb_done ? GF_LOG_WARNING : GF_LOG_ERROR, ("Cannot create hinter (%s)\n", gf_error_to_string(e) )); if (!nb_done) return e; } continue; } if (hint_no_offset) gf_hinter_track_force_no_offsets(hinter); bw = gf_hinter_track_get_bandwidth(hinter); tot_bw += bw; flags = gf_hinter_track_get_flags(hinter); //set extraction mode for AVC/SVC gf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY); gf_hinter_track_get_payload_name(hinter, szPayload); M4_LOG(GF_LOG_INFO, ("Hinting track ID %d - Type \"%s:%s\" (%s) - BW %d kbps\n", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw)); if (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) M4_LOG(GF_LOG_INFO, ("\tMPEG-4 Systems stream carousel enabled\n")); e = gf_hinter_track_process(hinter); if (!e) e = gf_hinter_track_finalize(hinter, has_iod); gf_hinter_track_del(hinter); if (e) { M4_LOG(GF_LOG_ERROR, ("Error while hinting (%s)\n", gf_error_to_string(e))); if (!nb_done) return e; } init_payt++; nb_done ++; } if (has_iod) { iod_mode = GF_SDP_IOD_ISMA; if (regular_iod) iod_mode = GF_SDP_IOD_REGULAR; } else { iod_mode = GF_SDP_IOD_NONE; } gf_hinter_finalize(file, iod_mode, tot_bw); if (!single_ocr) M4_LOG(GF_LOG_WARNING, ("Warning: at least 2 timelines found in the file\nThis may not be supported by servers/players\n\n")); return GF_OK; }
0
[ "CWE-476" ]
gpac
87afe070cd6866df7fe80f11b26ef75161de85e0
121,056,228,896,289,260,000,000,000,000,000,000,000
174
fixed #1734
void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl) { int rc = security_ops->xfrm_decode_session(skb, &fl->secid, 0); BUG_ON(rc); }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
193,894,811,207,207,130,000,000,000,000,000,000,000
6
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
static gpointer test_helper_server(gpointer opaque) { struct GVncTest *data = opaque; GSocketListener *server; GSocketConnection *client; GIOStream *ios; GInputStream *is; GOutputStream *os; server = g_socket_listener_new(); data->port = g_socket_listener_add_any_inet_port(server, NULL, NULL); g_mutex_unlock(&data->lock); client = g_socket_listener_accept(server, NULL, NULL, NULL); ios = G_IO_STREAM(client); is = g_io_stream_get_input_stream(ios); os = g_io_stream_get_output_stream(ios); guint8 greeting[] = { 'R', 'F', 'B', ' ', '0', '0', '3', '.', '0', '0', '8', '\n', }; /* Greeting */ test_send_bytes(os, greeting, G_N_ELEMENTS(greeting)); test_recv_bytes(is, greeting, G_N_ELEMENTS(greeting)); /* N auth */ test_send_u8(os, 1); /* auth == none */ test_send_u8(os, 1); test_recv_u8(is, 1); /* auth result */ test_send_u32(os, 0); /* shared flag */ test_recv_u8(is, 0); data->test_func(is, os); g_mutex_lock(&data->clock); while (!data->quit) { g_cond_wait(&data->cond, &data->clock); } g_object_unref(client); }
0
[]
gtk-vnc
c8583fd3783c5b811590fcb7bae4ce6e7344963e
175,789,001,298,240,320,000,000,000,000,000,000,000
51
Correctly validate color map range indexes The color map index could wrap around to zero causing negative array index accesses. https://bugzilla.gnome.org/show_bug.cgi?id=778050 CVE-2017-5885 Signed-off-by: Daniel P. Berrange <[email protected]>
spnego_gss_import_cred(OM_uint32 *minor_status, gss_buffer_t token, gss_cred_id_t *cred_handle) { OM_uint32 ret; spnego_gss_cred_id_t spcred; gss_cred_id_t mcred; ret = gss_import_cred(minor_status, token, &mcred); if (GSS_ERROR(ret)) return (ret); spcred = malloc(sizeof(*spcred)); if (spcred == NULL) { gss_release_cred(minor_status, &mcred); *minor_status = ENOMEM; return (GSS_S_FAILURE); } spcred->mcred = mcred; spcred->neg_mechs = GSS_C_NULL_OID_SET; *cred_handle = (gss_cred_id_t)spcred; return (ret); }
0
[ "CWE-415" ]
krb5
f18ddf5d82de0ab7591a36e465bc24225776940f
179,237,302,705,491,350,000,000,000,000,000,000,000
22
Fix double-free in SPNEGO [CVE-2014-4343] In commit cd7d6b08 ("Verify acceptor's mech in SPNEGO initiator") the pointer sc->internal_mech became an alias into sc->mech_set->elements, which should be considered constant for the duration of the SPNEGO context. So don't free it. CVE-2014-4343: In MIT krb5 releases 1.10 and newer, an unauthenticated remote attacker with the ability to spoof packets appearing to be from a GSSAPI acceptor can cause a double-free condition in GSSAPI initiators (clients) which are using the SPNEGO mechanism, by returning a different underlying mechanism than was proposed by the initiator. At this stage of the negotiation, the acceptor is unauthenticated, and the acceptor's response could be spoofed by an attacker with the ability to inject traffic to the initiator. Historically, some double-free vulnerabilities can be translated into remote code execution, though the necessary exploits must be tailored to the individual application and are usually quite complicated. Double-frees can also be exploited to cause an application crash, for a denial of service. However, most GSSAPI client applications are not vulnerable, as the SPNEGO mechanism is not used by default (when GSS_C_NO_OID is passed as the mech_type argument to gss_init_sec_context()). The most common use of SPNEGO is for HTTP-Negotiate, used in web browsers and other web clients. Most such clients are believed to not offer HTTP-Negotiate by default, instead requiring a whitelist of sites for which it may be used to be configured. If the whitelist is configured to only allow HTTP-Negotiate over TLS connections ("https://"), a successful attacker must also spoof the web server's SSL certificate, due to the way the WWW-Authenticate header is sent in a 401 (Unauthorized) response message. Unfortunately, many instructions for enabling HTTP-Negotiate in common web browsers do not include a TLS requirement. CVSSv2 Vector: AV:N/AC:H/Au:N/C:C/I:C/A:C/E:POC/RL:OF/RC:C [[email protected]: CVE summary and CVSSv2 vector] ticket: 7969 (new) target_version: 1.12.2 tags: pullup
static int nf_tables_newsetelem(struct sock *nlsk, struct sk_buff *skb, const struct nlmsghdr *nlh, const struct nlattr * const nla[]) { struct net *net = sock_net(skb->sk); const struct nlattr *attr; struct nft_set *set; struct nft_ctx ctx; int rem, err = 0; if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL) return -EINVAL; err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, true); if (err < 0) return err; set = nf_tables_set_lookup(ctx.table, nla[NFTA_SET_ELEM_LIST_SET]); if (IS_ERR(set)) { if (nla[NFTA_SET_ELEM_LIST_SET_ID]) { set = nf_tables_set_lookup_byid(net, nla[NFTA_SET_ELEM_LIST_SET_ID]); } if (IS_ERR(set)) return PTR_ERR(set); } if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT) return -EBUSY; nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) { err = nft_add_set_elem(&ctx, set, attr); if (err < 0) break; set->nelems++; } return err; }
0
[ "CWE-19" ]
nf
a2f18db0c68fec96631c10cad9384c196e9008ac
128,691,927,410,360,300,000,000,000,000,000,000,000
39
netfilter: nf_tables: fix flush ruleset chain dependencies Jumping between chains doesn't mix well with flush ruleset. Rules from a different chain and set elements may still refer to us. [ 353.373791] ------------[ cut here ]------------ [ 353.373845] kernel BUG at net/netfilter/nf_tables_api.c:1159! [ 353.373896] invalid opcode: 0000 [#1] SMP [ 353.373942] Modules linked in: intel_powerclamp uas iwldvm iwlwifi [ 353.374017] CPU: 0 PID: 6445 Comm: 31c3.nft Not tainted 3.18.0 #98 [ 353.374069] Hardware name: LENOVO 5129CTO/5129CTO, BIOS 6QET47WW (1.17 ) 07/14/2010 [...] [ 353.375018] Call Trace: [ 353.375046] [<ffffffff81964c31>] ? nf_tables_commit+0x381/0x540 [ 353.375101] [<ffffffff81949118>] nfnetlink_rcv+0x3d8/0x4b0 [ 353.375150] [<ffffffff81943fc5>] netlink_unicast+0x105/0x1a0 [ 353.375200] [<ffffffff8194438e>] netlink_sendmsg+0x32e/0x790 [ 353.375253] [<ffffffff818f398e>] sock_sendmsg+0x8e/0xc0 [ 353.375300] [<ffffffff818f36b9>] ? move_addr_to_kernel.part.20+0x19/0x70 [ 353.375357] [<ffffffff818f44f9>] ? move_addr_to_kernel+0x19/0x30 [ 353.375410] [<ffffffff819016d2>] ? verify_iovec+0x42/0xd0 [ 353.375459] [<ffffffff818f3e10>] ___sys_sendmsg+0x3f0/0x400 [ 353.375510] [<ffffffff810615fa>] ? native_sched_clock+0x2a/0x90 [ 353.375563] [<ffffffff81176697>] ? acct_account_cputime+0x17/0x20 [ 353.375616] [<ffffffff8110dc78>] ? account_user_time+0x88/0xa0 [ 353.375667] [<ffffffff818f4bbd>] __sys_sendmsg+0x3d/0x80 [ 353.375719] [<ffffffff81b184f4>] ? int_check_syscall_exit_work+0x34/0x3d [ 353.375776] [<ffffffff818f4c0d>] SyS_sendmsg+0xd/0x20 [ 353.375823] [<ffffffff81b1826d>] system_call_fastpath+0x16/0x1b Release objects in this order: rules -> sets -> chains -> tables, to make sure no references to chains are held anymore. Reported-by: Asbjoern Sloth Toennesen <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
Fatal( const char* message ) { FTDemo_Display_Done( display ); FTDemo_Done( handle ); PanicZ( message ); }
0
[ "CWE-120" ]
freetype2-demos
b995299b73ba4cd259f221f500d4e63095508bec
96,488,732,701,253,000,000,000,000,000,000,000,000
6
Fix Savannah bug #30054. * src/ftdiff.c, src/ftgrid.c, src/ftmulti.c, src/ftstring.c, src/ftview.c: Use precision for `%s' where appropriate to avoid buffer overflows.
static void retrigger_next_event(void *arg) { struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases); if (!base->hres_active) return; raw_spin_lock(&base->lock); hrtimer_update_base(base); hrtimer_force_reprogram(base, 0); raw_spin_unlock(&base->lock); }
0
[ "CWE-200" ]
tip
dfb4357da6ddbdf57d583ba64361c9d792b0e0b1
138,693,115,599,089,000,000,000,000,000,000,000,000
12
time: Remove CONFIG_TIMER_STATS Currently CONFIG_TIMER_STATS exposes process information across namespaces: kernel/time/timer_list.c print_timer(): SEQ_printf(m, ", %s/%d", tmp, timer->start_pid); /proc/timer_list: #11: <0000000000000000>, hrtimer_wakeup, S:01, do_nanosleep, cron/2570 Given that the tracer can give the same information, this patch entirely removes CONFIG_TIMER_STATS. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Kees Cook <[email protected]> Acked-by: John Stultz <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: [email protected] Cc: Lai Jiangshan <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Xing Gao <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Jessica Frazelle <[email protected]> Cc: [email protected] Cc: Nicolas Iooss <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Michal Marek <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Andrew Morton <[email protected]> Cc: [email protected] Cc: Arjan van de Ven <[email protected]> Link: http://lkml.kernel.org/r/20170208192659.GA32582@beast Signed-off-by: Thomas Gleixner <[email protected]>
struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, const char *name, int name_len) { struct btrfs_dir_item *dir_item; unsigned long name_ptr; u32 total_len; u32 cur = 0; u32 this_len; struct extent_buffer *leaf; leaf = path->nodes[0]; dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item); if (verify_dir_item(root, leaf, dir_item)) return NULL; total_len = btrfs_item_size_nr(leaf, path->slots[0]); while (cur < total_len) { this_len = sizeof(*dir_item) + btrfs_dir_name_len(leaf, dir_item) + btrfs_dir_data_len(leaf, dir_item); name_ptr = (unsigned long)(dir_item + 1); if (btrfs_dir_name_len(leaf, dir_item) == name_len && memcmp_extent_buffer(leaf, name, name_ptr, name_len) == 0) return dir_item; cur += this_len; dir_item = (struct btrfs_dir_item *)((char *)dir_item + this_len); } return NULL; }
0
[ "CWE-310" ]
linux-2.6
9c52057c698fb96f8f07e7a4bcf4801a092bda89
293,087,545,145,225,950,000,000,000,000,000,000,000
33
Btrfs: fix hash overflow handling The handling for directory crc hash overflows was fairly obscure, split_leaf returns EOVERFLOW when we try to extend the item and that is supposed to bubble up to userland. For a while it did so, but along the way we added better handling of errors and forced the FS readonly if we hit IO errors during the directory insertion. Along the way, we started testing only for EEXIST and the EOVERFLOW case was dropped. The end result is that we may force the FS readonly if we catch a directory hash bucket overflow. This fixes a few problem spots. First I add tests for EOVERFLOW in the places where we can safely just return the error up the chain. btrfs_rename is harder though, because it tries to insert the new directory item only after it has already unlinked anything the rename was going to overwrite. Rather than adding very complex logic, I added a helper to test for the hash overflow case early while it is still safe to bail out. Snapshot and subvolume creation had a similar problem, so they are using the new helper now too. Signed-off-by: Chris Mason <[email protected]> Reported-by: Pascal Junod <[email protected]>
static int sisusb_get_free_outbuf(struct sisusb_usb_data *sisusb) { int i, timeout = 5 * HZ; wait_event_timeout(sisusb->wait_q, ((i = sisusb_outurb_available(sisusb)) >= 0), timeout); return i; }
0
[ "CWE-476" ]
linux
9a5729f68d3a82786aea110b1bfe610be318f80a
63,569,416,364,594,590,000,000,000,000,000,000,000
9
USB: sisusbvga: fix oops in error path of sisusb_probe The pointer used to log a failure of usb_register_dev() must be set before the error is logged. v2: fix that minor is not available before registration Signed-off-by: oliver Neukum <[email protected]> Reported-by: [email protected] Fixes: 7b5cd5fefbe02 ("USB: SisUSB2VGA: Convert printk to dev_* macros") Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
R_API RList *r_bin_file_set_hashes(RBin *bin, RList/*<RBinFileHash*/ *new_hashes) { r_return_val_if_fail (bin && bin->cur && bin->cur->o && bin->cur->o->info, NULL); RBinFile *bf = bin->cur; RBinInfo *info = bf->o->info; RList *prev_hashes = info->file_hashes; info->file_hashes = new_hashes; return prev_hashes; }
0
[ "CWE-125" ]
radare2
193f4fe01d7f626e2ea937450f2e0c4604420e9d
277,858,495,516,454,300,000,000,000,000,000,000,000
10
Fix integer overflow in string search causing oobread ##crash * Reported by @greatergoodest via huntrdev * BountyID: 8a3dc5cb-08b3-4807-82b2-77f08c137a04 * Reproducer bfileovf
static int reenc_keyslot_validate(struct crypt_device *cd, json_object *jobj_keyslot) { json_object *jobj_mode, *jobj_area, *jobj_type, *jobj_shift_size, *jobj_hash, *jobj_sector_size, *jobj_direction; const char *mode, *type, *direction; uint32_t sector_size; uint64_t shift_size; /* mode (string: encrypt,reencrypt,decrypt) * direction (string:) * area { * type: (string: datashift, journal, checksum, none) * hash: (string: checksum only) * sector_size (uint32: checksum only) * shift_size (uint64: datashift only) * } */ /* area and area type are validated in general validation code */ if (!jobj_keyslot || !json_object_object_get_ex(jobj_keyslot, "area", &jobj_area) || !json_object_object_get_ex(jobj_area, "type", &jobj_type)) return -EINVAL; jobj_mode = json_contains(cd, jobj_keyslot, "", "reencrypt keyslot", "mode", json_type_string); jobj_direction = json_contains(cd, jobj_keyslot, "", "reencrypt keyslot", "direction", json_type_string); if (!jobj_mode || !jobj_direction) return -EINVAL; mode = json_object_get_string(jobj_mode); type = json_object_get_string(jobj_type); direction = json_object_get_string(jobj_direction); if (strcmp(mode, "reencrypt") && strcmp(mode, "encrypt") && strcmp(mode, "decrypt")) { log_dbg(cd, "Illegal reencrypt mode %s.", mode); return -EINVAL; } if (strcmp(direction, "forward") && strcmp(direction, "backward")) { log_dbg(cd, "Illegal reencrypt direction %s.", direction); return -EINVAL; } if (!strcmp(type, "checksum")) { jobj_hash = json_contains(cd, jobj_area, "type:checksum", "Keyslot area", "hash", json_type_string); jobj_sector_size = json_contains(cd, jobj_area, "type:checksum", "Keyslot area", "sector_size", json_type_int); if (!jobj_hash || !jobj_sector_size) return -EINVAL; if (!validate_json_uint32(jobj_sector_size)) return -EINVAL; sector_size = crypt_jobj_get_uint32(jobj_sector_size); if (sector_size < SECTOR_SIZE || NOTPOW2(sector_size)) { log_dbg(cd, "Invalid sector_size (%" PRIu32 ") for checksum resilience mode.", sector_size); return -EINVAL; } } else if (!strcmp(type, "datashift")) { if (!(jobj_shift_size = json_contains(cd, jobj_area, "type:datashift", "Keyslot area", "shift_size", json_type_string))) return -EINVAL; shift_size = crypt_jobj_get_uint64(jobj_shift_size); if (!shift_size) return -EINVAL; if (MISALIGNED_512(shift_size)) { log_dbg(cd, "Shift size field has to be aligned to sector size: %" PRIu32, SECTOR_SIZE); return -EINVAL; } } return 0; }
0
[ "CWE-345" ]
cryptsetup
0113ac2d889c5322659ad0596d4cfc6da53e356c
322,911,939,862,140,730,000,000,000,000,000,000,000
71
Fix CVE-2021-4122 - LUKS2 reencryption crash recovery attack Fix possible attacks against data confidentiality through LUKS2 online reencryption extension crash recovery. An attacker can modify on-disk metadata to simulate decryption in progress with crashed (unfinished) reencryption step and persistently decrypt part of the LUKS device. This attack requires repeated physical access to the LUKS device but no knowledge of user passphrases. The decryption step is performed after a valid user activates the device with a correct passphrase and modified metadata. There are no visible warnings for the user that such recovery happened (except using the luksDump command). The attack can also be reversed afterward (simulating crashed encryption from a plaintext) with possible modification of revealed plaintext. The problem was caused by reusing a mechanism designed for actual reencryption operation without reassessing the security impact for new encryption and decryption operations. While the reencryption requires calculating and verifying both key digests, no digest was needed to initiate decryption recovery if the destination is plaintext (no encryption key). Also, some metadata (like encryption cipher) is not protected, and an attacker could change it. Note that LUKS2 protects visible metadata only when a random change occurs. It does not protect against intentional modification but such modification must not cause a violation of data confidentiality. The fix introduces additional digest protection of reencryption metadata. The digest is calculated from known keys and critical reencryption metadata. Now an attacker cannot create correct metadata digest without knowledge of a passphrase for used keyslots. For more details, see LUKS2 On-Disk Format Specification version 1.1.0.
static URI_INLINE const URI_CHAR * URI_FUNC(ParseHierPart)( URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { if (first >= afterLast) { return afterLast; } switch (*first) { case _UT('!'): case _UT('$'): case _UT('%'): case _UT('&'): case _UT('('): case _UT(')'): case _UT('-'): case _UT('*'): case _UT(','): case _UT('.'): case _UT(':'): case _UT(';'): case _UT('@'): case _UT('\''): case _UT('_'): case _UT('~'): case _UT('+'): case _UT('='): case URI_SET_DIGIT: case URI_SET_ALPHA: return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory); case _UT('/'): return URI_FUNC(ParsePartHelperTwo)(state, first + 1, afterLast, memory); default: return first; } }
0
[ "CWE-125" ]
uriparser
cef25028de5ff872c2e1f0a6c562eb3ea9ecbce4
157,896,385,322,453,740,000,000,000,000,000,000,000
37
Fix uriParse*Ex* out-of-bounds read
static struct GuidPropertySet *GuidPropertySet_find_guid(const e_guid_t *guid) { unsigned i; for (i=0; i<array_length(GuidPropertySet); i++) { if (guid_cmp(&GuidPropertySet[i].guid, guid) == 0) { return &GuidPropertySet[i]; } } return NULL; }
0
[ "CWE-770" ]
wireshark
b7a0650e061b5418ab4a8f72c6e4b00317aff623
139,206,405,274,506,520,000,000,000,000,000,000,000
10
MS-WSP: Don't allocate huge amounts of memory. Add a couple of memory allocation sanity checks, one of which fixes #17331.
static int ldb_parse_hex2char(const char *x) { if (isxdigit(x[0]) && isxdigit(x[1])) { const char h1 = x[0], h2 = x[1]; int c = 0; if (h1 >= 'a') c = h1 - (int)'a' + 10; else if (h1 >= 'A') c = h1 - (int)'A' + 10; else if (h1 >= '0') c = h1 - (int)'0'; c = c << 4; if (h2 >= 'a') c += h2 - (int)'a' + 10; else if (h2 >= 'A') c += h2 - (int)'A' + 10; else if (h2 >= '0') c += h2 - (int)'0'; return c; } return -1; }
0
[ "CWE-125" ]
samba
8d34d172092f71baad0d777567e49aebfa07313d
322,649,153,361,507,860,000,000,000,000,000,000,000
19
CVE-2019-3824 ldb: ldb_parse_tree use talloc_zero Initialise the created ldb_parse_tree with talloc_zero, this ensures that it is correctly initialised if inadvertently passed to a function expecting a different operation type. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13773 Signed-off-by: Gary Lockyer <[email protected]> Reviewed-by: Andrew Bartlett <[email protected]>
set_field_split_str(char *arg, char **key, char **value, char **delim) { char *value_end; *value = arg; value_end = strstr(arg, "->"); *key = value_end + strlen("->"); if (delim) { *delim = value_end; } if (!value_end) { return xasprintf("%s: missing `->'", arg); } if (strlen(value_end) <= strlen("->")) { return xasprintf("%s: missing field name following `->'", arg); } return NULL; }
0
[ "CWE-125" ]
ovs
9237a63c47bd314b807cda0bd2216264e82edbe8
233,658,526,205,301,700,000,000,000,000,000,000,000
20
ofp-actions: Avoid buffer overread in BUNDLE action decoding. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9052 Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Justin Pettit <[email protected]>
ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */ const char *format_p) /**< format buffer */ { const uint32_t date_buffer_length = 37; JERRY_VLA (lit_utf8_byte_t, date_buffer, date_buffer_length); lit_utf8_byte_t *dest_p = date_buffer; while (*format_p != LIT_CHAR_NULL) { if (*format_p != LIT_CHAR_DOLLAR_SIGN) { *dest_p++ = (lit_utf8_byte_t) *format_p++; continue; } format_p++; const char *str_p = NULL; int32_t number = 0; int32_t number_length = 0; switch (*format_p) { case LIT_CHAR_UPPERCASE_Y: /* Year. */ { number = ecma_date_year_from_time (datetime_number); if (number >= 100000 || number <= -100000) { number_length = 6; } else if (number >= 10000 || number <= -10000) { number_length = 5; } else { number_length = 4; } break; } case LIT_CHAR_LOWERCASE_Y: /* ISO Year: -000001, 0000, 0001, 9999, +012345 */ { number = ecma_date_year_from_time (datetime_number); if (0 <= number && number <= 9999) { number_length = 4; } else { number_length = 6; } break; } case LIT_CHAR_UPPERCASE_M: /* Month. */ { int32_t month = ecma_date_month_from_time (datetime_number); JERRY_ASSERT (month >= 0 && month <= 11); str_p = month_names_p[month]; break; } case LIT_CHAR_UPPERCASE_O: /* Month as number. */ { /* The 'ecma_date_month_from_time' (ECMA 262 v5, 15.9.1.4) returns a * number from 0 to 11, but we have to print the month from 1 to 12 * for ISO 8601 standard (ECMA 262 v5, 15.9.1.15). */ number = ecma_date_month_from_time (datetime_number) + 1; number_length = 2; break; } case LIT_CHAR_UPPERCASE_D: /* Day. */ { number = ecma_date_date_from_time (datetime_number); number_length = 2; break; } case LIT_CHAR_UPPERCASE_W: /* Day of week. */ { int32_t day = ecma_date_week_day (datetime_number); JERRY_ASSERT (day >= 0 && day <= 6); str_p = day_names_p[day]; break; } case LIT_CHAR_LOWERCASE_H: /* Hour. */ { number = ecma_date_hour_from_time (datetime_number); number_length = 2; break; } case LIT_CHAR_LOWERCASE_M: /* Minutes. */ { number = ecma_date_min_from_time (datetime_number); number_length = 2; break; } case LIT_CHAR_LOWERCASE_S: /* Seconds. */ { number = ecma_date_sec_from_time (datetime_number); number_length = 2; break; } case LIT_CHAR_LOWERCASE_I: /* Milliseconds. */ { number = ecma_date_ms_from_time (datetime_number); number_length = 3; break; } case LIT_CHAR_LOWERCASE_Z: /* Time zone hours part. */ { int32_t time_zone = (int32_t) ecma_date_local_time_zone_adjustment (datetime_number); if (time_zone >= 0) { *dest_p++ = LIT_CHAR_PLUS; } else { *dest_p++ = LIT_CHAR_MINUS; time_zone = -time_zone; } number = time_zone / ECMA_DATE_MS_PER_HOUR; number_length = 2; break; } default: { JERRY_ASSERT (*format_p == LIT_CHAR_UPPERCASE_Z); /* Time zone minutes part. */ int32_t time_zone = (int32_t) ecma_date_local_time_zone_adjustment (datetime_number); if (time_zone < 0) { time_zone = -time_zone; } number = (time_zone % ECMA_DATE_MS_PER_HOUR) / ECMA_DATE_MS_PER_MINUTE; number_length = 2; break; } } format_p++; if (str_p != NULL) { /* Print string values: month or day name which is always 3 characters */ memcpy (dest_p, str_p, 3); dest_p += 3; continue; } /* Print right aligned number values. */ JERRY_ASSERT (number_length > 0); if (number < 0) { number = -number; *dest_p++ = '-'; } else if (*(format_p - 1) == LIT_CHAR_LOWERCASE_Y && number_length == 6) { /* positive sign is compulsory for extended years */ *dest_p++ = '+'; } dest_p += number_length; lit_utf8_byte_t *buffer_p = dest_p; do { buffer_p--; *buffer_p = (lit_utf8_byte_t) ((number % 10) + (int32_t) LIT_CHAR_0); number /= 10; } while (--number_length); } JERRY_ASSERT (dest_p <= date_buffer + date_buffer_length); return ecma_make_string_value (ecma_new_ecma_string_from_utf8 (date_buffer, (lit_utf8_size_t) (dest_p - date_buffer))); } /* ecma_date_to_string_format */
1
[ "CWE-416" ]
jerryscript
3bcd48f72d4af01d1304b754ef19fe1a02c96049
286,316,023,783,816,980,000,000,000,000,000,000,000
188
Improve parse_identifier (#4691) Ascii string length is no longer computed during string allocation. JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz [email protected]
static void csi_P(struct vc_data *vc, unsigned int nr) { if (nr > vc->vc_cols - vc->vc_x) nr = vc->vc_cols - vc->vc_x; else if (!nr) nr = 1; delete_char(vc, nr); }
0
[ "CWE-416", "CWE-362" ]
linux
ca4463bf8438b403596edd0ec961ca0d4fbe0220
165,869,720,873,793,340,000,000,000,000,000,000,000
8
vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console The VT_DISALLOCATE ioctl can free a virtual console while tty_release() is still running, causing a use-after-free in con_shutdown(). This occurs because VT_DISALLOCATE considers a virtual console's 'struct vc_data' to be unused as soon as the corresponding tty's refcount hits 0. But actually it may be still being closed. Fix this by making vc_data be reference-counted via the embedded 'struct tty_port'. A newly allocated virtual console has refcount 1. Opening it for the first time increments the refcount to 2. Closing it for the last time decrements the refcount (in tty_operations::cleanup() so that it happens late enough), as does VT_DISALLOCATE. Reproducer: #include <fcntl.h> #include <linux/vt.h> #include <sys/ioctl.h> #include <unistd.h> int main() { if (fork()) { for (;;) close(open("/dev/tty5", O_RDWR)); } else { int fd = open("/dev/tty10", O_RDWR); for (;;) ioctl(fd, VT_DISALLOCATE, 5); } } KASAN report: BUG: KASAN: use-after-free in con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 Write of size 8 at addr ffff88806a4ec108 by task syz_vt/129 CPU: 0 PID: 129 Comm: syz_vt Not tainted 5.6.0-rc2 #11 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20191223_100556-anatol 04/01/2014 Call Trace: [...] con_shutdown+0x76/0x80 drivers/tty/vt/vt.c:3278 release_tty+0xa8/0x410 drivers/tty/tty_io.c:1514 tty_release_struct+0x34/0x50 drivers/tty/tty_io.c:1629 tty_release+0x984/0xed0 drivers/tty/tty_io.c:1789 [...] Allocated by task 129: [...] kzalloc include/linux/slab.h:669 [inline] vc_allocate drivers/tty/vt/vt.c:1085 [inline] vc_allocate+0x1ac/0x680 drivers/tty/vt/vt.c:1066 con_install+0x4d/0x3f0 drivers/tty/vt/vt.c:3229 tty_driver_install_tty drivers/tty/tty_io.c:1228 [inline] tty_init_dev+0x94/0x350 drivers/tty/tty_io.c:1341 tty_open_by_driver drivers/tty/tty_io.c:1987 [inline] tty_open+0x3ca/0xb30 drivers/tty/tty_io.c:2035 [...] Freed by task 130: [...] kfree+0xbf/0x1e0 mm/slab.c:3757 vt_disallocate drivers/tty/vt/vt_ioctl.c:300 [inline] vt_ioctl+0x16dc/0x1e30 drivers/tty/vt/vt_ioctl.c:818 tty_ioctl+0x9db/0x11b0 drivers/tty/tty_io.c:2660 [...] Fixes: 4001d7b7fc27 ("vt: push down the tty lock so we can see what is left to tackle") Cc: <[email protected]> # v3.4+ Reported-by: [email protected] Acked-by: Jiri Slaby <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
static void find_refs(RCore *core, const char *glob) { char cmd[128]; ut64 curseek = core->offset; while (*glob == ' ') glob++; if (!*glob) { glob = "str."; } if (*glob == '?') { eprintf ("Usage: arf [flag-str-filter]\n"); return; } eprintf ("Finding references of flags matching '%s'...\n", glob); snprintf (cmd, sizeof (cmd) - 1, ".(findstref) @@= `f~%s[0]`", glob); r_core_cmd0 (core, "(findstref,f here=$$,s entry0,/r here,f-here)"); r_core_cmd0 (core, cmd); r_core_cmd0 (core, "(-findstref)"); r_core_seek (core, curseek, 1); }
0
[ "CWE-416", "CWE-908" ]
radare2
9d348bcc2c4bbd3805e7eec97b594be9febbdf9a
77,348,910,691,040,310,000,000,000,000,000,000,000
18
Fix #9943 - Invalid free on RAnal.avr
static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id) { u64 a; mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) { u64 t = mdesc_arc_target(hp, a); const char *name; const u64 *id; name = mdesc_node_name(hp, t); if (strcmp(name, "cpu")) continue; id = mdesc_get_property(hp, t, "id", NULL); if (*id < NR_CPUS) cpu_data(*id).proc_id = proc_id; } }
0
[ "CWE-476" ]
sparc
80caf43549e7e41a695c6d1e11066286538b336f
32,343,267,578,420,933,000,000,000,000,000,000,000
18
mdesc: fix a missing-check bug in get_vdev_port_node_info() In get_vdev_port_node_info(), 'node_info->vdev_port.name' is allcoated by kstrdup_const(), and it returns NULL when fails. So 'node_info->vdev_port.name' should be checked. Signed-off-by: Gen Zhang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void init_cdrom_command(struct packet_command *cgc, void *buf, int len, int type) { memset(cgc, 0, sizeof(struct packet_command)); if (buf) memset(buf, 0, len); cgc->buffer = (char *) buf; cgc->buflen = len; cgc->data_direction = type; cgc->timeout = CDROM_DEF_TIMEOUT; }
0
[ "CWE-119", "CWE-787" ]
linux
9de4ee40547fd315d4a0ed1dd15a2fa3559ad707
189,958,884,464,440,800,000,000,000,000,000,000,000
11
cdrom: information leak in cdrom_ioctl_media_changed() This cast is wrong. "cdi->capacity" is an int and "arg" is an unsigned long. The way the check is written now, if one of the high 32 bits is set then we could read outside the info->slots[] array. This bug is pretty old and it predates git. Reviewed-by: Christoph Hellwig <[email protected]> Cc: [email protected] Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
uint32 get_partition_id_range_for_endpoint(partition_info *part_info, bool left_endpoint, bool include_endpoint) { longlong *range_array= part_info->range_int_array; longlong part_end_val; uint max_partition= part_info->num_parts - 1; uint min_part_id= 0, max_part_id= max_partition, loc_part_id; /* Get the partitioning function value for the endpoint */ longlong part_func_value= part_info->part_expr->val_int_endpoint(left_endpoint, &include_endpoint); bool unsigned_flag= part_info->part_expr->unsigned_flag; DBUG_ENTER("get_partition_id_range_for_endpoint"); if (part_info->part_expr->null_value) { /* Special handling for MONOTONIC functions that can return NULL for values that are comparable. I.e. '2000-00-00' can be compared to '2000-01-01' but TO_DAYS('2000-00-00') returns NULL which cannot be compared used <, >, <=, >= etc. Otherwise, just return the first partition (may be included if not left endpoint) */ enum_monotonicity_info monotonic; monotonic= part_info->part_expr->get_monotonicity_info(); if (monotonic != MONOTONIC_INCREASING_NOT_NULL && monotonic != MONOTONIC_STRICT_INCREASING_NOT_NULL) { /* F(col) can not return NULL, return partition with lowest value */ if (!left_endpoint && include_endpoint) DBUG_RETURN(1); DBUG_RETURN(0); } } if (unsigned_flag) part_func_value-= 0x8000000000000000ULL; if (left_endpoint && !include_endpoint) part_func_value++; /* Search for the partition containing part_func_value (including the right endpoint). */ while (max_part_id > min_part_id) { loc_part_id= (max_part_id + min_part_id) / 2; if (range_array[loc_part_id] < part_func_value) min_part_id= loc_part_id + 1; else max_part_id= loc_part_id; } loc_part_id= max_part_id; /* Adjust for endpoints */ part_end_val= range_array[loc_part_id]; if (left_endpoint) { DBUG_ASSERT(part_func_value > part_end_val ? (loc_part_id == max_partition && !part_info->defined_max_value) : 1); /* In case of PARTITION p VALUES LESS THAN MAXVALUE the maximum value is in the current (last) partition. If value is equal or greater than the endpoint, the range starts from the next partition. */ if (part_func_value >= part_end_val && (loc_part_id < max_partition || !part_info->defined_max_value)) loc_part_id++; if (part_info->part_type == VERSIONING_PARTITION && part_func_value < INT_MAX32 && loc_part_id > part_info->vers_info->hist_part->id) { /* Historical query with AS OF point after the last history partition must include last history partition because it can be overflown (contain history rows out of right endpoint). */ loc_part_id= part_info->vers_info->hist_part->id; } } else { /* if 'WHERE <= X' and partition is LESS THAN (X) include next partition */ if (include_endpoint && loc_part_id < max_partition && part_func_value == part_end_val) loc_part_id++; /* Right endpoint, set end after correct partition */ loc_part_id++; } DBUG_RETURN(loc_part_id); }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
287,762,524,742,778,130,000,000,000,000,000,000,000
99
MDEV-24176 Preparations 1. moved fix_vcol_exprs() call to open_table() mysql_alter_table() doesn't do lock_tables() so it cannot win from fix_vcol_exprs() from there. Tests affected: main.default_session 2. Vanilla cleanups and comments.
uint gis_field_options_image(uchar *buff, List<Create_field> &create_fields) { uint image_size= 0; List_iterator<Create_field> it(create_fields); Create_field *field; while ((field= it++)) { if (field->sql_type != MYSQL_TYPE_GEOMETRY) continue; if (buff) { uchar *cbuf= buff + image_size; cbuf[0]= FIELDGEOM_STORAGE_MODEL; cbuf[1]= (uchar) Field_geom::GEOM_STORAGE_WKB; cbuf[2]= FIELDGEOM_PRECISION; cbuf[3]= (uchar) field->length; cbuf[4]= FIELDGEOM_SCALE; cbuf[5]= (uchar) field->decimals; cbuf[6]= FIELDGEOM_SRID; int4store(cbuf + 7, ((uint32) field->srid)); cbuf[11]= FIELDGEOM_END; } image_size+= 12; } return image_size; }
0
[ "CWE-120" ]
server
eca207c46293bc72dd8d0d5622153fab4d3fccf1
94,074,377,598,555,980,000,000,000,000,000,000,000
32
MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size. Precision should be kept below DECIMAL_MAX_SCALE for computations. It can be bigger in Item_decimal. I'd fix this too but it changes the existing behaviour so problemmatic to ix.
gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, struct iri *iri, int count) { struct request *req = NULL; char *type = NULL; char *user, *passwd; char *proxyauth; int statcode; int write_error; wgint contlen, contrange; struct url *conn; FILE *fp; int err; uerr_t retval; #ifdef HAVE_HSTS #ifdef TESTING /* we don't link against main.o when we're testing */ hsts_store_t hsts_store = NULL; #else extern hsts_store_t hsts_store; #endif const char *hsts_params; time_t max_age; bool include_subdomains; #endif int sock = -1; /* Set to 1 when the authorization has already been sent and should not be tried again. */ bool auth_finished = false; /* Set to 1 when just globally-set Basic authorization has been sent; * should prevent further Basic negotiations, but not other * mechanisms. */ bool basic_auth_finished = false; /* Whether NTLM authentication is used for this request. */ bool ntlm_seen = false; /* Whether our connection to the remote host is through SSL. */ bool using_ssl = false; /* Whether a HEAD request will be issued (as opposed to GET or POST). */ bool head_only = !!(*dt & HEAD_ONLY); /* Whether conditional get request will be issued. */ bool cond_get = !!(*dt & IF_MODIFIED_SINCE); #ifdef HAVE_METALINK /* Are we looking for metalink info in HTTP headers? */ bool metalink = !!(*dt & METALINK_METADATA); #endif char *head = NULL; struct response *resp = NULL; char hdrval[512]; char *message = NULL; /* Declare WARC variables. */ bool warc_enabled = (opt.warc_filename != NULL); FILE *warc_tmp = NULL; char warc_timestamp_str [21]; char warc_request_uuid [48]; ip_address *warc_ip = NULL; off_t warc_payload_offset = -1; /* Whether this connection will be kept alive after the HTTP request is done. */ bool keep_alive; /* Is the server using the chunked transfer encoding? */ bool chunked_transfer_encoding = false; /* Whether keep-alive should be inhibited. */ bool inhibit_keep_alive = !opt.http_keep_alive || opt.ignore_length; /* Headers sent when using POST. */ wgint body_data_size = 0; #ifdef HAVE_SSL if (u->scheme == SCHEME_HTTPS) { /* Initialize the SSL context. After this has once been done, it becomes a no-op. */ if (!ssl_init ()) { scheme_disable (SCHEME_HTTPS); logprintf (LOG_NOTQUIET, _("Disabling SSL due to encountered errors.\n")); retval = SSLINITFAILED; goto cleanup; } } #endif /* HAVE_SSL */ /* Initialize certain elements of struct http_stat. */ hs->len = 0; hs->contlen = -1; hs->res = -1; hs->rderrmsg = NULL; hs->newloc = NULL; xfree(hs->remote_time); hs->error = NULL; hs->message = NULL; conn = u; { uerr_t ret; req = initialize_request (u, hs, dt, proxy, inhibit_keep_alive, &basic_auth_finished, &body_data_size, &user, &passwd, &ret); if (req == NULL) { retval = ret; goto cleanup; } } retry_with_auth: /* We need to come back here when the initial attempt to retrieve without authorization header fails. (Expected to happen at least for the Digest authorization scheme.) */ if (opt.cookies) request_set_header (req, "Cookie", cookie_header (wget_cookie_jar, u->host, u->port, u->path, #ifdef HAVE_SSL u->scheme == SCHEME_HTTPS #else 0 #endif ), rel_value); /* Add the user headers. */ if (opt.user_headers) { int i; for (i = 0; opt.user_headers[i]; i++) request_set_user_header (req, opt.user_headers[i]); } proxyauth = NULL; if (proxy) { conn = proxy; initialize_proxy_configuration (u, req, proxy, &proxyauth); } keep_alive = true; /* Establish the connection. */ if (inhibit_keep_alive) keep_alive = false; { uerr_t conn_err = establish_connection (u, &conn, hs, proxy, &proxyauth, &req, &using_ssl, inhibit_keep_alive, &sock); if (conn_err != RETROK) { retval = conn_err; goto cleanup; } } /* Open the temporary file where we will write the request. */ if (warc_enabled) { warc_tmp = warc_tempfile (); if (warc_tmp == NULL) { CLOSE_INVALIDATE (sock); retval = WARC_TMP_FOPENERR; goto cleanup; } if (! proxy) { warc_ip = (ip_address *) alloca (sizeof (ip_address)); socket_ip_address (sock, warc_ip, ENDPOINT_PEER); } } /* Send the request to server. */ write_error = request_send (req, sock, warc_tmp); if (write_error >= 0) { if (opt.body_data) { DEBUGP (("[BODY data: %s]\n", opt.body_data)); write_error = fd_write (sock, opt.body_data, body_data_size, -1); if (write_error >= 0 && warc_tmp != NULL) { int warc_tmp_written; /* Remember end of headers / start of payload. */ warc_payload_offset = ftello (warc_tmp); /* Write a copy of the data to the WARC record. */ warc_tmp_written = fwrite (opt.body_data, 1, body_data_size, warc_tmp); if (warc_tmp_written != body_data_size) write_error = -2; } } else if (opt.body_file && body_data_size != 0) { if (warc_tmp != NULL) /* Remember end of headers / start of payload */ warc_payload_offset = ftello (warc_tmp); write_error = body_file_send (sock, opt.body_file, body_data_size, warc_tmp); } } if (write_error < 0) { CLOSE_INVALIDATE (sock); if (warc_tmp != NULL) fclose (warc_tmp); if (write_error == -2) retval = WARC_TMP_FWRITEERR; else retval = WRITEFAILED; goto cleanup; } logprintf (LOG_VERBOSE, _("%s request sent, awaiting response... "), proxy ? "Proxy" : "HTTP"); contlen = -1; contrange = 0; *dt &= ~RETROKF; if (warc_enabled) { bool warc_result; /* Generate a timestamp and uuid for this request. */ warc_timestamp (warc_timestamp_str, sizeof(warc_timestamp_str)); warc_uuid_str (warc_request_uuid); /* Create a request record and store it in the WARC file. */ warc_result = warc_write_request_record (u->url, warc_timestamp_str, warc_request_uuid, warc_ip, warc_tmp, warc_payload_offset); if (! warc_result) { CLOSE_INVALIDATE (sock); retval = WARC_ERR; goto cleanup; } /* warc_write_request_record has also closed warc_tmp. */ } /* Repeat while we receive a 10x response code. */ { bool _repeat; do { head = read_http_response_head (sock); if (!head) { if (errno == 0) { logputs (LOG_NOTQUIET, _("No data received.\n")); CLOSE_INVALIDATE (sock); retval = HEOF; } else { logprintf (LOG_NOTQUIET, _("Read error (%s) in headers.\n"), fd_errstr (sock)); CLOSE_INVALIDATE (sock); retval = HERR; } goto cleanup; } DEBUGP (("\n---response begin---\n%s---response end---\n", head)); resp = resp_new (head); /* Check for status line. */ xfree(message); statcode = resp_status (resp, &message); if (statcode < 0) { char *tms = datetime_str (time (NULL)); logprintf (LOG_VERBOSE, "%d\n", statcode); logprintf (LOG_NOTQUIET, _("%s ERROR %d: %s.\n"), tms, statcode, quotearg_style (escape_quoting_style, _("Malformed status line"))); CLOSE_INVALIDATE (sock); retval = HERR; goto cleanup; } if (H_10X (statcode)) { xfree (head); resp_free (&resp); _repeat = true; DEBUGP (("Ignoring response\n")); } else { _repeat = false; } } while (_repeat); } xfree(hs->message); hs->message = xstrdup (message); if (!opt.server_response) logprintf (LOG_VERBOSE, "%2d %s\n", statcode, message ? quotearg_style (escape_quoting_style, message) : ""); else { logprintf (LOG_VERBOSE, "\n"); print_server_response (resp, " "); } if (!opt.ignore_length && resp_header_copy (resp, "Content-Length", hdrval, sizeof (hdrval))) { wgint parsed; errno = 0; parsed = str_to_wgint (hdrval, NULL, 10); if (parsed == WGINT_MAX && errno == ERANGE) { /* Out of range. #### If Content-Length is out of range, it most likely means that the file is larger than 2G and that we're compiled without LFS. In that case we should probably refuse to even attempt to download the file. */ contlen = -1; } else if (parsed < 0) { /* Negative Content-Length; nonsensical, so we can't assume any information about the content to receive. */ contlen = -1; } else contlen = parsed; } /* Check for keep-alive related responses. */ if (!inhibit_keep_alive) { if (resp_header_copy (resp, "Connection", hdrval, sizeof (hdrval))) { if (0 == c_strcasecmp (hdrval, "Close")) keep_alive = false; } } chunked_transfer_encoding = false; if (resp_header_copy (resp, "Transfer-Encoding", hdrval, sizeof (hdrval)) && 0 == c_strcasecmp (hdrval, "chunked")) chunked_transfer_encoding = true; /* Handle (possibly multiple instances of) the Set-Cookie header. */ if (opt.cookies) { int scpos; const char *scbeg, *scend; /* The jar should have been created by now. */ assert (wget_cookie_jar != NULL); for (scpos = 0; (scpos = resp_header_locate (resp, "Set-Cookie", scpos, &scbeg, &scend)) != -1; ++scpos) { char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie); cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, u->path, set_cookie); } } if (keep_alive) /* The server has promised that it will not close the connection when we're done. This means that we can register it. */ register_persistent (conn->host, conn->port, sock, using_ssl); #ifdef HAVE_METALINK /* We need to check for the Metalink data in the very first response we get from the server (before redirectionrs, authorization, etc.). */ if (metalink) { hs->metalink = metalink_from_http (resp, hs, u); xfree (hs->message); retval = RETR_WITH_METALINK; CLOSE_FINISH (sock); goto cleanup; } #endif if (statcode == HTTP_STATUS_UNAUTHORIZED) { /* Authorization is required. */ uerr_t auth_err = RETROK; bool retry; /* Normally we are not interested in the response body. But if we are writing a WARC file we are: we like to keep everyting. */ if (warc_enabled) { int _err; type = resp_header_strdup (resp, "Content-Type"); _err = read_response_body (hs, sock, NULL, contlen, 0, chunked_transfer_encoding, u->url, warc_timestamp_str, warc_request_uuid, warc_ip, type, statcode, head); xfree (type); if (_err != RETRFINISHED || hs->res < 0) { CLOSE_INVALIDATE (sock); retval = _err; goto cleanup; } else CLOSE_FINISH (sock); } else { /* Since WARC is disabled, we are not interested in the response body. */ if (keep_alive && !head_only && skip_short_body (sock, contlen, chunked_transfer_encoding)) CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); } pconn.authorized = false; { auth_err = check_auth (u, user, passwd, resp, req, &ntlm_seen, &retry, &basic_auth_finished, &auth_finished); if (auth_err == RETROK && retry) { xfree (hs->message); resp_free (&resp); xfree (message); xfree (head); goto retry_with_auth; } } if (auth_err == RETROK) retval = AUTHFAILED; else retval = auth_err; goto cleanup; } else /* statcode != HTTP_STATUS_UNAUTHORIZED */ { /* Kludge: if NTLM is used, mark the TCP connection as authorized. */ if (ntlm_seen) pconn.authorized = true; } if (statcode == HTTP_STATUS_GATEWAY_TIMEOUT) { hs->len = 0; hs->res = 0; hs->restval = 0; CLOSE_FINISH (sock); xfree (hs->message); retval = GATEWAYTIMEOUT; goto cleanup; } { uerr_t ret = check_file_output (u, hs, resp, hdrval, sizeof hdrval); if (ret != RETROK) { retval = ret; goto cleanup; } } hs->statcode = statcode; if (statcode == -1) hs->error = xstrdup (_("Malformed status line")); else if (!*message) hs->error = xstrdup (_("(no description)")); else hs->error = xstrdup (message); #ifdef HAVE_HSTS if (opt.hsts && hsts_store) { hsts_params = resp_header_strdup (resp, "Strict-Transport-Security"); if (parse_strict_transport_security (hsts_params, &max_age, &include_subdomains)) { /* process strict transport security */ if (hsts_store_entry (hsts_store, u->scheme, u->host, u->port, max_age, include_subdomains)) DEBUGP(("Added new HSTS host: %s:%u (max-age: %u, includeSubdomains: %s)\n", u->host, u->port, (unsigned int) max_age, (include_subdomains ? "true" : "false"))); else DEBUGP(("Updated HSTS host: %s:%u (max-age: %u, includeSubdomains: %s)\n", u->host, u->port, (unsigned int) max_age, (include_subdomains ? "true" : "false"))); } } #endif type = resp_header_strdup (resp, "Content-Type"); if (type) { char *tmp = strchr (type, ';'); if (tmp) { #ifdef ENABLE_IRI /* sXXXav: only needed if IRI support is enabled */ char *tmp2 = tmp + 1; #endif while (tmp > type && c_isspace (tmp[-1])) --tmp; *tmp = '\0'; #ifdef ENABLE_IRI /* Try to get remote encoding if needed */ if (opt.enable_iri && !opt.encoding_remote) { tmp = parse_charset (tmp2); if (tmp) set_content_encoding (iri, tmp); xfree(tmp); } #endif } } hs->newloc = resp_header_strdup (resp, "Location"); hs->remote_time = resp_header_strdup (resp, "Last-Modified"); if (resp_header_copy (resp, "Content-Range", hdrval, sizeof (hdrval))) { wgint first_byte_pos, last_byte_pos, entity_length; if (parse_content_range (hdrval, &first_byte_pos, &last_byte_pos, &entity_length)) { contrange = first_byte_pos; contlen = last_byte_pos - first_byte_pos + 1; } } /* 20x responses are counted among successful by default. */ if (H_20X (statcode)) *dt |= RETROKF; if (statcode == HTTP_STATUS_NO_CONTENT) { /* 204 response has no body (RFC 2616, 4.3) */ /* In case the caller cares to look... */ hs->len = 0; hs->res = 0; hs->restval = 0; CLOSE_FINISH (sock); retval = RETRFINISHED; goto cleanup; } /* Return if redirected. */ if (H_REDIRECTED (statcode) || statcode == HTTP_STATUS_MULTIPLE_CHOICES) { /* RFC2068 says that in case of the 300 (multiple choices) response, the server can output a preferred URL through `Location' header; otherwise, the request should be treated like GET. So, if the location is set, it will be a redirection; otherwise, just proceed normally. */ if (statcode == HTTP_STATUS_MULTIPLE_CHOICES && !hs->newloc) *dt |= RETROKF; else { logprintf (LOG_VERBOSE, _("Location: %s%s\n"), hs->newloc ? escnonprint_uri (hs->newloc) : _("unspecified"), hs->newloc ? _(" [following]") : ""); /* In case the caller cares to look... */ hs->len = 0; hs->res = 0; hs->restval = 0; /* Normally we are not interested in the response body of a redirect. But if we are writing a WARC file we are: we like to keep everyting. */ if (warc_enabled) { int _err = read_response_body (hs, sock, NULL, contlen, 0, chunked_transfer_encoding, u->url, warc_timestamp_str, warc_request_uuid, warc_ip, type, statcode, head); if (_err != RETRFINISHED || hs->res < 0) { CLOSE_INVALIDATE (sock); retval = _err; goto cleanup; } else CLOSE_FINISH (sock); } else { /* Since WARC is disabled, we are not interested in the response body. */ if (keep_alive && !head_only && skip_short_body (sock, contlen, chunked_transfer_encoding)) CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); } /* From RFC2616: The status codes 303 and 307 have been added for servers that wish to make unambiguously clear which kind of reaction is expected of the client. A 307 should be redirected using the same method, in other words, a POST should be preserved and not converted to a GET in that case. With strict adherence to RFC2616, POST requests are not converted to a GET request on 301 Permanent Redirect or 302 Temporary Redirect. A switch may be provided later based on the HTTPbis draft that allows clients to convert POST requests to GET requests on 301 and 302 response codes. */ switch (statcode) { case HTTP_STATUS_TEMPORARY_REDIRECT: retval = NEWLOCATION_KEEP_POST; goto cleanup; case HTTP_STATUS_MOVED_PERMANENTLY: if (opt.method && c_strcasecmp (opt.method, "post") != 0) { retval = NEWLOCATION_KEEP_POST; goto cleanup; } break; case HTTP_STATUS_MOVED_TEMPORARILY: if (opt.method && c_strcasecmp (opt.method, "post") != 0) { retval = NEWLOCATION_KEEP_POST; goto cleanup; } break; } retval = NEWLOCATION; goto cleanup; } } set_content_type (dt, type); if (opt.adjust_extension) { if (*dt & TEXTHTML) /* -E / --adjust-extension / adjust_extension = on was specified, and this is a text/html file. If some case-insensitive variation on ".htm[l]" isn't already the file's suffix, tack on ".html". */ { ensure_extension (hs, ".html", dt); } else if (*dt & TEXTCSS) { ensure_extension (hs, ".css", dt); } } if (cond_get) { if (statcode == HTTP_STATUS_NOT_MODIFIED) { logprintf (LOG_VERBOSE, _("File %s not modified on server. Omitting download.\n\n"), quote (hs->local_file)); *dt |= RETROKF; CLOSE_FINISH (sock); retval = RETRUNNEEDED; goto cleanup; } /* Handle the case when server ignores If-Modified-Since header. */ else if (statcode == HTTP_STATUS_OK && hs->remote_time) { time_t tmr = http_atotm (hs->remote_time); /* Check if the local file is up-to-date based on Last-Modified header and content length. */ if (tmr != (time_t) - 1 && tmr <= hs->orig_file_tstamp && (contlen == -1 || contlen == hs->orig_file_size)) { logprintf (LOG_VERBOSE, _("Server ignored If-Modified-Since header for file %s.\n" "You might want to add --no-if-modified-since option." "\n\n"), quote (hs->local_file)); *dt |= RETROKF; CLOSE_INVALIDATE (sock); retval = RETRUNNEEDED; goto cleanup; } } } if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE || (!opt.timestamping && hs->restval > 0 && statcode == HTTP_STATUS_OK && contrange == 0 && contlen >= 0 && hs->restval >= contlen)) { /* If `-c' is in use and the file has been fully downloaded (or the remote file has shrunk), Wget effectively requests bytes after the end of file and the server response with 416 (or 200 with a <= Content-Length. */ logputs (LOG_VERBOSE, _("\ \n The file is already fully retrieved; nothing to do.\n\n")); /* In case the caller inspects. */ hs->len = contlen; hs->res = 0; /* Mark as successfully retrieved. */ *dt |= RETROKF; if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE) CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); /* would be CLOSE_FINISH, but there might be more bytes in the body. */ retval = RETRUNNEEDED; goto cleanup; } if ((contrange != 0 && contrange != hs->restval) || (H_PARTIAL (statcode) && !contrange)) { /* The Range request was somehow misunderstood by the server. Bail out. */ CLOSE_INVALIDATE (sock); retval = RANGEERR; goto cleanup; } if (contlen == -1) hs->contlen = -1; else hs->contlen = contlen + contrange; if (opt.verbose) { if (*dt & RETROKF) { /* No need to print this output if the body won't be downloaded at all, or if the original server response is printed. */ logputs (LOG_VERBOSE, _("Length: ")); if (contlen != -1) { logputs (LOG_VERBOSE, number_to_static_string (contlen + contrange)); if (contlen + contrange >= 1024) logprintf (LOG_VERBOSE, " (%s)", human_readable (contlen + contrange, 10, 1)); if (contrange) { if (contlen >= 1024) logprintf (LOG_VERBOSE, _(", %s (%s) remaining"), number_to_static_string (contlen), human_readable (contlen, 10, 1)); else logprintf (LOG_VERBOSE, _(", %s remaining"), number_to_static_string (contlen)); } } else logputs (LOG_VERBOSE, opt.ignore_length ? _("ignored") : _("unspecified")); if (type) logprintf (LOG_VERBOSE, " [%s]\n", quotearg_style (escape_quoting_style, type)); else logputs (LOG_VERBOSE, "\n"); } } /* Return if we have no intention of further downloading. */ if ((!(*dt & RETROKF) && !opt.content_on_error) || head_only || (opt.spider && !opt.recursive)) { /* In case the caller cares to look... */ hs->len = 0; hs->res = 0; hs->restval = 0; /* Normally we are not interested in the response body of a error responses. But if we are writing a WARC file we are: we like to keep everything. */ if (warc_enabled) { int _err = read_response_body (hs, sock, NULL, contlen, 0, chunked_transfer_encoding, u->url, warc_timestamp_str, warc_request_uuid, warc_ip, type, statcode, head); if (_err != RETRFINISHED || hs->res < 0) { CLOSE_INVALIDATE (sock); retval = _err; goto cleanup; } else CLOSE_FINISH (sock); } else { /* Since WARC is disabled, we are not interested in the response body. */ if (head_only) /* Pre-1.10 Wget used CLOSE_INVALIDATE here. Now we trust the servers not to send body in response to a HEAD request, and those that do will likely be caught by test_socket_open. If not, they can be worked around using `--no-http-keep-alive'. */ CLOSE_FINISH (sock); else if (opt.spider && !opt.recursive) /* we just want to see if the page exists - no downloading required */ CLOSE_INVALIDATE (sock); else if (keep_alive && skip_short_body (sock, contlen, chunked_transfer_encoding)) /* Successfully skipped the body; also keep using the socket. */ CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); } retval = RETRFINISHED; goto cleanup; } err = open_output_stream (hs, count, &fp); if (err != RETROK) { CLOSE_INVALIDATE (sock); retval = err; goto cleanup; } err = read_response_body (hs, sock, fp, contlen, contrange, chunked_transfer_encoding, u->url, warc_timestamp_str, warc_request_uuid, warc_ip, type, statcode, head); if (hs->res >= 0) CLOSE_FINISH (sock); else CLOSE_INVALIDATE (sock); if (!output_stream) fclose (fp); retval = err; cleanup: xfree (head); xfree (type); xfree (message); resp_free (&resp); request_free (&req); return retval; }
1
[ "CWE-200" ]
wget
a933bdd31eee9c956a3b5cc142f004ef1fa94cb3
68,129,138,605,861,870,000,000,000,000,000,000,000
887
Keep fetched URLs in POSIX extended attributes * configure.ac: Check for xattr availability * src/Makefile.am: Add xattr.c * src/ftp.c: Include xattr.h. (getftp): Set attributes if enabled. * src/http.c: Include xattr.h. (gethttp): Add parameter 'original_url', set attributes if enabled. (http_loop): Add 'original_url' to call of gethttp(). * src/init.c: Add new option --xattr. * src/main.c: Add new option --xattr, add description to help text. * src/options.h: Add new config member 'enable_xattr'. * src/xatrr.c: New file. * src/xattr.h: New file. These attributes provide a lightweight method of later determining where a file was downloaded from. This patch changes: * autoconf detects whether extended attributes are available and enables the code if they are. * The new flags --xattr and --no-xattr control whether xattr is enabled. * The new command "xattr = (on|off)" can be used in ~/.wgetrc or /etc/wgetrc * The original and redirected URLs are recorded as shown below. * This works for both single fetches and recursive mode. The attributes that are set are: user.xdg.origin.url: The URL that the content was fetched from. user.xdg.referrer.url: The URL that was originally requested. Here is an example, where http://archive.org redirects to https://archive.org: $ wget --xattr http://archive.org ... $ getfattr -d index.html user.xdg.origin.url="https://archive.org/" user.xdg.referrer.url="http://archive.org/" These attributes were chosen based on those stored by Google Chrome https://bugs.chromium.org/p/chromium/issues/detail?id=45903 and curl https://github.com/curl/curl/blob/master/src/tool_xattr.c
int commit_creds(struct cred *new) { struct task_struct *task = current; const struct cred *old = task->real_cred; kdebug("commit_creds(%p{%d,%d})", new, atomic_read(&new->usage), read_cred_subscribers(new)); BUG_ON(task->cred != old); #ifdef CONFIG_DEBUG_CREDENTIALS BUG_ON(read_cred_subscribers(old) < 2); validate_creds(old); validate_creds(new); #endif BUG_ON(atomic_read(&new->usage) < 1); security_commit_creds(new, old); get_cred(new); /* we will require a ref for the subj creds too */ /* dumpability changes */ if (old->euid != new->euid || old->egid != new->egid || old->fsuid != new->fsuid || old->fsgid != new->fsgid || !cap_issubset(new->cap_permitted, old->cap_permitted)) { if (task->mm) set_dumpable(task->mm, suid_dumpable); task->pdeath_signal = 0; smp_wmb(); } /* alter the thread keyring */ if (new->fsuid != old->fsuid) key_fsuid_changed(task); if (new->fsgid != old->fsgid) key_fsgid_changed(task); /* do it * - What if a process setreuid()'s and this brings the * new uid over his NPROC rlimit? We can check this now * cheaply with the new uid cache, so if it matters * we should be checking for it. -DaveM */ alter_cred_subscribers(new, 2); if (new->user != old->user) atomic_inc(&new->user->processes); rcu_assign_pointer(task->real_cred, new); rcu_assign_pointer(task->cred, new); if (new->user != old->user) atomic_dec(&old->user->processes); alter_cred_subscribers(old, -2); sched_switch_user(task); /* send notifications */ if (new->uid != old->uid || new->euid != old->euid || new->suid != old->suid || new->fsuid != old->fsuid) proc_id_connector(task, PROC_EVENT_UID); if (new->gid != old->gid || new->egid != old->egid || new->sgid != old->sgid || new->fsgid != old->fsgid) proc_id_connector(task, PROC_EVENT_GID); /* release the old obj and subj refs both */ put_cred(old); put_cred(old); return 0; }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
94,552,586,457,730,940,000,000,000,000,000,000,000
74
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
art_pdf_knockoutisolated_group_8(byte *gs_restrict dst, const byte *gs_restrict src, int n_chan) { byte src_alpha; src_alpha = src[n_chan]; if (src_alpha == 0) return; memcpy (dst, src, n_chan + 1); }
0
[ "CWE-476" ]
ghostpdl
7870f4951bcc6a153f317e3439e14d0e929fd231
5,597,657,638,731,474,000,000,000,000,000,000,000
10
Bug 701795: Segv due to image mask issue
TryReuseIndex(Oid oldId, IndexStmt *stmt) { if (CheckIndexCompatible(oldId, stmt->accessMethod, stmt->indexParams, stmt->excludeOpNames)) { Relation irel = index_open(oldId, NoLock); stmt->oldNode = irel->rd_node.relNode; index_close(irel, NoLock); } }
0
[ "CWE-362" ]
postgres
5f173040e324f6c2eebb90d86cf1b0cdb5890f0a
122,370,646,311,058,860,000,000,000,000,000,000,000
13
Avoid repeated name lookups during table and index DDL. If the name lookups come to different conclusions due to concurrent activity, we might perform some parts of the DDL on a different table than other parts. At least in the case of CREATE INDEX, this can be used to cause the permissions checks to be performed against a different table than the index creation, allowing for a privilege escalation attack. This changes the calling convention for DefineIndex, CreateTrigger, transformIndexStmt, transformAlterTableStmt, CheckIndexCompatible (in 9.2 and newer), and AlterTable (in 9.1 and older). In addition, CheckRelationOwnership is removed in 9.2 and newer and the calling convention is changed in older branches. A field has also been added to the Constraint node (FkConstraint in 8.4). Third-party code calling these functions or using the Constraint node will require updating. Report by Andres Freund. Patch by Robert Haas and Andres Freund, reviewed by Tom Lane. Security: CVE-2014-0062
void WebContents::ShowDefinitionForSelection() { #if defined(OS_MAC) auto* const view = web_contents()->GetRenderWidgetHostView(); if (view) view->ShowDefinitionForSelection(); #endif }
0
[ "CWE-200", "CWE-668" ]
electron
07a1c2a3e5845901f7e2eda9506695be58edc73c
2,576,438,849,047,207,000,000,000,000,000,000,000
7
fix: restrict sendToFrame to same-process frames by default (#26875)
static int authorizer(void *autharg, int access_type, const char *arg3, const char *arg4, const char *arg5, const char *arg6) { char *filename; switch (access_type) { case SQLITE_COPY: { TSRMLS_FETCH(); filename = make_filename_safe(arg4 TSRMLS_CC); if (!filename) { return SQLITE_DENY; } efree(filename); return SQLITE_OK; } case SQLITE_ATTACH: { TSRMLS_FETCH(); filename = make_filename_safe(arg3 TSRMLS_CC); if (!filename) { return SQLITE_DENY; } efree(filename); return SQLITE_OK; } default: /* access allowed */ return SQLITE_OK; } }
0
[ "CWE-264" ]
php-src
055ecbc62878e86287d742c7246c21606cee8183
303,763,357,347,626,400,000,000,000,000,000,000,000
30
Improve check for :memory: pseudo-filename in SQlite
void ide_atapi_cmd(IDEState *s) { uint8_t *buf = s->io_buffer; const struct AtapiCmd *cmd = &atapi_cmd_table[s->io_buffer[0]]; trace_ide_atapi_cmd(s, s->io_buffer[0]); if (trace_event_get_state_backends(TRACE_IDE_ATAPI_CMD_PACKET)) { /* Each pretty-printed byte needs two bytes and a space; */ char *ppacket = g_malloc(ATAPI_PACKET_SIZE * 3 + 1); int i; for (i = 0; i < ATAPI_PACKET_SIZE; i++) { sprintf(ppacket + (i * 3), "%02x ", buf[i]); } trace_ide_atapi_cmd_packet(s, s->lcyl | (s->hcyl << 8), ppacket); g_free(ppacket); } /* * If there's a UNIT_ATTENTION condition pending, only command flagged with * ALLOW_UA are allowed to complete. with other commands getting a CHECK * condition response unless a higher priority status, defined by the drive * here, is pending. */ if (s->sense_key == UNIT_ATTENTION && !(cmd->flags & ALLOW_UA)) { ide_atapi_cmd_check_status(s); return; } /* * When a CD gets changed, we have to report an ejected state and * then a loaded state to guests so that they detect tray * open/close and media change events. Guests that do not use * GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close * states rely on this behavior. */ if (!(cmd->flags & ALLOW_UA) && !s->tray_open && blk_is_inserted(s->blk) && s->cdrom_changed) { if (s->cdrom_changed == 1) { ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT); s->cdrom_changed = 2; } else { ide_atapi_cmd_error(s, UNIT_ATTENTION, ASC_MEDIUM_MAY_HAVE_CHANGED); s->cdrom_changed = 0; } return; } /* Report a Not Ready condition if appropriate for the command */ if ((cmd->flags & CHECK_READY) && (!media_present(s) || !blk_is_inserted(s->blk))) { ide_atapi_cmd_error(s, NOT_READY, ASC_MEDIUM_NOT_PRESENT); return; } /* Commands that don't transfer DATA permit the byte_count_limit to be 0. * If this is a data-transferring PIO command and BCL is 0, * we abort at the /ATA/ level, not the ATAPI level. * See ATA8 ACS3 section 7.17.6.49 and 7.21.5 */ if (cmd->handler && !(cmd->flags & (NONDATA | CONDDATA))) { if (!validate_bcl(s)) { return; } } /* Execute the command */ if (cmd->handler) { cmd->handler(s, buf); return; } ide_atapi_cmd_error(s, ILLEGAL_REQUEST, ASC_ILLEGAL_OPCODE); }
0
[ "CWE-125" ]
qemu
813212288970c39b1800f63e83ac6e96588095c6
19,928,936,687,698,074,000,000,000,000,000,000,000
75
ide: atapi: assert that the buffer pointer is in range A case was reported where s->io_buffer_index can be out of range. The report skimped on the details but it seems to be triggered by s->lba == -1 on the READ/READ CD paths (e.g. by sending an ATAPI command with LBA = 0xFFFFFFFF). For now paper over it with assertions. The first one ensures that there is no overflow when incrementing s->io_buffer_index, the second checks for the buffer overrun. Note that the buffer overrun is only a read, so I am not sure if the assertion failure is actually less harmful than the overrun. Signed-off-by: Paolo Bonzini <[email protected]> Message-id: [email protected] Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
move_folder_response_cb (ESoapResponse *response, GSimpleAsyncResult *simple) { ESoapParameter *param; ESoapParameter *subparam; GError *error = NULL; param = e_soap_response_get_first_parameter_by_name ( response, "ResponseMessages", &error); /* Sanity check */ g_return_if_fail ( (param != NULL && error == NULL) || (param == NULL && error != NULL)); if (error != NULL) { g_simple_async_result_take_error (simple, error); return; } subparam = e_soap_parameter_get_first_child (param); while (subparam != NULL) { if (!ews_get_response_status (subparam, &error)) { g_simple_async_result_take_error (simple, error); return; } subparam = e_soap_parameter_get_next_child (subparam); } }
0
[ "CWE-295" ]
evolution-ews
915226eca9454b8b3e5adb6f2fff9698451778de
282,156,061,151,960,160,000,000,000,000,000,000,000
31
I#27 - SSL Certificates are not validated This depends on https://gitlab.gnome.org/GNOME/evolution-data-server/commit/6672b8236139bd6ef41ecb915f4c72e2a052dba5 too. Closes https://gitlab.gnome.org/GNOME/evolution-ews/issues/27
int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, struct kvm_translation *tr) { return -EINVAL; }
0
[ "CWE-20" ]
linux
d26c25a9d19b5976b319af528886f89cf455692d
190,544,590,983,721,320,000,000,000,000,000,000,000
5
arm64: KVM: Tighten guest core register access from userspace We currently allow userspace to access the core register file in about any possible way, including straddling multiple registers and doing unaligned accesses. This is not the expected use of the ABI, and nobody is actually using it that way. Let's tighten it by explicitly checking the size and alignment for each field of the register file. Cc: <[email protected]> Fixes: 2f4a07c5f9fe ("arm64: KVM: guest one-reg interface") Reviewed-by: Christoffer Dall <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Signed-off-by: Dave Martin <[email protected]> [maz: rewrote Dave's initial patch to be more easily backported] Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Will Deacon <[email protected]>
static void php_openssl_pkey_free(zend_resource *rsrc) { EVP_PKEY *pkey = (EVP_PKEY *)rsrc->ptr; assert(pkey != NULL); EVP_PKEY_free(pkey); }
0
[ "CWE-326" ]
php-src
0216630ea2815a5789a24279a1211ac398d4de79
318,374,811,098,167,560,000,000,000,000,000,000,000
8
Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
static int php_skip_variable(php_stream * stream TSRMLS_DC) { off_t length = ((unsigned int)php_read2(stream TSRMLS_CC)); if (length < 2) { return 0; } length = length - 2; php_stream_seek(stream, (long)length, SEEK_CUR); return 1; }
0
[]
php-src
87829c09a1d9e39bee994460d7ccf19dd20eda14
197,036,113,786,177,900,000,000,000,000,000,000,000
11
Fix #70052: getimagesize() fails for very large and very small WBMP Very large WBMP (width or height greater than 2**31-1) cause an overflow and circumvent the size limitation of 2048x2048 px. Very small WBMP (less than 12 bytes) cause a read error and are not recognized. This patch fixes both bugs.
Fty make_adaptor(F fn, R (F::*)(SemanticValues &sv, any &dt) const) { return TypeAdaptor_sv_dt<R>(fn); }
0
[ "CWE-125" ]
cpp-peglib
b3b29ce8f3acf3a32733d930105a17d7b0ba347e
227,718,920,543,560,900,000,000,000,000,000,000,000
3
Fix #122
TEST_F(Http1ServerConnectionImplTest, HeaderMutateEmbeddedNul) { const std::string example_input = "GET / HTTP/1.1\r\nHOST: h.com\r\nfoo: barbaz\r\n"; for (size_t n = 1; n < example_input.size(); ++n) { initialize(); InSequence sequence; MockRequestDecoder decoder; EXPECT_CALL(callbacks_, newStream(_, _)).WillOnce(ReturnRef(decoder)); Buffer::OwnedImpl buffer( absl::StrCat(example_input.substr(0, n), std::string(1, '\0'), example_input.substr(n))); EXPECT_CALL(decoder, sendLocalReply(_, _, _, _, _, _, _)); auto status = codec_->dispatch(buffer); EXPECT_FALSE(status.ok()); EXPECT_TRUE(isCodecProtocolError(status)); EXPECT_THAT(status.message(), testing::HasSubstr("http/1.1 protocol error:")); } }
0
[ "CWE-770" ]
envoy
7ca28ff7d46454ae930e193d97b7d08156b1ba59
190,795,993,405,011,960,000,000,000,000,000,000,000
20
[http1] Include request URL in request header size computation, and reject partial headers that exceed configured limits (#145) Signed-off-by: antonio <[email protected]>
optional<Service> to_service(const smatch::value_type& s, bool wildcards) { static const unordered_map<string, Service> services = { { "acm", Service::acm }, { "apigateway", Service::apigateway }, { "appstream", Service::appstream }, { "artifact", Service::artifact }, { "autoscaling", Service::autoscaling }, { "aws-marketplace", Service::aws_marketplace }, { "aws-marketplace-management", Service::aws_marketplace_management }, { "aws-portal", Service::aws_portal }, { "cloudformation", Service::cloudformation }, { "cloudfront", Service::cloudfront }, { "cloudhsm", Service::cloudhsm }, { "cloudsearch", Service::cloudsearch }, { "cloudtrail", Service::cloudtrail }, { "cloudwatch", Service::cloudwatch }, { "codebuild", Service::codebuild }, { "codecommit", Service::codecommit }, { "codedeploy", Service::codedeploy }, { "codepipeline", Service::codepipeline }, { "cognito-identity", Service::cognito_identity }, { "cognito-idp", Service::cognito_idp }, { "cognito-sync", Service::cognito_sync }, { "config", Service::config }, { "datapipeline", Service::datapipeline }, { "devicefarm", Service::devicefarm }, { "directconnect", Service::directconnect }, { "dms", Service::dms }, { "ds", Service::ds }, { "dynamodb", Service::dynamodb }, { "ec2", Service::ec2 }, { "ecr", Service::ecr }, { "ecs", Service::ecs }, { "elasticache", Service::elasticache }, { "elasticbeanstalk", Service::elasticbeanstalk }, { "elasticfilesystem", Service::elasticfilesystem }, { "elasticloadbalancing", Service::elasticloadbalancing }, { "elasticmapreduce", Service::elasticmapreduce }, { "elastictranscoder", Service::elastictranscoder }, { "es", Service::es }, { "events", Service::events }, { "firehose", Service::firehose }, { "gamelift", Service::gamelift }, { "glacier", Service::glacier }, { "health", Service::health }, { "iam", Service::iam }, { "importexport", Service::importexport }, { "inspector", Service::inspector }, { "iot", Service::iot }, { "kinesis", Service::kinesis }, { "kinesisanalytics", Service::kinesisanalytics }, { "kms", Service::kms }, { "lambda", Service::lambda }, { "lightsail", Service::lightsail }, { "logs", Service::logs }, { "machinelearning", Service::machinelearning }, { "mobileanalytics", Service::mobileanalytics }, { "mobilehub", Service::mobilehub }, { "opsworks", Service::opsworks }, { "opsworks-cm", Service::opsworks_cm }, { "polly", Service::polly }, { "rds", Service::rds }, { "redshift", Service::redshift }, { "route53", Service::route53 }, { "route53domains", Service::route53domains }, { "s3", Service::s3 }, { "sdb", Service::sdb }, { "servicecatalog", Service::servicecatalog }, { "ses", Service::ses }, { "sns", Service::sns }, { "sqs", Service::sqs }, { "ssm", Service::ssm }, { "states", Service::states }, { "storagegateway", Service::storagegateway }, { "sts", Service::sts }, { "support", Service::support }, { "swf", Service::swf }, { "trustedadvisor", Service::trustedadvisor }, { "waf", Service::waf }, { "workmail", Service::workmail }, { "workspaces", Service::workspaces }}; if (wildcards && s == "*") { return Service::wildcard; } auto i = services.find(s); if (i == services.end()) { return none; } else { return i->second; } }
0
[ "CWE-617" ]
ceph
b3118cabb8060a8cc6a01c4e8264cb18e7b1745a
88,664,768,133,609,850,000,000,000,000,000,000,000
95
rgw: Remove assertions in IAM Policy A couple of them could be triggered by user input. Signed-off-by: Adam C. Emerson <[email protected]>
void WebPImage::printStructure(std::ostream& out, PrintStructureOption option,int depth) { if (io_->open() != 0) { throw Error(kerDataSourceOpenFailed, io_->path(), strError()); } // Ensure this is the correct image type if (!isWebPType(*io_, true)) { if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData); throw Error(kerNotAnImage, "WEBP"); } bool bPrint = option==kpsBasic || option==kpsRecursive; if ( bPrint || option == kpsXMP || option == kpsIccProfile || option == kpsIptcErase ) { byte data [WEBP_TAG_SIZE * 2]; io_->read(data, WEBP_TAG_SIZE * 2); uint64_t filesize = Exiv2::getULong(data + WEBP_TAG_SIZE, littleEndian); DataBuf chunkId(5) ; chunkId.pData_[4] = '\0' ; if ( bPrint ) { out << Internal::indent(depth) << "STRUCTURE OF WEBP FILE: " << io().path() << std::endl; out << Internal::indent(depth) << Internal::stringFormat(" Chunk | Length | Offset | Payload") << std::endl; } io_->seek(0,BasicIo::beg); // rewind while ( !io_->eof() && (uint64_t) io_->tell() < filesize) { uint64_t offset = (uint64_t) io_->tell(); byte size_buff[WEBP_TAG_SIZE]; io_->read(chunkId.pData_, WEBP_TAG_SIZE); io_->read(size_buff, WEBP_TAG_SIZE); long size = Exiv2::getULong(size_buff, littleEndian); DataBuf payload(offset?size:WEBP_TAG_SIZE); // header is different from chunks io_->read(payload.pData_, payload.size_); if ( bPrint ) { out << Internal::indent(depth) << Internal::stringFormat(" %s | %8u | %8u | ", (const char*)chunkId.pData_,(uint32_t)size,(uint32_t)offset) << Internal::binaryToString(makeSlice(payload, 0, payload.size_ > 32 ? 32 : payload.size_)) << std::endl; } if ( equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_EXIF) && option==kpsRecursive ) { // create memio object with the payload, then print the structure BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(payload.pData_,payload.size_)); printTiffStructure(*p,out,option,depth); } bool bPrintPayload = (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_XMP) && option==kpsXMP) || (equalsWebPTag(chunkId, WEBP_CHUNK_HEADER_ICCP) && option==kpsIccProfile) ; if ( bPrintPayload ) { out.write((const char*) payload.pData_,payload.size_); } if ( offset && io_->tell() % 2 ) io_->seek(+1, BasicIo::cur); // skip padding byte on sub-chunks } } }
0
[ "CWE-190" ]
exiv2
caa4e6745a76a23bb80127cf54c0d65096ae684c
225,271,384,535,611,030,000,000,000,000,000,000,000
63
Avoid negative integer overflow when `filesize < io_->tell()`. This fixes #791.
static void insert_to_mm_slots_hash(struct mm_struct *mm, struct mm_slot *mm_slot) { struct hlist_head *bucket; bucket = &mm_slots_hash[((unsigned long)mm / sizeof(struct mm_struct)) % MM_SLOTS_HASH_HEADS]; mm_slot->mm = mm; hlist_add_head(&mm_slot->hash, bucket); }
0
[ "CWE-399" ]
linux
78f11a255749d09025f54d4e2df4fbcb031530e2
274,860,300,204,544,500,000,000,000,000,000,000,000
10
mm: thp: fix /dev/zero MAP_PRIVATE and vm_flags cleanups The huge_memory.c THP page fault was allowed to run if vm_ops was null (which would succeed for /dev/zero MAP_PRIVATE, as the f_op->mmap wouldn't setup a special vma->vm_ops and it would fallback to regular anonymous memory) but other THP logics weren't fully activated for vmas with vm_file not NULL (/dev/zero has a not NULL vma->vm_file). So this removes the vm_file checks so that /dev/zero also can safely use THP (the other albeit safer approach to fix this bug would have been to prevent the THP initial page fault to run if vm_file was set). After removing the vm_file checks, this also makes huge_memory.c stricter in khugepaged for the DEBUG_VM=y case. It doesn't replace the vm_file check with a is_pfn_mapping check (but it keeps checking for VM_PFNMAP under VM_BUG_ON) because for a is_cow_mapping() mapping VM_PFNMAP should only be allowed to exist before the first page fault, and in turn when vma->anon_vma is null (so preventing khugepaged registration). So I tend to think the previous comment saying if vm_file was set, VM_PFNMAP might have been set and we could still be registered in khugepaged (despite anon_vma was not NULL to be registered in khugepaged) was too paranoid. The is_linear_pfn_mapping check is also I think superfluous (as described by comment) but under DEBUG_VM it is safe to stay. Addresses https://bugzilla.kernel.org/show_bug.cgi?id=33682 Signed-off-by: Andrea Arcangeli <[email protected]> Reported-by: Caspar Zhang <[email protected]> Acked-by: Mel Gorman <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: <[email protected]> [2.6.38.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn, const char *reason) { struct tevent_req *subreq; if (conn->limits.reason) { return; } DLIST_REMOVE(conn->service->connections, conn); conn->limits.endtime = timeval_current_ofs(0, 500); tevent_queue_stop(conn->sockets.send_queue); TALLOC_FREE(conn->sockets.read_req); TALLOC_FREE(conn->deferred_expire_disconnect); if (conn->active_call) { tevent_req_cancel(conn->active_call); conn->active_call = NULL; } conn->limits.reason = talloc_strdup(conn, reason); if (conn->limits.reason == NULL) { TALLOC_FREE(conn->sockets.tls); TALLOC_FREE(conn->sockets.sasl); TALLOC_FREE(conn->sockets.raw); stream_terminate_connection(conn->connection, reason); return; } subreq = tstream_disconnect_send(conn, conn->connection->event.ctx, conn->sockets.active); if (subreq == NULL) { TALLOC_FREE(conn->sockets.tls); TALLOC_FREE(conn->sockets.sasl); TALLOC_FREE(conn->sockets.raw); stream_terminate_connection(conn->connection, reason); return; } tevent_req_set_endtime(subreq, conn->connection->event.ctx, conn->limits.endtime); tevent_req_set_callback(subreq, ldapsrv_terminate_connection_done, conn); }
0
[ "CWE-703" ]
samba
f9b2267c6eb8138fc94df7a138ad5d87526f1d79
89,896,492,431,690,800,000,000,000,000,000,000,000
45
CVE-2021-3670 ldap_server: Ensure value of MaxQueryDuration is greater than zero BUG: https://bugzilla.samba.org/show_bug.cgi?id=14694 Signed-off-by: Joseph Sutton <[email protected]> Reviewed-by: Douglas Bagnall <[email protected]> (cherry picked from commit e1ab0c43629686d1d2c0b0b2bcdc90057a792049)
static void nfc_check_pres_work(struct work_struct *work) { struct nfc_dev *dev = container_of(work, struct nfc_dev, check_pres_work); int rc; device_lock(&dev->dev); if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) { rc = dev->ops->check_presence(dev, dev->active_target); if (rc == -EOPNOTSUPP) goto exit; if (rc) { u32 active_target_idx = dev->active_target->idx; device_unlock(&dev->dev); nfc_target_lost(dev, active_target_idx); return; } if (!dev->shutting_down) mod_timer(&dev->check_pres_timer, jiffies + msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); } exit: device_unlock(&dev->dev); }
0
[]
linux
3e3b5dfcd16a3e254aab61bd1e8c417dd4503102
251,705,337,139,588,530,000,000,000,000,000,000,000
27
NFC: reorder the logic in nfc_{un,}register_device There is a potential UAF between the unregistration routine and the NFC netlink operations. The race that cause that UAF can be shown as below: (FREE) | (USE) nfcmrvl_nci_unregister_dev | nfc_genl_dev_up nci_close_device | nci_unregister_device | nfc_get_device nfc_unregister_device | nfc_dev_up rfkill_destory | device_del | rfkill_blocked ... | ... The root cause for this race is concluded below: 1. The rfkill_blocked (USE) in nfc_dev_up is supposed to be placed after the device_is_registered check. 2. Since the netlink operations are possible just after the device_add in nfc_register_device, the nfc_dev_up() can happen anywhere during the rfkill creation process, which leads to data race. This patch reorder these actions to permit 1. Once device_del is finished, the nfc_dev_up cannot dereference the rfkill object. 2. The rfkill_register need to be placed after the device_add of nfc_dev because the parent device need to be created first. So this patch keeps the order but inject device_lock to prevent the data race. Signed-off-by: Lin Ma <[email protected]> Fixes: be055b2f89b5 ("NFC: RFKILL support") Reviewed-by: Jakub Kicinski <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
jd_utc_to_local(int jd, int df, int of) { df += of; if (df < 0) jd -= 1; else if (df >= DAY_IN_SECONDS) jd += 1; return jd; }
0
[]
date
3959accef8da5c128f8a8e2fd54e932a4fb253b0
269,473,654,386,084,650,000,000,000,000,000,000,000
9
Add length limit option for methods that parses date strings `Date.parse` now raises an ArgumentError when a given date string is longer than 128. You can configure the limit by giving `limit` keyword arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`, the limit is disabled. Not only `Date.parse` but also the following methods are changed. * Date._parse * Date.parse * DateTime.parse * Date._iso8601 * Date.iso8601 * DateTime.iso8601 * Date._rfc3339 * Date.rfc3339 * DateTime.rfc3339 * Date._xmlschema * Date.xmlschema * DateTime.xmlschema * Date._rfc2822 * Date.rfc2822 * DateTime.rfc2822 * Date._rfc822 * Date.rfc822 * DateTime.rfc822 * Date._jisx0301 * Date.jisx0301 * DateTime.jisx0301
static double mp_list_Joff(_cimg_math_parser& mp) { double *ptrd = &_mp_arg(1) + 1; const unsigned int ind = (unsigned int)cimg::mod((int)_mp_arg(2),mp.listin.width()), boundary_conditions = (unsigned int)_mp_arg(4), vsiz = (unsigned int)mp.opcode[5]; const int ox = (int)mp.mem[_cimg_mp_slot_x], oy = (int)mp.mem[_cimg_mp_slot_y], oz = (int)mp.mem[_cimg_mp_slot_z]; const CImg<T> &img = mp.listin[ind]; const longT off = img.offset(ox,oy,oz) + (longT)_mp_arg(3), whd = (longT)img.width()*img.height()*img.depth(); const T *ptrs; if (off>=0 && off<whd) { ptrs = &img[off]; cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; } return cimg::type<double>::nan(); } if (img._data) switch (boundary_conditions) { case 3 : { // Mirror const longT whd2 = 2*whd, moff = cimg::mod(off,whd2); ptrs = &img[moff<whd?moff:whd2 - moff - 1]; cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; } return cimg::type<double>::nan(); } case 2 : // Periodic ptrs = &img[cimg::mod(off,whd)]; cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; } return cimg::type<double>::nan(); case 1 : // Neumann ptrs = off<0?&img[0]:&img[whd - 1]; cimg_for_inC(img,0,vsiz - 1,c) { *(ptrd++) = *ptrs; ptrs+=whd; } return cimg::type<double>::nan(); default : // Dirichlet std::memset(ptrd,0,vsiz*sizeof(double)); return cimg::type<double>::nan(); } std::memset(ptrd,0,vsiz*sizeof(double)); return cimg::type<double>::nan();
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
267,801,381,430,732,260,000,000,000,000,000,000,000
40
Fix other issues in 'CImg<T>::load_bmp()'.
static int ZEND_FASTCALL ZEND_SL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; shift_left_function(&EX_T(opline->result.u.var).tmp_var, _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC), _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) TSRMLS_CC); zval_dtor(free_op1.var); zval_dtor(free_op2.var); ZEND_VM_NEXT_OPCODE(); }
0
[]
php-src
ce96fd6b0761d98353761bf78d5bfb55291179fd
219,759,921,821,275,500,000,000,000,000,000,000,000
12
- 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
copyFromFrameBuffer (char *& writePtr, const char *& readPtr, const char * endPtr, size_t xStride, Compressor::Format format, PixelType type) { char * localWritePtr = writePtr; const char * localReadPtr = readPtr; // // Copy a horizontal row of pixels from a frame // buffer to an output file's line or tile buffer. // if (format == Compressor::XDR) { // // The the line or tile buffer is in XDR format. // switch (type) { case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT: while (localReadPtr <= endPtr) { Xdr::write <CharPtrIO> (localWritePtr, *(const unsigned int *) localReadPtr); localReadPtr += xStride; } break; case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF: while (localReadPtr <= endPtr) { Xdr::write <CharPtrIO> (localWritePtr, *(const half *) localReadPtr); localReadPtr += xStride; } break; case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT: while (localReadPtr <= endPtr) { Xdr::write <CharPtrIO> (localWritePtr, *(const float *) localReadPtr); localReadPtr += xStride; } break; default: throw IEX_NAMESPACE::ArgExc ("Unknown pixel data type."); } } else { // // The the line or tile buffer is in NATIVE format. // switch (type) { case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT: while (localReadPtr <= endPtr) { for (size_t i = 0; i < sizeof (unsigned int); ++i) *localWritePtr++ = localReadPtr[i]; localReadPtr += xStride; } break; case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF: while (localReadPtr <= endPtr) { *(half *) localWritePtr = *(const half *) localReadPtr; localWritePtr += sizeof (half); localReadPtr += xStride; } break; case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT: while (localReadPtr <= endPtr) { for (size_t i = 0; i < sizeof (float); ++i) *localWritePtr++ = localReadPtr[i]; localReadPtr += xStride; } break; default: throw IEX_NAMESPACE::ArgExc ("Unknown pixel data type."); } } writePtr = localWritePtr; readPtr = localReadPtr; }
0
[ "CWE-190" ]
openexr
5db6f7aee79e3e75e8c3780b18b28699614dd08e
257,332,699,971,040,970,000,000,000,000,000,000,000
104
prevent overflow in bytesPerDeepLineTable (#1152) * prevent overflow in bytesPerDeepLineTable Signed-off-by: Peter Hillman <[email protected]> * restore zapped 'const' from ImfMisc Signed-off-by: Peter Hillman <[email protected]>
optimize_utf8 (re_dfa_t *dfa) { Idx node; int i; bool mb_chars = false; bool has_period = false; for (node = 0; node < dfa->nodes_len; ++node) switch (dfa->nodes[node].type) { case CHARACTER: if (dfa->nodes[node].opr.c >= ASCII_CHARS) mb_chars = true; break; case ANCHOR: switch (dfa->nodes[node].opr.ctx_type) { case LINE_FIRST: case LINE_LAST: case BUF_FIRST: case BUF_LAST: break; default: /* Word anchors etc. cannot be handled. It's okay to test opr.ctx_type since constraints (for all DFA nodes) are created by ORing one or more opr.ctx_type values. */ return; } break; case OP_PERIOD: has_period = true; break; case OP_BACK_REF: case OP_ALT: case END_OF_RE: case OP_DUP_ASTERISK: case OP_OPEN_SUBEXP: case OP_CLOSE_SUBEXP: break; case COMPLEX_BRACKET: return; case SIMPLE_BRACKET: /* Just double check. */ { int rshift = (ASCII_CHARS % BITSET_WORD_BITS == 0 ? 0 : BITSET_WORD_BITS - ASCII_CHARS % BITSET_WORD_BITS); for (i = ASCII_CHARS / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) { if (dfa->nodes[node].opr.sbcset[i] >> rshift != 0) return; rshift = 0; } } break; default: abort (); } if (mb_chars || has_period) for (node = 0; node < dfa->nodes_len; ++node) { if (dfa->nodes[node].type == CHARACTER && dfa->nodes[node].opr.c >= ASCII_CHARS) dfa->nodes[node].mb_partial = 0; else if (dfa->nodes[node].type == OP_PERIOD) dfa->nodes[node].type = OP_UTF8_PERIOD; } /* The search can be in single byte locale. */ dfa->mb_cur_max = 1; dfa->is_utf8 = 0; dfa->has_mb_node = dfa->nbackref > 0 || has_period; }
0
[ "CWE-19" ]
gnulib
5513b40999149090987a0341c018d05d3eea1272
292,279,800,397,329,470,000,000,000,000,000,000,000
74
Diagnose ERE '()|\1' Problem reported by Hanno Böck in: http://bugs.gnu.org/21513 * lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep track of the set of previously-completed subexpressions available before the first alternative, and restore this set just before parsing each subsequent alternative. This lets us diagnose the invalid back-reference in the ERE '()|\1'.
komeda_wb_init_data_flow(struct komeda_layer *wb_layer, struct drm_connector_state *conn_st, struct komeda_crtc_state *kcrtc_st, struct komeda_data_flow_cfg *dflow) { struct drm_framebuffer *fb = conn_st->writeback_job->fb; memset(dflow, 0, sizeof(*dflow)); dflow->out_w = fb->width; dflow->out_h = fb->height; /* the write back data comes from the compiz */ pipeline_composition_size(kcrtc_st, &dflow->in_w, &dflow->in_h); dflow->input.component = &wb_layer->base.pipeline->compiz->base; /* compiz doesn't output alpha */ dflow->pixel_blend_mode = DRM_MODE_BLEND_PIXEL_NONE; dflow->rot = DRM_MODE_ROTATE_0; komeda_complete_data_flow_cfg(wb_layer, dflow, fb); return 0; }
0
[ "CWE-401" ]
linux
a0ecd6fdbf5d648123a7315c695fb6850d702835
213,637,532,498,926,400,000,000,000,000,000,000,000
23
drm/komeda: prevent memory leak in komeda_wb_connector_add In komeda_wb_connector_add if drm_writeback_connector_init fails the allocated memory for kwb_conn should be released. Signed-off-by: Navid Emamdoost <[email protected]> Reviewed-by: James Qian Wang (Arm Technology China) <[email protected]> Signed-off-by: james qian wang (Arm Technology China) <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
TEST_F(AccessControlTest, validate_partition_access_fail_on_not_subpartition) { topic_name = "HelloWorldTopic_multiple_partition"; partitions.push_back("Partition1"); partitions.push_back("Partition5"); RTPSParticipantAttributes subscriber_participant_attr; fill_subscriber_participant_security_attributes(subscriber_participant_attr); check_local_datareader(subscriber_participant_attr, false); check_remote_datareader(subscriber_participant_attr, false); RTPSParticipantAttributes publisher_participant_attr; fill_publisher_participant_security_attributes(publisher_participant_attr); check_local_datawriter(publisher_participant_attr, false); check_remote_datawriter(publisher_participant_attr, false); }
0
[ "CWE-284" ]
Fast-DDS
d2aeab37eb4fad4376b68ea4dfbbf285a2926384
204,694,366,065,051,900,000,000,000,000,000,000,000
16
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 int unit_add_mount_dependencies(Unit *u) { UnitDependencyInfo di; const char *path; Iterator i; int r; assert(u); HASHMAP_FOREACH_KEY(di.data, path, u->requires_mounts_for, i) { char prefix[strlen(path) + 1]; PATH_FOREACH_PREFIX_MORE(prefix, path) { _cleanup_free_ char *p = NULL; Unit *m; r = unit_name_from_path(prefix, ".mount", &p); if (r < 0) return r; m = manager_get_unit(u->manager, p); if (!m) { /* Make sure to load the mount unit if * it exists. If so the dependencies * on this unit will be added later * during the loading of the mount * unit. */ (void) manager_load_unit_prepare(u->manager, p, NULL, NULL, &m); continue; } if (m == u) continue; if (m->load_state != UNIT_LOADED) continue; r = unit_add_dependency(u, UNIT_AFTER, m, true, di.origin_mask); if (r < 0) return r; if (m->fragment_path) { r = unit_add_dependency(u, UNIT_REQUIRES, m, true, di.origin_mask); if (r < 0) return r; } } } return 0; }
0
[ "CWE-269" ]
systemd
bf65b7e0c9fc215897b676ab9a7c9d1c688143ba
259,724,286,036,519,800,000,000,000,000,000,000,000
49
core: imply NNP and SUID/SGID restriction for DynamicUser=yes service Let's be safe, rather than sorry. This way DynamicUser=yes services can neither take benefit of, nor create SUID/SGID binaries. Given that DynamicUser= is a recent addition only we should be able to get away with turning this on, even though this is strictly speaking a binary compatibility breakage.