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
|
---|---|---|---|---|---|---|---|
MagickExport Image *MeanShiftImage(const Image *image,const size_t width,
const size_t height,const double color_distance,ExceptionInfo *exception)
{
#define MaxMeanShiftIterations 100
#define MeanShiftImageTag "MeanShift/Image"
CacheView
*image_view,
*mean_view,
*pixel_view;
Image
*mean_image;
MagickBooleanType
status;
MagickOffsetType
progress;
ssize_t
y;
assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
mean_image=CloneImage(image,0,0,MagickTrue,exception);
if (mean_image == (Image *) NULL)
return((Image *) NULL);
if (SetImageStorageClass(mean_image,DirectClass,exception) == MagickFalse)
{
mean_image=DestroyImage(mean_image);
return((Image *) NULL);
}
status=MagickTrue;
progress=0;
image_view=AcquireVirtualCacheView(image,exception);
pixel_view=AcquireVirtualCacheView(image,exception);
mean_view=AcquireAuthenticCacheView(mean_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status,progress) \
magick_number_threads(mean_image,mean_image,mean_image->rows,1)
#endif
for (y=0; y < (ssize_t) mean_image->rows; y++)
{
register const Quantum
*magick_restrict p;
register Quantum
*magick_restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
q=GetCacheViewAuthenticPixels(mean_view,0,y,mean_image->columns,1,
exception);
if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) mean_image->columns; x++)
{
PixelInfo
mean_pixel,
previous_pixel;
PointInfo
mean_location,
previous_location;
register ssize_t
i;
GetPixelInfo(image,&mean_pixel);
GetPixelInfoPixel(image,p,&mean_pixel);
mean_location.x=(double) x;
mean_location.y=(double) y;
for (i=0; i < MaxMeanShiftIterations; i++)
{
double
distance,
gamma;
PixelInfo
sum_pixel;
PointInfo
sum_location;
ssize_t
count,
v;
sum_location.x=0.0;
sum_location.y=0.0;
GetPixelInfo(image,&sum_pixel);
previous_location=mean_location;
previous_pixel=mean_pixel;
count=0;
for (v=(-((ssize_t) height/2)); v <= (((ssize_t) height/2)); v++)
{
ssize_t
u;
for (u=(-((ssize_t) width/2)); u <= (((ssize_t) width/2)); u++)
{
if ((v*v+u*u) <= (ssize_t) ((width/2)*(height/2)))
{
PixelInfo
pixel;
status=GetOneCacheViewVirtualPixelInfo(pixel_view,(ssize_t)
MagickRound(mean_location.x+u),(ssize_t) MagickRound(
mean_location.y+v),&pixel,exception);
distance=(mean_pixel.red-pixel.red)*(mean_pixel.red-pixel.red)+
(mean_pixel.green-pixel.green)*(mean_pixel.green-pixel.green)+
(mean_pixel.blue-pixel.blue)*(mean_pixel.blue-pixel.blue);
if (distance <= (color_distance*color_distance))
{
sum_location.x+=mean_location.x+u;
sum_location.y+=mean_location.y+v;
sum_pixel.red+=pixel.red;
sum_pixel.green+=pixel.green;
sum_pixel.blue+=pixel.blue;
sum_pixel.alpha+=pixel.alpha;
count++;
}
}
}
}
gamma=PerceptibleReciprocal(count);
mean_location.x=gamma*sum_location.x;
mean_location.y=gamma*sum_location.y;
mean_pixel.red=gamma*sum_pixel.red;
mean_pixel.green=gamma*sum_pixel.green;
mean_pixel.blue=gamma*sum_pixel.blue;
mean_pixel.alpha=gamma*sum_pixel.alpha;
distance=(mean_location.x-previous_location.x)*
(mean_location.x-previous_location.x)+
(mean_location.y-previous_location.y)*
(mean_location.y-previous_location.y)+
255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)*
255.0*QuantumScale*(mean_pixel.red-previous_pixel.red)+
255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)*
255.0*QuantumScale*(mean_pixel.green-previous_pixel.green)+
255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue)*
255.0*QuantumScale*(mean_pixel.blue-previous_pixel.blue);
if (distance <= 3.0)
break;
}
SetPixelRed(mean_image,ClampToQuantum(mean_pixel.red),q);
SetPixelGreen(mean_image,ClampToQuantum(mean_pixel.green),q);
SetPixelBlue(mean_image,ClampToQuantum(mean_pixel.blue),q);
SetPixelAlpha(mean_image,ClampToQuantum(mean_pixel.alpha),q);
p+=GetPixelChannels(image);
q+=GetPixelChannels(mean_image);
}
if (SyncCacheViewAuthenticPixels(mean_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp atomic
#endif
progress++;
proceed=SetImageProgress(image,MeanShiftImageTag,progress,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
mean_view=DestroyCacheView(mean_view);
pixel_view=DestroyCacheView(pixel_view);
image_view=DestroyCacheView(image_view);
return(mean_image);
}
| 0 |
[
"CWE-369"
] |
ImageMagick
|
a77d8d97f5a7bced0468f0b08798c83fb67427bc
| 103,684,703,199,316,320,000,000,000,000,000,000,000 | 185 |
https://github.com/ImageMagick/ImageMagick/issues/1552
|
static void __io_poll_flush(struct io_ring_ctx *ctx, struct llist_node *nodes)
{
struct io_kiocb *req, *tmp;
struct req_batch rb;
rb.to_free = rb.need_iter = 0;
spin_lock_irq(&ctx->completion_lock);
llist_for_each_entry_safe(req, tmp, nodes, llist_node) {
hash_del(&req->hash_node);
io_poll_complete(req, req->result, 0);
if (refcount_dec_and_test(&req->refs) &&
!io_req_multi_free(&rb, req)) {
req->flags |= REQ_F_COMP_LOCKED;
io_free_req(req);
}
}
spin_unlock_irq(&ctx->completion_lock);
io_cqring_ev_posted(ctx);
io_free_req_many(ctx, &rb);
}
| 0 |
[] |
linux
|
ff002b30181d30cdfbca316dadd099c3ca0d739c
| 119,246,865,643,362,070,000,000,000,000,000,000,000 | 22 |
io_uring: grab ->fs as part of async preparation
This passes it in to io-wq, so it assumes the right fs_struct when
executing async work that may need to do lookups.
Cc: [email protected] # 5.3+
Signed-off-by: Jens Axboe <[email protected]>
|
static int add_chunked_item_iovs(conn *c, item *it, int len) {
assert(it->it_flags & ITEM_CHUNKED);
item_chunk *ch = (item_chunk *) ITEM_data(it);
while (ch) {
int todo = (len > ch->used) ? ch->used : len;
if (add_iov(c, ch->data, todo) != 0) {
return -1;
}
ch = ch->next;
len -= todo;
}
return 0;
}
| 0 |
[
"CWE-190"
] |
memcached
|
bd578fc34b96abe0f8d99c1409814a09f51ee71c
| 266,669,294,433,695,240,000,000,000,000,000,000,000 | 13 |
CVE reported by cisco talos
|
int report(request_rec *r) {
r->status = 500;
ap_set_content_type(r, "text/html; charset=UTF-8");
ap_rputs("<h1>Passenger error #1</h1>\n", r);
ap_rputs("Cannot determine the document root for the current request.", r);
P_ERROR("Cannot determine the document root for the current request.\n" <<
" Backtrace:\n" << e.backtrace());
return OK;
}
| 0 |
[
"CWE-59"
] |
passenger
|
9dda49f4a3ebe9bafc48da1bd45799f30ce19566
| 186,117,978,732,189,330,000,000,000,000,000,000,000 | 9 |
Fixed a problem with graceful web server restarts.
This problem was introduced in 4.0.6 during the attempt to fix issue #910.
|
host_and_ident(BOOL useflag)
{
if (!sender_fullhost)
string_format_nt(big_buffer, big_buffer_size, "%s%s", useflag ? "U=" : "",
sender_ident ? sender_ident : US"unknown");
else
{
uschar * flag = useflag ? US"H=" : US"";
uschar * iface = US"";
if (LOGGING(incoming_interface) && interface_address)
iface = string_sprintf(" I=[%s]:%d", interface_address, interface_port);
if (sender_ident)
string_format_nt(big_buffer, big_buffer_size, "%s%s%s U=%s",
flag, sender_fullhost, iface, sender_ident);
else
string_format_nt(big_buffer, big_buffer_size, "%s%s%s",
flag, sender_fullhost, iface);
}
return big_buffer;
}
| 0 |
[
"CWE-787"
] |
exim
|
d4bc023436e4cce7c23c5f8bb5199e178b4cc743
| 280,998,953,974,313,700,000,000,000,000,000,000,000 | 20 |
Fix host_name_lookup (Close 2747)
Thanks to Nico R for providing a reproducing configuration.
host_lookup = *
message_size_limit = ${if def:sender_host_name {32M}{32M}}
acl_smtp_connect = acl_smtp_connect
acl_smtp_rcpt = acl_smtp_rcpt
begin acl
acl_smtp_connect:
warn ratelimit = 256 / 1m / per_conn
accept
acl_smtp_rcpt:
accept hosts = 127.0.0.*
begin routers
null:
driver = accept
transport = null
begin transports
null:
driver = appendfile
file = /dev/null
Tested with
swaks -f [email protected] -t [email protected] --pipe 'exim -bh 127.0.0.1 -C /opt/exim/etc/exim-bug.conf'
The IP must have a PTR to "localhost." to reproduce it.
(cherry picked from commit 20812729e3e47a193a21d326ecd036d67a8b2724)
|
void ssl_excert_free(SSL_EXCERT *exc)
{
SSL_EXCERT *curr;
while (exc)
{
if (exc->cert)
X509_free(exc->cert);
if (exc->key)
EVP_PKEY_free(exc->key);
if (exc->chain)
sk_X509_pop_free(exc->chain, X509_free);
curr = exc;
exc = exc->next;
OPENSSL_free(curr);
}
}
| 0 |
[] |
openssl
|
a70da5b3ecc3160368529677006801c58cb369db
| 182,791,518,548,413,700,000,000,000,000,000,000,000 | 16 |
New functions to check a hostname email or IP address against a
certificate. Add options to s_client, s_server and x509 utilities
to print results of checks.
|
gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, const int bgColor)
{
float _angle = ((float) (-degrees / 180.0f) * (float)M_PI);
const int src_w = gdImageSX(src);
const int src_h = gdImageSY(src);
const unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f);
const unsigned int new_height = (unsigned int)(abs((int)(src_w * sin(_angle))) + abs((int)(src_h * cos(_angle))) + 0.5f);
const gdFixed f_0_5 = gd_ftofx(0.5f);
const gdFixed f_H = gd_itofx(src_h/2);
const gdFixed f_W = gd_itofx(src_w/2);
const gdFixed f_cos = gd_ftofx(cos(-_angle));
const gdFixed f_sin = gd_ftofx(sin(-_angle));
unsigned int dst_offset_x;
unsigned int dst_offset_y = 0;
unsigned int i;
gdImagePtr dst;
dst = gdImageCreateTrueColor(new_width, new_height);
if (!dst) {
return NULL;
}
dst->saveAlphaFlag = 1;
for (i = 0; i < new_height; i++) {
unsigned int j;
dst_offset_x = 0;
for (j = 0; j < new_width; j++) {
gdFixed f_i = gd_itofx((int)i - (int)new_height/2);
gdFixed f_j = gd_itofx((int)j - (int)new_width/2);
gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
long m = gd_fxtoi(f_m);
long n = gd_fxtoi(f_n);
if ((m > 0) && (m < src_h-1) && (n > 0) && (n < src_w-1)) {
if (dst_offset_y < new_height) {
dst->tpixels[dst_offset_y][dst_offset_x++] = src->tpixels[m][n];
}
} else {
if (dst_offset_y < new_height) {
dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor;
}
}
}
dst_offset_y++;
}
return dst;
}
| 0 |
[
"CWE-119"
] |
php-src
|
4bb422343f29f06b7081323844d9b52e1a71e4a5
| 102,487,898,895,328,840,000,000,000,000,000,000,000 | 48 |
Fix bug #70976: fix boundary check on gdImageRotateInterpolated
|
TEST_F(RouterTest, UpstreamTimeoutWithAltResponse) {
NiceMock<Http::MockRequestEncoder> encoder;
Http::ResponseDecoder* response_decoder = nullptr;
EXPECT_CALL(cm_.thread_local_cluster_.conn_pool_, newStream(_, _))
.WillOnce(Invoke(
[&](Http::ResponseDecoder& decoder,
Http::ConnectionPool::Callbacks& callbacks) -> Http::ConnectionPool::Cancellable* {
response_decoder = &decoder;
callbacks.onPoolReady(encoder, cm_.thread_local_cluster_.conn_pool_.host_,
upstream_stream_info_, Http::Protocol::Http10);
return nullptr;
}));
expectResponseTimerCreate();
Http::TestRequestHeaderMapImpl headers{{"x-envoy-upstream-rq-timeout-alt-response", "204"},
{"x-envoy-internal", "true"}};
HttpTestUtility::addDefaultHeaders(headers);
router_.decodeHeaders(headers, false);
Buffer::OwnedImpl data;
router_.decodeData(data, true);
EXPECT_EQ(1U,
callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());
EXPECT_CALL(callbacks_.stream_info_,
setResponseFlag(StreamInfo::ResponseFlag::UpstreamRequestTimeout));
EXPECT_CALL(encoder.stream_, resetStream(Http::StreamResetReason::LocalReset));
Http::TestResponseHeaderMapImpl response_headers{{":status", "204"}};
EXPECT_CALL(callbacks_, encodeHeaders_(HeaderMapEqualRef(&response_headers), true));
EXPECT_CALL(*router_.retry_state_, shouldRetryReset(_, _)).Times(0);
EXPECT_CALL(
cm_.thread_local_cluster_.conn_pool_.host_->outlier_detector_,
putResult(Upstream::Outlier::Result::LocalOriginTimeout, absl::optional<uint64_t>(204)));
response_timeout_->invokeCallback();
EXPECT_EQ(1U,
cm_.thread_local_cluster_.cluster_.info_->stats_store_.counter("upstream_rq_timeout")
.value());
EXPECT_EQ(1UL, cm_.thread_local_cluster_.conn_pool_.host_->stats().rq_timeout_.value());
EXPECT_TRUE(verifyHostUpstreamStats(0, 1));
}
| 0 |
[
"CWE-703"
] |
envoy
|
5bf9b0f1e7f247a4eee7180849cb0823926f7fff
| 98,985,102,463,349,280,000,000,000,000,000,000,000 | 41 |
[1.21] CVE-2022-21655
Signed-off-by: Otto van der Schaaf <[email protected]>
|
_dbus_fd_set_close_on_exec (int fd)
{
int val;
val = fcntl (fd, F_GETFD, 0);
if (val < 0)
return;
val |= FD_CLOEXEC;
fcntl (fd, F_SETFD, val);
}
| 0 |
[
"CWE-404"
] |
dbus
|
872b085f12f56da25a2dbd9bd0b2dff31d5aea63
| 152,470,995,242,469,030,000,000,000,000,000,000,000 | 13 |
sysdeps-unix: On MSG_CTRUNC, close the fds we did receive
MSG_CTRUNC indicates that we have received fewer fds that we should
have done because the buffer was too small, but we were treating it
as though it indicated that we received *no* fds. If we received any,
we still have to make sure we close them, otherwise they will be leaked.
On the system bus, if an attacker can induce us to leak fds in this
way, that's a local denial of service via resource exhaustion.
Reported-by: Kevin Backhouse, GitHub Security Lab
Fixes: dbus#294
Fixes: CVE-2020-12049
Fixes: GHSL-2020-057
|
static int tty_driver_install_tty(struct tty_driver *driver,
struct tty_struct *tty)
{
int idx = tty->index;
int ret;
if (driver->ops->install) {
ret = driver->ops->install(driver, tty);
return ret;
}
if (tty_init_termios(tty) == 0) {
tty_driver_kref_get(driver);
tty->count++;
driver->ttys[idx] = tty;
return 0;
}
return -ENOMEM;
}
| 0 |
[
"CWE-703"
] |
linux
|
c290f8358acaeffd8e0c551ddcc24d1206143376
| 140,180,690,528,031,930,000,000,000,000,000,000,000 | 19 |
TTY: drop driver reference in tty_open fail path
When tty_driver_lookup_tty fails in tty_open, we forget to drop a
reference to the tty driver. This was added by commit 4a2b5fddd5 (Move
tty lookup/reopen to caller).
Fix that by adding tty_driver_kref_put to the fail path.
I will refactor the code later. This is for the ease of backporting to
stable.
Introduced-in: v2.6.28-rc2
Signed-off-by: Jiri Slaby <[email protected]>
Cc: stable <[email protected]>
Cc: Alan Cox <[email protected]>
Acked-by: Sukadev Bhattiprolu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
byte* s, word32* sLen)
{
int err;
int tmp_valid = 0;
word32 x = 0;
#ifdef WOLFSSL_SMALL_STACK
mp_int* rtmp = NULL;
mp_int* stmp = NULL;
#else
mp_int rtmp[1];
mp_int stmp[1];
#endif
if (sig == NULL || r == NULL || rLen == NULL || s == NULL || sLen == NULL)
return ECC_BAD_ARG_E;
#ifdef WOLFSSL_SMALL_STACK
rtmp = (mp_int*)XMALLOC(sizeof(mp_int), NULL, DYNAMIC_TYPE_ECC);
if (rtmp == NULL)
return MEMORY_E;
stmp = (mp_int*)XMALLOC(sizeof(mp_int), NULL, DYNAMIC_TYPE_ECC);
if (stmp == NULL) {
XFREE(rtmp, NULL, DYNAMIC_TYPE_ECC);
return MEMORY_E;
}
#endif
err = DecodeECC_DSA_Sig(sig, sigLen, rtmp, stmp);
/* rtmp and stmp are initialized */
if (err == MP_OKAY) {
tmp_valid = 1;
}
/* extract r */
if (err == MP_OKAY) {
x = mp_unsigned_bin_size(rtmp);
if (*rLen < x)
err = BUFFER_E;
if (err == MP_OKAY) {
*rLen = x;
err = mp_to_unsigned_bin(rtmp, r);
}
}
/* extract s */
if (err == MP_OKAY) {
x = mp_unsigned_bin_size(stmp);
if (*sLen < x)
err = BUFFER_E;
if (err == MP_OKAY) {
*sLen = x;
err = mp_to_unsigned_bin(stmp, s);
}
}
if (tmp_valid) {
mp_clear(rtmp);
mp_clear(stmp);
}
#ifdef WOLFSSL_SMALL_STACK
XFREE(stmp, NULL, DYNAMIC_TYPE_ECC);
XFREE(rtmp, NULL, DYNAMIC_TYPE_ECC);
#endif
return err;
}
| 0 |
[
"CWE-326",
"CWE-203"
] |
wolfssl
|
1de07da61f0c8e9926dcbd68119f73230dae283f
| 299,696,813,383,644,340,000,000,000,000,000,000,000 | 70 |
Constant time EC map to affine for private operations
For fast math, use a constant time modular inverse when mapping to
affine when operation involves a private key - key gen, calc shared
secret, sign.
|
static int set_bitmap_file(struct mddev *mddev, int fd)
{
int err = 0;
if (mddev->pers) {
if (!mddev->pers->quiesce || !mddev->thread)
return -EBUSY;
if (mddev->recovery || mddev->sync_thread)
return -EBUSY;
/* we should be able to change the bitmap.. */
}
if (fd >= 0) {
struct inode *inode;
struct file *f;
if (mddev->bitmap || mddev->bitmap_info.file)
return -EEXIST; /* cannot add when bitmap is present */
f = fget(fd);
if (f == NULL) {
printk(KERN_ERR "%s: error: failed to get bitmap file\n",
mdname(mddev));
return -EBADF;
}
inode = f->f_mapping->host;
if (!S_ISREG(inode->i_mode)) {
printk(KERN_ERR "%s: error: bitmap file must be a regular file\n",
mdname(mddev));
err = -EBADF;
} else if (!(f->f_mode & FMODE_WRITE)) {
printk(KERN_ERR "%s: error: bitmap file must open for write\n",
mdname(mddev));
err = -EBADF;
} else if (atomic_read(&inode->i_writecount) != 1) {
printk(KERN_ERR "%s: error: bitmap file is already in use\n",
mdname(mddev));
err = -EBUSY;
}
if (err) {
fput(f);
return err;
}
mddev->bitmap_info.file = f;
mddev->bitmap_info.offset = 0; /* file overrides offset */
} else if (mddev->bitmap == NULL)
return -ENOENT; /* cannot remove what isn't there */
err = 0;
if (mddev->pers) {
mddev->pers->quiesce(mddev, 1);
if (fd >= 0) {
struct bitmap *bitmap;
bitmap = bitmap_create(mddev, -1);
if (!IS_ERR(bitmap)) {
mddev->bitmap = bitmap;
err = bitmap_load(mddev);
} else
err = PTR_ERR(bitmap);
}
if (fd < 0 || err) {
bitmap_destroy(mddev);
fd = -1; /* make sure to put the file */
}
mddev->pers->quiesce(mddev, 0);
}
if (fd < 0) {
struct file *f = mddev->bitmap_info.file;
if (f) {
spin_lock(&mddev->lock);
mddev->bitmap_info.file = NULL;
spin_unlock(&mddev->lock);
fput(f);
}
}
return err;
}
| 0 |
[
"CWE-200"
] |
linux
|
b6878d9e03043695dbf3fa1caa6dfc09db225b16
| 10,790,908,818,831,010,000,000,000,000,000,000,000 | 79 |
md: use kzalloc() when bitmap is disabled
In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
mdu_bitmap_file_t called "file".
5769 file = kmalloc(sizeof(*file), GFP_NOIO);
5770 if (!file)
5771 return -ENOMEM;
This structure is copied to user space at the end of the function.
5786 if (err == 0 &&
5787 copy_to_user(arg, file, sizeof(*file)))
5788 err = -EFAULT
But if bitmap is disabled only the first byte of "file" is initialized
with zero, so it's possible to read some bytes (up to 4095) of kernel
space memory from user space. This is an information leak.
5775 /* bitmap disabled, zero the first byte and copy out */
5776 if (!mddev->bitmap_info.file)
5777 file->pathname[0] = '\0';
Signed-off-by: Benjamin Randazzo <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
|
proc_mchar(struct readbuffer *obuf, int pre_mode,
int width, char **str, Lineprop mode)
{
check_breakpoint(obuf, pre_mode, *str);
obuf->pos += width;
Strcat_charp_n(obuf->line, *str, get_mclen(*str));
if (width > 0) {
set_prevchar(obuf->prevchar, *str, 1);
if (**str != ' ')
obuf->prev_ctype = mode;
}
(*str) += get_mclen(*str);
obuf->flag |= RB_NFLUSHED;
}
| 0 |
[
"CWE-476"
] |
w3m
|
59b91cd8e30c86f23476fa81ae005cabff49ebb6
| 5,296,682,949,000,931,500,000,000,000,000,000,000 | 14 |
Prevent segfault with malformed input type
Bug-Debian: https://github.com/tats/w3m/issues/7
|
int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
const char *str, int slen, unsigned char *out)
{
unsigned int i;
EVP_MD_CTX ctx;
unsigned char buf[TLS_MD_MAX_CONST_SIZE+MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
unsigned char *q,buf2[12];
q=buf;
memcpy(q,str,slen);
q+=slen;
EVP_MD_CTX_init(&ctx);
EVP_MD_CTX_copy_ex(&ctx,in1_ctx);
EVP_DigestFinal_ex(&ctx,q,&i);
q+=i;
EVP_MD_CTX_copy_ex(&ctx,in2_ctx);
EVP_DigestFinal_ex(&ctx,q,&i);
q+=i;
tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf),
s->session->master_key,s->session->master_key_length,
out,buf2,sizeof buf2);
EVP_MD_CTX_cleanup(&ctx);
return sizeof buf2;
}
| 0 |
[
"CWE-310"
] |
openssl
|
35a65e814beb899fa1c69a7673a8956c6059dce7
| 146,736,839,769,520,180,000,000,000,000,000,000,000 | 27 |
Make CBC decoding constant time.
This patch makes the decoding of SSLv3 and TLS CBC records constant
time. Without this, a timing side-channel can be used to build a padding
oracle and mount Vaudenay's attack.
This patch also disables the stitched AESNI+SHA mode pending a similar
fix to that code.
In order to be easy to backport, this change is implemented in ssl/,
rather than as a generic AEAD mode. In the future this should be changed
around so that HMAC isn't in ssl/, but crypto/ as FIPS expects.
(cherry picked from commit e130841bccfc0bb9da254dc84e23bc6a1c78a64e)
Conflicts:
crypto/evp/c_allc.c
ssl/ssl_algs.c
ssl/ssl_locl.h
ssl/t1_enc.c
(cherry picked from commit 3622239826698a0e534dcf0473204c724bb9b4b4)
Conflicts:
ssl/d1_enc.c
ssl/s3_enc.c
ssl/s3_pkt.c
ssl/ssl3.h
ssl/ssl_algs.c
ssl/t1_enc.c
|
int luaRedisReturnSingleFieldTable(lua_State *lua, char *field) {
if (lua_gettop(lua) != 1 || lua_type(lua,-1) != LUA_TSTRING) {
luaPushError(lua, "wrong number or type of arguments");
return 1;
}
lua_newtable(lua);
lua_pushstring(lua, field);
lua_pushvalue(lua, -3);
lua_settable(lua, -3);
return 1;
}
| 0 |
[
"CWE-703",
"CWE-125"
] |
redis
|
6ac3c0b7abd35f37201ed2d6298ecef4ea1ae1dd
| 155,298,662,983,565,680,000,000,000,000,000,000,000 | 12 |
Fix protocol parsing on 'ldbReplParseCommand' (CVE-2021-32672)
The protocol parsing on 'ldbReplParseCommand' (LUA debugging)
Assumed protocol correctness. This means that if the following
is given:
*1
$100
test
The parser will try to read additional 94 unallocated bytes after
the client buffer.
This commit fixes this issue by validating that there are actually enough
bytes to read. It also limits the amount of data that can be sent by
the debugger client to 1M so the client will not be able to explode
the memory.
|
_asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len,
char *str, int str_size)
{
int len_len, len, k;
int leading;
char temp[20];
unsigned long val, val1;
*ret_len = 0;
if (str && str_size > 0)
str[0] = 0; /* no oid */
if (str == NULL || der_len <= 0)
return ASN1_GENERIC_ERROR;
len = asn1_get_length_der (der, der_len, &len_len);
if (len < 0 || len > der_len || len_len > der_len)
return ASN1_DER_ERROR;
val1 = der[len_len] / 40;
val = der[len_len] - val1 * 40;
_asn1_str_cpy (str, str_size, _asn1_ltostr (val1, temp));
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
for (k = 1; k < len; k++)
{
/* X.690 mandates that the leading byte must never be 0x80
*/
if (leading != 0 && der[len_len + k] == 0x80)
return ASN1_DER_ERROR;
leading = 0;
/* check for wrap around */
if (INT_LEFT_SHIFT_OVERFLOW (val, 7))
return ASN1_DER_ERROR;
val = val << 7;
val |= der[len_len + k] & 0x7F;
if (!(der[len_len + k] & 0x80))
{
_asn1_str_cat (str, str_size, ".");
_asn1_str_cat (str, str_size, _asn1_ltostr (val, temp));
val = 0;
leading = 1;
}
}
if (INT_ADD_OVERFLOW (len, len_len))
return ASN1_DER_ERROR;
*ret_len = len + len_len;
return ASN1_SUCCESS;
}
| 1 |
[] |
libtasn1
|
51612fca32dda445056ca9a7533bae258acd3ecb
| 171,055,086,052,398,100,000,000,000,000,000,000,000 | 60 |
check for zero size in time and object ids.
|
static bool is_legal_file(const std::string &filename)
{
DBG_FS << "Looking for '" << filename << "'.\n";
if (filename.empty()) {
LOG_FS << " invalid filename\n";
return false;
}
if (filename.find("..") != std::string::npos) {
ERR_FS << "Illegal path '" << filename << "' (\"..\" not allowed).\n";
return false;
}
if (looks_like_pbl(filename)) {
ERR_FS << "Illegal path '" << filename << "' (.pbl files are not allowed)." << std::endl;
return false;
}
return true;
}
| 0 |
[
"CWE-200"
] |
wesnoth
|
b2738ffb2fdd2550ececb74f76f75583c43c8b59
| 100,160,590,471,059,740,000,000,000,000,000,000,000 | 21 |
Use looks_like_pbl() to disallow .pbl file inclusion (bug #23504)
This function is implemented using case-insensitive pattern matching,
unlike filesystem::ends_with(). I missed this when writing my original
fix, so the vulnerability still applied to .pbl files on a
case-insensitive filesystem (e.g. NTFS and FAT* on Windows) by using
different case to bypass the check.
|
rfbPowM64(uint64_t b, uint64_t e, uint64_t m)
{
uint64_t r;
for(r=1;e>0;e>>=1)
{
if(e&1) r=rfbMulM64(r,b,m);
b=rfbMulM64(b,b,m);
}
return r;
}
| 0 |
[
"CWE-20"
] |
libvncserver
|
85a778c0e45e87e35ee7199f1f25020648e8b812
| 168,204,770,848,359,470,000,000,000,000,000,000,000 | 10 |
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 clone_finish_inode_update(struct btrfs_trans_handle *trans,
struct inode *inode,
u64 endoff,
const u64 destoff,
const u64 olen,
int no_time_update)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret;
inode_inc_iversion(inode);
if (!no_time_update)
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
/*
* We round up to the block size at eof when determining which
* extents to clone above, but shouldn't round up the file size.
*/
if (endoff > destoff + olen)
endoff = destoff + olen;
if (endoff > inode->i_size)
btrfs_i_size_write(inode, endoff);
ret = btrfs_update_inode(trans, root, inode);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_end_transaction(trans, root);
goto out;
}
ret = btrfs_end_transaction(trans, root);
out:
return ret;
}
| 0 |
[
"CWE-200"
] |
linux
|
8039d87d9e473aeb740d4fdbd59b9d2f89b2ced9
| 288,717,717,606,019,770,000,000,000,000,000,000,000 | 32 |
Btrfs: fix file corruption and data loss after cloning inline extents
Currently the clone ioctl allows to clone an inline extent from one file
to another that already has other (non-inlined) extents. This is a problem
because btrfs is not designed to deal with files having inline and regular
extents, if a file has an inline extent then it must be the only extent
in the file and must start at file offset 0. Having a file with an inline
extent followed by regular extents results in EIO errors when doing reads
or writes against the first 4K of the file.
Also, the clone ioctl allows one to lose data if the source file consists
of a single inline extent, with a size of N bytes, and the destination
file consists of a single inline extent with a size of M bytes, where we
have M > N. In this case the clone operation removes the inline extent
from the destination file and then copies the inline extent from the
source file into the destination file - we lose the M - N bytes from the
destination file, a read operation will get the value 0x00 for any bytes
in the the range [N, M] (the destination inode's i_size remained as M,
that's why we can read past N bytes).
So fix this by not allowing such destructive operations to happen and
return errno EOPNOTSUPP to user space.
Currently the fstest btrfs/035 tests the data loss case but it totally
ignores this - i.e. expects the operation to succeed and does not check
the we got data loss.
The following test case for fstests exercises all these cases that result
in file corruption and data loss:
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# real QA test starts here
_need_to_be_root
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_cloner
_require_btrfs_fs_feature "no_holes"
_require_btrfs_mkfs_feature "no-holes"
rm -f $seqres.full
test_cloning_inline_extents()
{
local mkfs_opts=$1
local mount_opts=$2
_scratch_mkfs $mkfs_opts >>$seqres.full 2>&1
_scratch_mount $mount_opts
# File bar, the source for all the following clone operations, consists
# of a single inline extent (50 bytes).
$XFS_IO_PROG -f -c "pwrite -S 0xbb 0 50" $SCRATCH_MNT/bar \
| _filter_xfs_io
# Test cloning into a file with an extent (non-inlined) where the
# destination offset overlaps that extent. It should not be possible to
# clone the inline extent from file bar into this file.
$XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 16K" $SCRATCH_MNT/foo \
| _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo
# Doing IO against any range in the first 4K of the file should work.
# Due to a past clone ioctl bug which allowed cloning the inline extent,
# these operations resulted in EIO errors.
echo "File foo data after clone operation:"
# All bytes should have the value 0xaa (clone operation failed and did
# not modify our file).
od -t x1 $SCRATCH_MNT/foo
$XFS_IO_PROG -c "pwrite -S 0xcc 0 100" $SCRATCH_MNT/foo | _filter_xfs_io
# Test cloning the inline extent against a file which has a hole in its
# first 4K followed by a non-inlined extent. It should not be possible
# as well to clone the inline extent from file bar into this file.
$XFS_IO_PROG -f -c "pwrite -S 0xdd 4K 12K" $SCRATCH_MNT/foo2 \
| _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo2
# Doing IO against any range in the first 4K of the file should work.
# Due to a past clone ioctl bug which allowed cloning the inline extent,
# these operations resulted in EIO errors.
echo "File foo2 data after clone operation:"
# All bytes should have the value 0x00 (clone operation failed and did
# not modify our file).
od -t x1 $SCRATCH_MNT/foo2
$XFS_IO_PROG -c "pwrite -S 0xee 0 90" $SCRATCH_MNT/foo2 | _filter_xfs_io
# Test cloning the inline extent against a file which has a size of zero
# but has a prealloc extent. It should not be possible as well to clone
# the inline extent from file bar into this file.
$XFS_IO_PROG -f -c "falloc -k 0 1M" $SCRATCH_MNT/foo3 | _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo3
# Doing IO against any range in the first 4K of the file should work.
# Due to a past clone ioctl bug which allowed cloning the inline extent,
# these operations resulted in EIO errors.
echo "First 50 bytes of foo3 after clone operation:"
# Should not be able to read any bytes, file has 0 bytes i_size (the
# clone operation failed and did not modify our file).
od -t x1 $SCRATCH_MNT/foo3
$XFS_IO_PROG -c "pwrite -S 0xff 0 90" $SCRATCH_MNT/foo3 | _filter_xfs_io
# Test cloning the inline extent against a file which consists of a
# single inline extent that has a size not greater than the size of
# bar's inline extent (40 < 50).
# It should be possible to do the extent cloning from bar to this file.
$XFS_IO_PROG -f -c "pwrite -S 0x01 0 40" $SCRATCH_MNT/foo4 \
| _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo4
# Doing IO against any range in the first 4K of the file should work.
echo "File foo4 data after clone operation:"
# Must match file bar's content.
od -t x1 $SCRATCH_MNT/foo4
$XFS_IO_PROG -c "pwrite -S 0x02 0 90" $SCRATCH_MNT/foo4 | _filter_xfs_io
# Test cloning the inline extent against a file which consists of a
# single inline extent that has a size greater than the size of bar's
# inline extent (60 > 50).
# It should not be possible to clone the inline extent from file bar
# into this file.
$XFS_IO_PROG -f -c "pwrite -S 0x03 0 60" $SCRATCH_MNT/foo5 \
| _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo5
# Reading the file should not fail.
echo "File foo5 data after clone operation:"
# Must have a size of 60 bytes, with all bytes having a value of 0x03
# (the clone operation failed and did not modify our file).
od -t x1 $SCRATCH_MNT/foo5
# Test cloning the inline extent against a file which has no extents but
# has a size greater than bar's inline extent (16K > 50).
# It should not be possible to clone the inline extent from file bar
# into this file.
$XFS_IO_PROG -f -c "truncate 16K" $SCRATCH_MNT/foo6 | _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo6
# Reading the file should not fail.
echo "File foo6 data after clone operation:"
# Must have a size of 16K, with all bytes having a value of 0x00 (the
# clone operation failed and did not modify our file).
od -t x1 $SCRATCH_MNT/foo6
# Test cloning the inline extent against a file which has no extents but
# has a size not greater than bar's inline extent (30 < 50).
# It should be possible to clone the inline extent from file bar into
# this file.
$XFS_IO_PROG -f -c "truncate 30" $SCRATCH_MNT/foo7 | _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo7
# Reading the file should not fail.
echo "File foo7 data after clone operation:"
# Must have a size of 50 bytes, with all bytes having a value of 0xbb.
od -t x1 $SCRATCH_MNT/foo7
# Test cloning the inline extent against a file which has a size not
# greater than the size of bar's inline extent (20 < 50) but has
# a prealloc extent that goes beyond the file's size. It should not be
# possible to clone the inline extent from bar into this file.
$XFS_IO_PROG -f -c "falloc -k 0 1M" \
-c "pwrite -S 0x88 0 20" \
$SCRATCH_MNT/foo8 | _filter_xfs_io
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/bar $SCRATCH_MNT/foo8
echo "File foo8 data after clone operation:"
# Must have a size of 20 bytes, with all bytes having a value of 0x88
# (the clone operation did not modify our file).
od -t x1 $SCRATCH_MNT/foo8
_scratch_unmount
}
echo -e "\nTesting without compression and without the no-holes feature...\n"
test_cloning_inline_extents
echo -e "\nTesting with compression and without the no-holes feature...\n"
test_cloning_inline_extents "" "-o compress"
echo -e "\nTesting without compression and with the no-holes feature...\n"
test_cloning_inline_extents "-O no-holes" ""
echo -e "\nTesting with compression and with the no-holes feature...\n"
test_cloning_inline_extents "-O no-holes" "-o compress"
status=0
exit
Cc: [email protected]
Signed-off-by: Filipe Manana <[email protected]>
|
TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
bool requires_broadcast = !HaveSameShapes(input1, input2);
switch (input1->type) {
case kTfLiteFloat32:
Comparison<float, reference_ops::LessFn>(input1, input2, output,
requires_broadcast);
break;
case kTfLiteInt32:
Comparison<int32_t, reference_ops::LessFn>(input1, input2, output,
requires_broadcast);
break;
case kTfLiteInt64:
Comparison<int64_t, reference_ops::LessFn>(input1, input2, output,
requires_broadcast);
break;
case kTfLiteUInt8:
ComparisonQuantized<uint8_t, reference_ops::LessFn>(
input1, input2, output, requires_broadcast);
break;
case kTfLiteInt8:
ComparisonQuantized<int8_t, reference_ops::LessFn>(input1, input2, output,
requires_broadcast);
break;
default:
context->ReportError(context,
"Does not support type %d, requires float|int|uint8",
input1->type);
return kTfLiteError;
}
return kTfLiteOk;
}
| 1 |
[
"CWE-125",
"CWE-787"
] |
tensorflow
|
1970c2158b1ffa416d159d03c3370b9a462aee35
| 329,793,860,856,596,420,000,000,000,000,000,000,000 | 34 |
[tflite]: Insert `nullptr` checks when obtaining tensors.
As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages.
We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`).
PiperOrigin-RevId: 332521299
Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56
|
spell_suggest_intern(suginfo_T *su, int interactive)
{
// Load the .sug file(s) that are available and not done yet.
suggest_load_files();
// 1. Try special cases, such as repeating a word: "the the" -> "the".
//
// Set a maximum score to limit the combination of operations that is
// tried.
suggest_try_special(su);
// 2. Try inserting/deleting/swapping/changing a letter, use REP entries
// from the .aff file and inserting a space (split the word).
suggest_try_change(su);
// For the resulting top-scorers compute the sound-a-like score.
if (sps_flags & SPS_DOUBLE)
score_comp_sal(su);
// 3. Try finding sound-a-like words.
if ((sps_flags & SPS_FAST) == 0)
{
if (sps_flags & SPS_BEST)
// Adjust the word score for the suggestions found so far for how
// they sound like.
rescore_suggestions(su);
// While going through the soundfold tree "su_maxscore" is the score
// for the soundfold word, limits the changes that are being tried,
// and "su_sfmaxscore" the rescored score, which is set by
// cleanup_suggestions().
// First find words with a small edit distance, because this is much
// faster and often already finds the top-N suggestions. If we didn't
// find many suggestions try again with a higher edit distance.
// "sl_sounddone" is used to avoid doing the same word twice.
suggest_try_soundalike_prep();
su->su_maxscore = SCORE_SFMAX1;
su->su_sfmaxscore = SCORE_MAXINIT * 3;
suggest_try_soundalike(su);
if (su->su_ga.ga_len < SUG_CLEAN_COUNT(su))
{
// We didn't find enough matches, try again, allowing more
// changes to the soundfold word.
su->su_maxscore = SCORE_SFMAX2;
suggest_try_soundalike(su);
if (su->su_ga.ga_len < SUG_CLEAN_COUNT(su))
{
// Still didn't find enough matches, try again, allowing even
// more changes to the soundfold word.
su->su_maxscore = SCORE_SFMAX3;
suggest_try_soundalike(su);
}
}
su->su_maxscore = su->su_sfmaxscore;
suggest_try_soundalike_finish();
}
// When CTRL-C was hit while searching do show the results. Only clear
// got_int when using a command, not for spellsuggest().
ui_breakcheck();
if (interactive && got_int)
{
(void)vgetc();
got_int = FALSE;
}
if ((sps_flags & SPS_DOUBLE) == 0 && su->su_ga.ga_len != 0)
{
if (sps_flags & SPS_BEST)
// Adjust the word score for how it sounds like.
rescore_suggestions(su);
// Remove bogus suggestions, sort and truncate at "maxcount".
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
}
}
| 0 |
[
"CWE-457"
] |
vim
|
15d9890eee53afc61eb0a03b878a19cb5672f732
| 62,820,485,948,959,560,000,000,000,000,000,000,000 | 77 |
patch 8.2.3582: reading uninitialized memory when giving spell suggestions
Problem: Reading uninitialized memory when giving spell suggestions.
Solution: Check that preword is not empty.
|
int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc,
bool allow_ipv6)
{
int err, val;
struct cmsghdr *cmsg;
struct net *net = sock_net(sk);
for_each_cmsghdr(cmsg, msg) {
if (!CMSG_OK(msg, cmsg))
return -EINVAL;
#if IS_ENABLED(CONFIG_IPV6)
if (allow_ipv6 &&
cmsg->cmsg_level == SOL_IPV6 &&
cmsg->cmsg_type == IPV6_PKTINFO) {
struct in6_pktinfo *src_info;
if (cmsg->cmsg_len < CMSG_LEN(sizeof(*src_info)))
return -EINVAL;
src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);
if (!ipv6_addr_v4mapped(&src_info->ipi6_addr))
return -EINVAL;
ipc->oif = src_info->ipi6_ifindex;
ipc->addr = src_info->ipi6_addr.s6_addr32[3];
continue;
}
#endif
if (cmsg->cmsg_level == SOL_SOCKET) {
err = __sock_cmsg_send(sk, msg, cmsg, &ipc->sockc);
if (err)
return err;
continue;
}
if (cmsg->cmsg_level != SOL_IP)
continue;
switch (cmsg->cmsg_type) {
case IP_RETOPTS:
err = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
/* Our caller is responsible for freeing ipc->opt */
err = ip_options_get(net, &ipc->opt, CMSG_DATA(cmsg),
err < 40 ? err : 40);
if (err)
return err;
break;
case IP_PKTINFO:
{
struct in_pktinfo *info;
if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in_pktinfo)))
return -EINVAL;
info = (struct in_pktinfo *)CMSG_DATA(cmsg);
ipc->oif = info->ipi_ifindex;
ipc->addr = info->ipi_spec_dst.s_addr;
break;
}
case IP_TTL:
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)))
return -EINVAL;
val = *(int *)CMSG_DATA(cmsg);
if (val < 1 || val > 255)
return -EINVAL;
ipc->ttl = val;
break;
case IP_TOS:
if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)))
val = *(int *)CMSG_DATA(cmsg);
else if (cmsg->cmsg_len == CMSG_LEN(sizeof(u8)))
val = *(u8 *)CMSG_DATA(cmsg);
else
return -EINVAL;
if (val < 0 || val > 255)
return -EINVAL;
ipc->tos = val;
ipc->priority = rt_tos2priority(ipc->tos);
break;
default:
return -EINVAL;
}
}
return 0;
}
| 0 |
[
"CWE-476",
"CWE-284"
] |
linux
|
34b2cef20f19c87999fff3da4071e66937db9644
| 43,497,829,565,703,040,000,000,000,000,000,000,000 | 82 |
ipv4: keep skb->dst around in presence of IP options
Andrey Konovalov got crashes in __ip_options_echo() when a NULL skb->dst
is accessed.
ipv4_pktinfo_prepare() should not drop the dst if (evil) IP options
are present.
We could refine the test to the presence of ts_needtime or srr,
but IP options are not often used, so let's be conservative.
Thanks to syzkaller team for finding this bug.
Fixes: d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Andrey Konovalov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
ENTROPY_DEBUG(const char * label, unsigned long entropy) {
const char * const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG");
if (EXPAT_ENTROPY_DEBUG && ! strcmp(EXPAT_ENTROPY_DEBUG, "1")) {
fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n",
label,
(int)sizeof(entropy) * 2, entropy,
(unsigned long)sizeof(entropy));
}
return entropy;
}
| 0 |
[
"CWE-611"
] |
libexpat
|
c4bf96bb51dd2a1b0e185374362ee136fe2c9d7f
| 66,175,004,862,964,870,000,000,000,000,000,000,000 | 10 |
xmlparse.c: Fix external entity infinite loop bug (CVE-2017-9233)
|
MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
QuantumInfo *quantum_info,const QuantumFormatType format)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(quantum_info != (QuantumInfo *) NULL);
assert(quantum_info->signature == MagickCoreSignature);
quantum_info->format=format;
return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
}
| 0 |
[
"CWE-369"
] |
ImageMagick
|
c4e63ad30bc42da691f2b5f82a24516dd6b4dc70
| 142,137,092,792,084,200,000,000,000,000,000,000,000 | 12 |
https://github.com/ImageMagick/ImageMagick/issues/105
|
static void convert_key_from_CPU(struct brcmf_wsec_key *key,
struct brcmf_wsec_key_le *key_le)
{
key_le->index = cpu_to_le32(key->index);
key_le->len = cpu_to_le32(key->len);
key_le->algo = cpu_to_le32(key->algo);
key_le->flags = cpu_to_le32(key->flags);
key_le->rxiv.hi = cpu_to_le32(key->rxiv.hi);
key_le->rxiv.lo = cpu_to_le16(key->rxiv.lo);
key_le->iv_initialized = cpu_to_le32(key->iv_initialized);
memcpy(key_le->data, key->data, sizeof(key->data));
memcpy(key_le->ea, key->ea, sizeof(key->ea));
}
| 0 |
[
"CWE-119",
"CWE-703"
] |
linux
|
ded89912156b1a47d940a0c954c43afbabd0c42c
| 304,688,178,377,717,320,000,000,000,000,000,000,000 | 13 |
brcmfmac: avoid potential stack overflow in brcmf_cfg80211_start_ap()
User-space can choose to omit NL80211_ATTR_SSID and only provide raw
IE TLV data. When doing so it can provide SSID IE with length exceeding
the allowed size. The driver further processes this IE copying it
into a local variable without checking the length. Hence stack can be
corrupted and used as exploit.
Cc: [email protected] # v4.7
Reported-by: Daxing Guo <[email protected]>
Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
|
rfbClientConnectionGone(rfbClientPtr cl)
{
int i;
LOCK(rfbClientListMutex);
if (cl->prev)
cl->prev->next = cl->next;
else
cl->screen->rfbClientHead = cl->next;
if (cl->next)
cl->next->prev = cl->prev;
if(cl->sock>0)
close(cl->sock);
#ifdef VINO_HAVE_ZLIB
FreeZrleData(cl);
#endif
if(cl->sock>=0)
FD_CLR(cl->sock,&(cl->screen->allFds));
if (cl->clientGoneHook)
cl->clientGoneHook(cl);
rfbLog("Client %s gone\n",cl->host);
free(cl->host);
#ifdef VINO_HAVE_ZLIB
/* Release the compression state structures if any. */
if ( cl->compStreamInited ) {
deflateEnd( &(cl->compStream) );
}
#ifdef VINO_HAVE_JPEG
for (i = 0; i < 4; i++) {
if (cl->zsActive[i])
deflateEnd(&cl->zsStruct[i]);
}
#endif
#endif
if (pointerClient == cl)
pointerClient = NULL;
sraRgnDestroy(cl->modifiedRegion);
sraRgnDestroy(cl->requestedRegion);
sraRgnDestroy(cl->copyRegion);
UNLOCK(rfbClientListMutex);
if (cl->translateLookupTable) free(cl->translateLookupTable);
rfbPrintStats(cl);
free(cl);
}
| 0 |
[
"CWE-119"
] |
vino
|
456dadbb5c5971d3448763a44c05b9ad033e522f
| 290,077,150,897,046,730,000,000,000,000,000,000,000 | 58 |
Avoid out-of-bounds memory accesses
This fixes two critical security vulnerabilities that lead to an
out-of-bounds memory access with a crafted client framebuffer update
request packet. The dimensions of the update from the packet are checked
to ensure that they are within the screen dimensions.
Thanks to Kevin Chen from the Bitblaze group for the reports in bugs
641802 and 641803. The CVE identifiers for these vulnerabilities are
CVE-2011-0904 and CVE-2011-0905.
|
char *QuotedString::extractFrom(char *input, char **endPtr) {
char firstChar = *input;
if (!isQuote(firstChar)) {
// must start with a quote
return NULL;
}
char stopChar = firstChar; // closing quote is the same as opening quote
char *startPtr = input + 1; // skip the quote
char *readPtr = startPtr;
char *writePtr = startPtr;
char c;
for (;;) {
c = *readPtr++;
if (c == '\0') {
// premature ending
return NULL;
}
if (c == stopChar) {
// closing quote
break;
}
if (c == '\\') {
// replace char
c = unescapeChar(*readPtr++);
}
*writePtr++ = c;
}
// end the string here
*writePtr = '\0';
// update end ptr
*endPtr = readPtr;
return startPtr;
}
| 1 |
[
"CWE-415",
"CWE-119"
] |
ArduinoJson
|
5e7b9ec688d79e7b16ec7064e1d37e8481a31e72
| 307,003,983,279,515,230,000,000,000,000,000,000,000 | 44 |
Fix buffer overflow (pull request #81)
|
static int netlink_getname(struct socket *sock, struct sockaddr *addr,
int *addr_len, int peer)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
DECLARE_SOCKADDR(struct sockaddr_nl *, nladdr, addr);
nladdr->nl_family = AF_NETLINK;
nladdr->nl_pad = 0;
*addr_len = sizeof(*nladdr);
if (peer) {
nladdr->nl_pid = nlk->dst_portid;
nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
} else {
nladdr->nl_pid = nlk->portid;
nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0;
}
return 0;
}
| 0 |
[
"CWE-362",
"CWE-415"
] |
linux
|
92964c79b357efd980812c4de5c1fd2ec8bb5520
| 58,596,152,893,792,770,000,000,000,000,000,000,000 | 20 |
netlink: Fix dump skb leak/double free
When we free cb->skb after a dump, we do it after releasing the
lock. This means that a new dump could have started in the time
being and we'll end up freeing their skb instead of ours.
This patch saves the skb and module before we unlock so we free
the right memory.
Fixes: 16b304f3404f ("netlink: Eliminate kmalloc in netlink dump operation.")
Reported-by: Baozeng Ding <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *mem_ctx,
char **blob_description,
DATA_BLOB *blob)
{
VFS_FIND(sys_acl_blob_get_fd);
return handle->fns->sys_acl_blob_get_fd_fn(handle, fsp, mem_ctx, blob_description, blob);
}
| 0 |
[
"CWE-264"
] |
samba
|
4278ef25f64d5fdbf432ff1534e275416ec9561e
| 115,622,984,127,452,140,000,000,000,000,000,000,000 | 9 |
CVE-2015-5252: s3: smbd: Fix symlink verification (file access outside the share).
Ensure matching component ends in '/' or '\0'.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11395
Signed-off-by: Jeremy Allison <[email protected]>
Reviewed-by: Volker Lendecke <[email protected]>
|
bool run(OperationContext* opCtx,
const string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
auth::RolesInfoArgs args;
Status status = auth::parseRolesInfoCommand(cmdObj, dbname, &args);
uassertStatusOK(status);
AuthorizationManager* authzManager = AuthorizationManager::get(opCtx->getServiceContext());
auto lk = uassertStatusOK(requireReadableAuthSchema26Upgrade(opCtx, authzManager));
if (args.allForDB) {
std::vector<BSONObj> rolesDocs;
status = authzManager->getRoleDescriptionsForDB(opCtx,
dbname,
args.privilegeFormat,
args.authenticationRestrictionsFormat,
args.showBuiltinRoles,
&rolesDocs);
uassertStatusOK(status);
if (args.privilegeFormat == PrivilegeFormat::kShowAsUserFragment) {
uasserted(ErrorCodes::IllegalOperation,
"Cannot get user fragment for all roles in a database");
}
BSONArrayBuilder rolesArrayBuilder;
for (size_t i = 0; i < rolesDocs.size(); ++i) {
rolesArrayBuilder.append(rolesDocs[i]);
}
result.append("roles", rolesArrayBuilder.arr());
} else {
BSONObj roleDetails;
status = authzManager->getRolesDescription(opCtx,
args.roleNames,
args.privilegeFormat,
args.authenticationRestrictionsFormat,
&roleDetails);
uassertStatusOK(status);
if (args.privilegeFormat == PrivilegeFormat::kShowAsUserFragment) {
result.append("userFragment", roleDetails);
} else {
result.append("roles", BSONArray(roleDetails));
}
}
return true;
}
| 0 |
[
"CWE-613"
] |
mongo
|
e55d6e2292e5dbe2f97153251d8193d1cc89f5d7
| 272,638,678,296,493,760,000,000,000,000,000,000,000 | 48 |
SERVER-38984 Validate unique User ID on UserCache hit
|
free_unmarked (struct MHD_PostProcessor *pp)
{
if ( (NULL != pp->content_name) &&
(0 == (pp->have & NE_content_name)) )
{
free (pp->content_name);
pp->content_name = NULL;
}
if ( (NULL != pp->content_type) &&
(0 == (pp->have & NE_content_type)) )
{
free (pp->content_type);
pp->content_type = NULL;
}
if ( (NULL != pp->content_filename) &&
(0 == (pp->have & NE_content_filename)) )
{
free (pp->content_filename);
pp->content_filename = NULL;
}
if ( (NULL != pp->content_transfer_encoding) &&
(0 == (pp->have & NE_content_transfer_encoding)) )
{
free (pp->content_transfer_encoding);
pp->content_transfer_encoding = NULL;
}
}
| 0 |
[
"CWE-120"
] |
libmicrohttpd
|
a110ae6276660bee3caab30e9ff3f12f85cf3241
| 20,114,509,723,088,841,000,000,000,000,000,000,000 | 27 |
fix buffer overflow and add test
|
normalize_cookie_domain (const char *domain)
{
/* Trim any leading dot if present to transform the cookie
* domain into a valid hostname.
*/
if (domain != NULL && domain[0] == '.')
return domain + 1;
return domain;
}
| 0 |
[
"CWE-125"
] |
libsoup
|
db2b0d5809d5f8226d47312b40992cadbcde439f
| 292,527,202,335,107,540,000,000,000,000,000,000,000 | 9 |
cookie-jar: bail if hostname is an empty string
There are several other ways to fix the problem with this function, but
skipping over all of the code is probably the simplest.
Fixes #3
|
*/
PHP_MINFO_FUNCTION(wddx)
{
php_info_print_table_start();
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
php_info_print_table_header(2, "WDDX Support", "enabled" );
php_info_print_table_row(2, "WDDX Session Serializer", "enabled" );
#else
php_info_print_table_row(2, "WDDX Support", "enabled" );
#endif
php_info_print_table_end();
| 0 |
[] |
php-src
|
366f9505a4aae98ef2f4ca39a838f628a324b746
| 268,956,375,282,641,980,000,000,000,000,000,000,000 | 11 |
Fixed bug #70661 (Use After Free Vulnerability in WDDX Packet Deserialization)
Conflicts:
ext/wddx/wddx.c
|
synthesize_class_def (PangoOTInfo *info)
{
GArray *glyph_infos;
hb_codepoint_t *glyph_indices;
unsigned char *classes;
gunichar charcode;
FT_UInt glyph;
unsigned int i, j;
FT_CharMap old_charmap;
old_charmap = info->face->charmap;
if (!old_charmap || !old_charmap->encoding != ft_encoding_unicode)
if (!set_unicode_charmap (info->face))
return;
glyph_infos = g_array_new (FALSE, FALSE, sizeof (GlyphInfo));
/* Collect all the glyphs in the charmap, and guess
* the appropriate classes for them
*/
charcode = FT_Get_First_Char (info->face, &glyph);
while (glyph != 0)
{
GlyphInfo glyph_info;
if (glyph <= 65535)
{
glyph_info.glyph = glyph;
if (get_glyph_class (charcode, &glyph_info.class))
g_array_append_val (glyph_infos, glyph_info);
}
charcode = FT_Get_Next_Char (info->face, charcode, &glyph);
}
/* Sort and remove duplicates
*/
g_array_sort (glyph_infos, compare_glyph_info);
glyph_indices = g_new (hb_codepoint_t, glyph_infos->len);
classes = g_new (unsigned char, glyph_infos->len);
for (i = 0, j = 0; i < glyph_infos->len; i++)
{
GlyphInfo *info = &g_array_index (glyph_infos, GlyphInfo, i);
if (j == 0 || info->glyph != glyph_indices[j - 1])
{
glyph_indices[j] = info->glyph;
classes[j] = info->class;
j++;
}
}
g_array_free (glyph_infos, TRUE);
hb_ot_layout_build_glyph_classes (info->layout, info->face->num_glyphs,
glyph_indices, classes, j);
g_free (glyph_indices);
g_free (classes);
if (old_charmap && info->face->charmap != old_charmap)
FT_Set_Charmap (info->face, old_charmap);
}
| 0 |
[] |
pango
|
336bb3201096bdd0494d29926dd44e8cca8bed26
| 40,667,189,878,238,217,000,000,000,000,000,000,000 | 67 |
[HB] Remove all references to the old code!
|
unsigned short gr_face_n_languages(const gr_face* pFace)
{
assert(pFace);
return pFace->theSill().numLanguages();
}
| 0 |
[
"CWE-476"
] |
graphite
|
db132b4731a9b4c9534144ba3a18e65b390e9ff6
| 332,157,630,091,545,250,000,000,000,000,000,000,000 | 5 |
Deprecate and make ineffective gr_face_dumbRendering
|
convert_language_name(text *languagename)
{
char *langname = text_to_cstring(languagename);
return get_language_oid(langname, false);
}
| 0 |
[
"CWE-264"
] |
postgres
|
fea164a72a7bfd50d77ba5fb418d357f8f2bb7d0
| 215,831,005,412,628,350,000,000,000,000,000,000,000 | 6 |
Shore up ADMIN OPTION restrictions.
Granting a role without ADMIN OPTION is supposed to prevent the grantee
from adding or removing members from the granted role. Issuing SET ROLE
before the GRANT bypassed that, because the role itself had an implicit
right to add or remove members. Plug that hole by recognizing that
implicit right only when the session user matches the current role.
Additionally, do not recognize it during a security-restricted operation
or during execution of a SECURITY DEFINER function. The restriction on
SECURITY DEFINER is not security-critical. However, it seems best for a
user testing his own SECURITY DEFINER function to see the same behavior
others will see. Back-patch to 8.4 (all supported versions).
The SQL standards do not conflate roles and users as PostgreSQL does;
only SQL roles have members, and only SQL users initiate sessions. An
application using PostgreSQL users and roles as SQL users and roles will
never attempt to grant membership in the role that is the session user,
so the implicit right to add or remove members will never arise.
The security impact was mostly that a role member could revoke access
from others, contrary to the wishes of his own grantor. Unapproved role
member additions are less notable, because the member can still largely
achieve that by creating a view or a SECURITY DEFINER function.
Reviewed by Andres Freund and Tom Lane. Reported, independently, by
Jonas Sundman and Noah Misch.
Security: CVE-2014-0060
|
custom_basename_skip (va_list *va)
{
(void) va_arg (*va, GFile *);
}
| 0 |
[
"CWE-20"
] |
nautilus
|
1630f53481f445ada0a455e9979236d31a8d3bb0
| 54,768,382,426,854,880,000,000,000,000,000,000,000 | 4 |
mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991
|
cockpit_auth_empty_cookie_value (const gchar *path, gboolean secure)
{
gchar *application = cockpit_auth_parse_application (path, NULL);
gchar *cookie = application_cookie_name (application);
/* this is completely security irrelevant, but security scanners complain
* about the lack of Secure (rhbz#1677767) */
gchar *cookie_line = g_strdup_printf ("%s=deleted; PATH=/;%s HttpOnly",
cookie,
secure ? " Secure;" : "");
g_free (application);
g_free (cookie);
return cookie_line;
}
| 1 |
[
"CWE-1021"
] |
cockpit
|
46f6839d1af4e662648a85f3e54bba2d57f39f0e
| 145,710,859,580,599,410,000,000,000,000,000,000,000 | 16 |
ws: Restrict our cookie to the login host only
Mark our cookie as `SameSite: Strict` [1]. The current `None` default
will soon be moved to `Lax` by Firefox and Chromium, and recent versions
started to throw a warning about it.
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
https://bugzilla.redhat.com/show_bug.cgi?id=1891944
|
TEST_F(QueryPlannerTest, MinBadHint) {
addIndex(BSON("b" << 1));
runInvalidQueryHintMinMax(BSONObj(), fromjson("{b: 1}"), fromjson("{a: 1}"), BSONObj());
}
| 0 |
[] |
mongo
|
ee97c0699fd55b498310996ee002328e533681a3
| 190,896,516,882,203,830,000,000,000,000,000,000,000 | 4 |
SERVER-36993 Fix crash due to incorrect $or pushdown for indexed $expr.
|
static RDyldRebaseInfos *get_rebase_infos(RBinFile *bf, RDyldCache *cache) {
RDyldRebaseInfos *result = R_NEW0 (RDyldRebaseInfos);
if (!result) {
return NULL;
}
if (!cache->hdr->slideInfoOffset || !cache->hdr->slideInfoSize) {
ut32 total_slide_infos = 0;
ut32 n_slide_infos[MAX_N_HDR];
ut32 i;
for (i = 0; i < cache->n_hdr && i < MAX_N_HDR; i++) {
ut64 hdr_offset = cache->hdr_offset[i];
if ((n_slide_infos[i] = r_buf_read_le32_at (cache->buf, 0x13c + hdr_offset)) == UT32_MAX) {
goto beach;
}
total_slide_infos += n_slide_infos[i];
}
if (!total_slide_infos) {
goto beach;
}
RDyldRebaseInfosEntry * infos = R_NEWS0 (RDyldRebaseInfosEntry, total_slide_infos);
if (!infos) {
goto beach;
}
ut32 k = 0;
for (i = 0; i < cache->n_hdr && i < MAX_N_HDR; i++) {
ut64 hdr_offset = cache->hdr_offset[i];
ut64 slide_infos_offset;
if (!n_slide_infos[i]) {
continue;
}
if ((slide_infos_offset = r_buf_read_le32_at (cache->buf, 0x138 + hdr_offset)) == UT32_MAX) {
continue;
}
if (!slide_infos_offset) {
continue;
}
slide_infos_offset += hdr_offset;
ut32 j;
RDyldRebaseInfo *prev_info = NULL;
for (j = 0; j < n_slide_infos[i]; j++) {
ut64 offset = slide_infos_offset + j * sizeof (cache_mapping_slide);
cache_mapping_slide entry;
if (r_buf_fread_at (cache->buf, offset, (ut8*)&entry, "6lii", 1) != sizeof (cache_mapping_slide)) {
break;
}
if (entry.slideInfoOffset && entry.slideInfoSize) {
infos[k].start = entry.fileOffset + hdr_offset;
infos[k].end = infos[k].start + entry.size;
ut64 slide = prev_info ? prev_info->slide : UT64_MAX;
infos[k].info = get_rebase_info (bf, cache, entry.slideInfoOffset + hdr_offset, entry.slideInfoSize, entry.fileOffset + hdr_offset, slide);
prev_info = infos[k].info;
k++;
}
}
}
if (!k) {
free (infos);
goto beach;
}
if (k < total_slide_infos) {
RDyldRebaseInfosEntry * pruned_infos = R_NEWS0 (RDyldRebaseInfosEntry, k);
if (!pruned_infos) {
free (infos);
goto beach;
}
memcpy (pruned_infos, infos, sizeof (RDyldRebaseInfosEntry) * k);
free (infos);
infos = pruned_infos;
}
result->entries = infos;
result->length = k;
return result;
}
if (cache->hdr->mappingCount > 1) {
RDyldRebaseInfosEntry * infos = R_NEWS0 (RDyldRebaseInfosEntry, 1);
if (!infos) {
goto beach;
}
infos[0].start = cache->maps[1].fileOffset;
infos[0].end = infos[0].start + cache->maps[1].size;
infos[0].info = get_rebase_info (bf, cache, cache->hdr->slideInfoOffset, cache->hdr->slideInfoSize, infos[0].start, UT64_MAX);
result->entries = infos;
result->length = 1;
return result;
}
beach:
free (result);
return NULL;
}
| 0 |
[
"CWE-787"
] |
radare2
|
c84b7232626badd075caf3ae29661b609164bac6
| 323,149,863,825,030,300,000,000,000,000,000,000,000 | 104 |
Fix heap buffer overflow in dyldcache parser ##crash
* Reported by: Lazymio via huntr.dev
* Reproducer: dyldovf
|
static void *mcryptd_alloc_instance(struct crypto_alg *alg, unsigned int head,
unsigned int tail)
{
char *p;
struct crypto_instance *inst;
int err;
p = kzalloc(head + sizeof(*inst) + tail, GFP_KERNEL);
if (!p)
return ERR_PTR(-ENOMEM);
inst = (void *)(p + head);
err = -ENAMETOOLONG;
if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
"mcryptd(%s)", alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
goto out_free_inst;
memcpy(inst->alg.cra_name, alg->cra_name, CRYPTO_MAX_ALG_NAME);
inst->alg.cra_priority = alg->cra_priority + 50;
inst->alg.cra_blocksize = alg->cra_blocksize;
inst->alg.cra_alignmask = alg->cra_alignmask;
out:
return p;
out_free_inst:
kfree(p);
p = ERR_PTR(err);
goto out;
}
| 0 |
[
"CWE-476",
"CWE-284"
] |
linux
|
48a992727d82cb7db076fa15d372178743b1f4cd
| 290,433,386,508,496,420,000,000,000,000,000,000,000 | 32 |
crypto: mcryptd - Check mcryptd algorithm compatibility
Algorithms not compatible with mcryptd could be spawned by mcryptd
with a direct crypto_alloc_tfm invocation using a "mcryptd(alg)" name
construct. This causes mcryptd to crash the kernel if an arbitrary
"alg" is incompatible and not intended to be used with mcryptd. It is
an issue if AF_ALG tries to spawn mcryptd(alg) to expose it externally.
But such algorithms must be used internally and not be exposed.
We added a check to enforce that only internal algorithms are allowed
with mcryptd at the time mcryptd is spawning an algorithm.
Link: http://marc.info/?l=linux-crypto-vger&m=148063683310477&w=2
Cc: [email protected]
Reported-by: Mikulas Patocka <[email protected]>
Signed-off-by: Tim Chen <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
|
static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x,
int tos, int oif,
xfrm_address_t *prev_saddr,
xfrm_address_t *prev_daddr,
int family)
{
struct net *net = xs_net(x);
xfrm_address_t *saddr = &x->props.saddr;
xfrm_address_t *daddr = &x->id.daddr;
struct dst_entry *dst;
if (x->type->flags & XFRM_TYPE_LOCAL_COADDR) {
saddr = x->coaddr;
daddr = prev_daddr;
}
if (x->type->flags & XFRM_TYPE_REMOTE_COADDR) {
saddr = prev_saddr;
daddr = x->coaddr;
}
dst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family);
if (!IS_ERR(dst)) {
if (prev_saddr != saddr)
memcpy(prev_saddr, saddr, sizeof(*prev_saddr));
if (prev_daddr != daddr)
memcpy(prev_daddr, daddr, sizeof(*prev_daddr));
}
return dst;
}
| 0 |
[
"CWE-125"
] |
ipsec
|
7bab09631c2a303f87a7eb7e3d69e888673b9b7e
| 268,450,368,479,360,830,000,000,000,000,000,000,000 | 31 |
xfrm: policy: check policy direction value
The 'dir' parameter in xfrm_migrate() is a user-controlled byte which is used
as an array index. This can lead to an out-of-bound access, kernel lockup and
DoS. Add a check for the 'dir' value.
This fixes CVE-2017-11600.
References: https://bugzilla.redhat.com/show_bug.cgi?id=1474928
Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Cc: <[email protected]> # v2.6.21-rc1
Reported-by: "bo Zhang" <[email protected]>
Signed-off-by: Vladis Dronov <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
|
bool run(OperationContext* opCtx,
const string& dbname,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
AuthorizationManager* authzManager = getGlobalAuthorizationManager();
authzManager->invalidateUserCache();
return true;
}
| 0 |
[
"CWE-613"
] |
mongo
|
6dfb92b1299de04677d0bd2230e89a52eb01003c
| 24,735,935,237,327,966,000,000,000,000,000,000,000 | 8 |
SERVER-38984 Validate unique User ID on UserCache hit
(cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
|
static auto HasProxy(Local<Object> object) -> bool {
if (object->IsProxy()) {
return true;
} else {
auto proto = object->GetPrototype();
if (proto->IsNullOrUndefined()) {
return false;
} else {
return HasProxy(proto.As<Object>());
}
}
}
| 0 |
[
"CWE-913"
] |
isolated-vm
|
2646e6c1558bac66285daeab54c7d490ed332b15
| 251,814,947,870,994,130,000,000,000,000,000,000,000 | 12 |
Don't invoke accessors or proxies via Reference functions
|
LineBufferTask::LineBufferTask
(TaskGroup *group,
DeepScanLineInputFile::Data *ifd,
LineBuffer *lineBuffer,
int scanLineMin,
int scanLineMax)
:
Task (group),
_ifd (ifd),
_lineBuffer (lineBuffer),
_scanLineMin (scanLineMin),
_scanLineMax (scanLineMax)
{
// empty
}
| 0 |
[
"CWE-125"
] |
openexr
|
e79d2296496a50826a15c667bf92bdc5a05518b4
| 336,807,734,230,222,520,000,000,000,000,000,000,000 | 15 |
fix memory leaks and invalid memory accesses
Signed-off-by: Peter Hillman <[email protected]>
|
inline int Offset(const RuntimeShape& shape, int i0, int i1, int i2, int i3) {
TFLITE_DCHECK_EQ(shape.DimensionsCount(), 4);
const int* dims_data = reinterpret_cast<const int*>(shape.DimsDataUpTo5D());
TFLITE_DCHECK(i0 >= 0 && i0 < dims_data[0]);
TFLITE_DCHECK(i1 >= 0 && i1 < dims_data[1]);
TFLITE_DCHECK(i2 >= 0 && i2 < dims_data[2]);
TFLITE_DCHECK(i3 >= 0 && i3 < dims_data[3]);
return ((i0 * dims_data[1] + i1) * dims_data[2] + i2) * dims_data[3] + i3;
}
| 0 |
[
"CWE-125",
"CWE-787"
] |
tensorflow
|
8ee24e7949a203d234489f9da2c5bf45a7d5157d
| 43,978,641,213,846,830,000,000,000,000,000,000,000 | 9 |
[tflite] Ensure `MatchingDim` does not allow buffer overflow.
We check in `MatchingDim` that both arguments have the same dimensionality, however that is a `DCHECK` only enabled if building in debug mode. Hence, it could be possible to cause buffer overflows by passing in a tensor with larger dimensions as the second argument. To fix, we now make `MatchingDim` return the minimum of the two sizes.
A much better fix would be to return a status object but that requires refactoring a large part of the codebase for minor benefits.
PiperOrigin-RevId: 332526127
Change-Id: If627d0d2c80a685217b6e0d1e64b0872dbf1c5e4
|
inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *w, char *url) {
static uint32_t hash_action = 0, hash_access = 0, hash_hello = 0, hash_delete = 0, hash_search = 0,
hash_switch = 0, hash_machine = 0, hash_url = 0, hash_name = 0, hash_delete_url = 0, hash_for = 0,
hash_to = 0 /*, hash_redirects = 0 */;
if(unlikely(!hash_action)) {
hash_action = simple_hash("action");
hash_access = simple_hash("access");
hash_hello = simple_hash("hello");
hash_delete = simple_hash("delete");
hash_search = simple_hash("search");
hash_switch = simple_hash("switch");
hash_machine = simple_hash("machine");
hash_url = simple_hash("url");
hash_name = simple_hash("name");
hash_delete_url = simple_hash("delete_url");
hash_for = simple_hash("for");
hash_to = simple_hash("to");
/*
hash_redirects = simple_hash("redirects");
*/
}
char person_guid[GUID_LEN + 1] = "";
debug(D_WEB_CLIENT, "%llu: API v1 registry with URL '%s'", w->id, url);
// TODO
// The browser may send multiple cookies with our id
char *cookie = strstr(w->response.data->buffer, NETDATA_REGISTRY_COOKIE_NAME "=");
if(cookie)
strncpyz(person_guid, &cookie[sizeof(NETDATA_REGISTRY_COOKIE_NAME)], 36);
char action = '\0';
char *machine_guid = NULL,
*machine_url = NULL,
*url_name = NULL,
*search_machine_guid = NULL,
*delete_url = NULL,
*to_person_guid = NULL;
/*
int redirects = 0;
*/
while(url) {
char *value = mystrsep(&url, "?&");
if (!value || !*value) continue;
char *name = mystrsep(&value, "=");
if (!name || !*name) continue;
if (!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 registry query param '%s' with value '%s'", w->id, name, value);
uint32_t hash = simple_hash(name);
if(hash == hash_action && !strcmp(name, "action")) {
uint32_t vhash = simple_hash(value);
if(vhash == hash_access && !strcmp(value, "access")) action = 'A';
else if(vhash == hash_hello && !strcmp(value, "hello")) action = 'H';
else if(vhash == hash_delete && !strcmp(value, "delete")) action = 'D';
else if(vhash == hash_search && !strcmp(value, "search")) action = 'S';
else if(vhash == hash_switch && !strcmp(value, "switch")) action = 'W';
#ifdef NETDATA_INTERNAL_CHECKS
else error("unknown registry action '%s'", value);
#endif /* NETDATA_INTERNAL_CHECKS */
}
/*
else if(hash == hash_redirects && !strcmp(name, "redirects"))
redirects = atoi(value);
*/
else if(hash == hash_machine && !strcmp(name, "machine"))
machine_guid = value;
else if(hash == hash_url && !strcmp(name, "url"))
machine_url = value;
else if(action == 'A') {
if(hash == hash_name && !strcmp(name, "name"))
url_name = value;
}
else if(action == 'D') {
if(hash == hash_delete_url && !strcmp(name, "delete_url"))
delete_url = value;
}
else if(action == 'S') {
if(hash == hash_for && !strcmp(name, "for"))
search_machine_guid = value;
}
else if(action == 'W') {
if(hash == hash_to && !strcmp(name, "to"))
to_person_guid = value;
}
#ifdef NETDATA_INTERNAL_CHECKS
else error("unused registry URL parameter '%s' with value '%s'", name, value);
#endif /* NETDATA_INTERNAL_CHECKS */
}
if(unlikely(respect_web_browser_do_not_track_policy && web_client_has_donottrack(w))) {
buffer_flush(w->response.data);
buffer_sprintf(w->response.data, "Your web browser is sending 'DNT: 1' (Do Not Track). The registry requires persistent cookies on your browser to work.");
return 400;
}
if(unlikely(action == 'H')) {
// HELLO request, dashboard ACL
if(unlikely(!web_client_can_access_dashboard(w)))
return web_client_permission_denied(w);
}
else {
// everything else, registry ACL
if(unlikely(!web_client_can_access_registry(w)))
return web_client_permission_denied(w);
}
switch(action) {
case 'A':
if(unlikely(!machine_guid || !machine_url || !url_name)) {
error("Invalid registry request - access requires these parameters: machine ('%s'), url ('%s'), name ('%s')", machine_guid ? machine_guid : "UNSET", machine_url ? machine_url : "UNSET", url_name ? url_name : "UNSET");
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Invalid registry Access request.");
return 400;
}
web_client_enable_tracking_required(w);
return registry_request_access_json(host, w, person_guid, machine_guid, machine_url, url_name, now_realtime_sec());
case 'D':
if(unlikely(!machine_guid || !machine_url || !delete_url)) {
error("Invalid registry request - delete requires these parameters: machine ('%s'), url ('%s'), delete_url ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", delete_url?delete_url:"UNSET");
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Invalid registry Delete request.");
return 400;
}
web_client_enable_tracking_required(w);
return registry_request_delete_json(host, w, person_guid, machine_guid, machine_url, delete_url, now_realtime_sec());
case 'S':
if(unlikely(!machine_guid || !machine_url || !search_machine_guid)) {
error("Invalid registry request - search requires these parameters: machine ('%s'), url ('%s'), for ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", search_machine_guid?search_machine_guid:"UNSET");
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Invalid registry Search request.");
return 400;
}
web_client_enable_tracking_required(w);
return registry_request_search_json(host, w, person_guid, machine_guid, machine_url, search_machine_guid, now_realtime_sec());
case 'W':
if(unlikely(!machine_guid || !machine_url || !to_person_guid)) {
error("Invalid registry request - switching identity requires these parameters: machine ('%s'), url ('%s'), to ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", to_person_guid?to_person_guid:"UNSET");
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Invalid registry Switch request.");
return 400;
}
web_client_enable_tracking_required(w);
return registry_request_switch_json(host, w, person_guid, machine_guid, machine_url, to_person_guid, now_realtime_sec());
case 'H':
return registry_request_hello_json(host, w);
default:
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Invalid registry request - you need to set an action: hello, access, delete, search");
return 400;
}
}
| 0 |
[
"CWE-113",
"CWE-200",
"CWE-94",
"CWE-74"
] |
netdata
|
92327c9ec211bd1616315abcb255861b130b97ca
| 333,485,228,359,098,570,000,000,000,000,000,000,000 | 171 |
fixed vulnerabilities identified by red4sec.com (#4521)
|
array_param_enumerate(iparam_list * plist, gs_param_enumerator_t * penum,
gs_param_key_t * key, ref_type * type)
{
int index = penum->intval;
ref *bot = ((array_param_list *) plist)->bot;
ref *ptr = bot + index;
ref *top = ((array_param_list *) plist)->top;
for (; ptr < top; ptr += 2) {
index += 2;
if (r_has_type(ptr, t_name)) {
int code = ref_to_key(ptr, key, plist);
*type = r_type(ptr);
penum->intval = index;
return code;
}
}
return 1;
}
| 0 |
[] |
ghostpdl
|
bfa6b2ecbe48edc69a7d9d22a12419aed25960b8
| 79,319,050,370,758,320,000,000,000,000,000,000,000 | 21 |
Bug 697548: use the correct param list enumerator
When we encountered dictionary in a ref_param_list, we were using the enumerator
for the "parent" param_list, rather than the enumerator for the param_list
we just created for the dictionary. That parent was usually the stack
list enumerator, and caused a segfault.
Using the correct enumerator works better.
|
bool GetDouble(const json &o, double &val) {
if (o.IsDouble()) {
val = o.GetDouble();
return true;
}
return false;
}
| 0 |
[
"CWE-20"
] |
tinygltf
|
52ff00a38447f06a17eab1caa2cf0730a119c751
| 204,957,506,159,124,400,000,000,000,000,000,000,000 | 8 |
Do not expand file path since its not necessary for glTF asset path(URI) and for security reason(`wordexp`).
|
BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine[6], gdRectPtr bbox)
{
gdPointF extent[4], min, max, point;
int i;
extent[0].x=0.0;
extent[0].y=0.0;
extent[1].x=(double) src->width;
extent[1].y=0.0;
extent[2].x=(double) src->width;
extent[2].y=(double) src->height;
extent[3].x=0.0;
extent[3].y=(double) src->height;
for (i=0; i < 4; i++) {
point=extent[i];
if (gdAffineApplyToPointF(&extent[i], &point, affine) != GD_TRUE) {
return GD_FALSE;
}
}
min=extent[0];
max=extent[0];
for (i=1; i < 4; i++) {
if (min.x > extent[i].x)
min.x=extent[i].x;
if (min.y > extent[i].y)
min.y=extent[i].y;
if (max.x < extent[i].x)
max.x=extent[i].x;
if (max.y < extent[i].y)
max.y=extent[i].y;
}
bbox->x = (int) min.x;
bbox->y = (int) min.y;
bbox->width = (int) ceil((max.x - min.x)) + 1;
bbox->height = (int) ceil(max.y - min.y) + 1;
return GD_TRUE;
}
| 0 |
[
"CWE-125",
"CWE-191"
] |
libgd
|
60bfb401ad5a4a8ae995dcd36372fe15c71e1a35
| 277,044,981,811,378,340,000,000,000,000,000,000,000 | 40 |
Fix potential unsigned underflow
No need to decrease `u`, so we don't do it. While we're at it, we also factor
out the overflow check of the loop, what improves performance and readability.
This issue has been reported by Stefan Esser to [email protected].
|
QVariantMap PostgreSqlStorage::setupDefaults() const
{
QVariantMap map;
map["Username"] = QVariant(QString("quassel"));
map["Hostname"] = QVariant(QString("localhost"));
map["Port"] = QVariant(5432);
map["Database"] = QVariant(QString("quassel"));
return map;
}
| 0 |
[
"CWE-89"
] |
quassel
|
aa1008be162cb27da938cce93ba533f54d228869
| 41,108,517,889,995,080,000,000,000,000,000,000,000 | 9 |
Fixing security vulnerability with Qt 4.8.5+ and PostgreSQL.
Properly detects whether Qt performs slash escaping in SQL queries or
not, and then configures PostgreSQL accordingly. This bug was a
introduced due to a bugfix in Qt 4.8.5 disables slash escaping when
binding queries: https://bugreports.qt-project.org/browse/QTBUG-30076
Thanks to brot and Tucos.
[Fixes #1244]
|
bool is_object3d(const CImgList<tp>& primitives,
const CImgList<tc>& colors,
const to& opacities,
const bool full_check=true,
char *const error_message=0) const {
if (error_message) *error_message = 0;
// Check consistency for the particular case of an empty 3D object.
if (is_empty()) {
if (primitives || colors || opacities) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines no vertices but %u primitives, "
"%u colors and %lu opacities",
_width,primitives._width,primitives._width,
colors._width,(unsigned long)opacities.size());
return false;
}
return true;
}
// Check consistency of vertices.
if (_height!=3 || _depth>1 || _spectrum>1) { // Check vertices dimensions
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) has invalid vertex dimensions (%u,%u,%u,%u)",
_width,primitives._width,_width,_height,_depth,_spectrum);
return false;
}
if (colors._width>primitives._width + 1) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines %u colors",
_width,primitives._width,colors._width);
return false;
}
if (opacities.size()>primitives._width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines %lu opacities",
_width,primitives._width,(unsigned long)opacities.size());
return false;
}
if (!full_check) return true;
// Check consistency of primitives.
cimglist_for(primitives,l) {
const CImg<tp>& primitive = primitives[l];
const unsigned int psiz = (unsigned int)primitive.size();
switch (psiz) {
case 1 : { // Point
const unsigned int i0 = (unsigned int)primitive(0);
if (i0>=_width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) refers to invalid vertex index %u in "
"point primitive [%u]",
_width,primitives._width,i0,l);
return false;
}
} break;
case 5 : { // Sphere
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1);
if (i0>=_width || i1>=_width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) refers to invalid vertex indices (%u,%u) in "
"sphere primitive [%u]",
_width,primitives._width,i0,i1,l);
return false;
}
} break;
case 2 : case 6 : { // Segment
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1);
if (i0>=_width || i1>=_width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) refers to invalid vertex indices (%u,%u) in "
"segment primitive [%u]",
_width,primitives._width,i0,i1,l);
return false;
}
} break;
case 3 : case 9 : { // Triangle
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1),
i2 = (unsigned int)primitive(2);
if (i0>=_width || i1>=_width || i2>=_width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) refers to invalid vertex indices (%u,%u,%u) in "
"triangle primitive [%u]",
_width,primitives._width,i0,i1,i2,l);
return false;
}
} break;
case 4 : case 12 : { // Quadrangle
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1),
i2 = (unsigned int)primitive(2),
i3 = (unsigned int)primitive(3);
if (i0>=_width || i1>=_width || i2>=_width || i3>=_width) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) refers to invalid vertex indices (%u,%u,%u,%u) in "
"quadrangle primitive [%u]",
_width,primitives._width,i0,i1,i2,i3,l);
return false;
}
} break;
default :
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines an invalid primitive [%u] of size %u",
_width,primitives._width,l,(unsigned int)psiz);
return false;
}
}
// Check consistency of colors.
cimglist_for(colors,c) {
const CImg<tc>& color = colors[c];
if (!color) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines no color for primitive [%u]",
_width,primitives._width,c);
return false;
}
}
// Check consistency of light texture.
if (colors._width>primitives._width) {
const CImg<tc> &light = colors.back();
if (!light || light._depth>1) {
if (error_message) cimg_sprintf(error_message,
"3D object (%u,%u) defines an invalid light texture (%u,%u,%u,%u)",
_width,primitives._width,light._width,
light._height,light._depth,light._spectrum);
return false;
}
}
return true;
}
| 0 |
[
"CWE-770"
] |
cimg
|
619cb58dd90b4e03ac68286c70ed98acbefd1c90
| 174,210,837,273,718,560,000,000,000,000,000,000,000 | 140 |
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
|
explicit operator std::basic_string_view<Char>() const FMT_NOEXCEPT {
return std::basic_string_view<Char>(data_, size_);
}
| 0 |
[
"CWE-134",
"CWE-119",
"CWE-787"
] |
fmt
|
8cf30aa2be256eba07bb1cefb998c52326e846e7
| 108,229,696,443,656,100,000,000,000,000,000,000,000 | 3 |
Fix segfault on complex pointer formatting (#642)
|
do_writekey (app_t app, ctrl_t ctrl,
const char *keyid, unsigned int flags,
gpg_error_t (*pincb)(void*, const char *, char **),
void *pincb_arg,
const unsigned char *keydata, size_t keydatalen)
{
gpg_error_t err;
int force = (flags & 1);
int keyno;
const unsigned char *buf, *tok;
size_t buflen, toklen;
int depth;
(void)ctrl;
if (!strcmp (keyid, "OPENPGP.1"))
keyno = 0;
else if (!strcmp (keyid, "OPENPGP.2"))
keyno = 1;
else if (!strcmp (keyid, "OPENPGP.3"))
keyno = 2;
else
return gpg_error (GPG_ERR_INV_ID);
err = does_key_exist (app, keyno, 0, force);
if (err)
return err;
/*
Parse the S-expression
*/
buf = keydata;
buflen = keydatalen;
depth = 0;
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave;
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave;
if (!tok || toklen != 11 || memcmp ("private-key", tok, toklen))
{
if (!tok)
;
else if (toklen == 21 && !memcmp ("protected-private-key", tok, toklen))
log_info ("protected-private-key passed to writekey\n");
else if (toklen == 20 && !memcmp ("shadowed-private-key", tok, toklen))
log_info ("shadowed-private-key passed to writekey\n");
err = gpg_error (GPG_ERR_BAD_SECKEY);
goto leave;
}
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave;
if ((err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)))
goto leave;
if (tok && toklen == 3 && memcmp ("rsa", tok, toklen) == 0)
err = rsa_writekey (app, pincb, pincb_arg, keyno, buf, buflen, depth);
else if (tok
&& ((toklen == 3 && memcmp ("ecc", tok, toklen) == 0)
|| (toklen == 4 && memcmp ("ecdh", tok, toklen) == 0)
|| (toklen == 5 && memcmp ("ecdsa", tok, toklen) == 0)))
err = ecc_writekey (app, pincb, pincb_arg, keyno, buf, buflen, depth);
else
{
err = gpg_error (GPG_ERR_WRONG_PUBKEY_ALGO);
goto leave;
}
leave:
return err;
}
| 0 |
[
"CWE-20"
] |
gnupg
|
2183683bd633818dd031b090b5530951de76f392
| 64,012,351,864,837,760,000,000,000,000,000,000,000 | 70 |
Use inline functions to convert buffer data to scalars.
* common/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.
--
Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to
avoid all sign extension on shift problems. Hanno Böck found a case
with an invalid read due to this problem. To fix that once and for
all almost all uses of "<< 24" and "<< 8" are changed by this patch to
use an inline function from host2net.h.
Signed-off-by: Werner Koch <[email protected]>
|
static __cold void io_rsrc_node_ref_zero(struct percpu_ref *ref)
{
struct io_rsrc_node *node = container_of(ref, struct io_rsrc_node, refs);
struct io_ring_ctx *ctx = node->rsrc_data->ctx;
unsigned long flags;
bool first_add = false;
unsigned long delay = HZ;
spin_lock_irqsave(&ctx->rsrc_ref_lock, flags);
node->done = true;
/* if we are mid-quiesce then do not delay */
if (node->rsrc_data->quiesce)
delay = 0;
while (!list_empty(&ctx->rsrc_ref_list)) {
node = list_first_entry(&ctx->rsrc_ref_list,
struct io_rsrc_node, node);
/* recycle ref nodes in order */
if (!node->done)
break;
list_del(&node->node);
first_add |= llist_add(&node->llist, &ctx->rsrc_put_llist);
}
spin_unlock_irqrestore(&ctx->rsrc_ref_lock, flags);
if (first_add)
mod_delayed_work(system_wq, &ctx->rsrc_put_work, delay);
| 0 |
[
"CWE-416"
] |
linux
|
e677edbcabee849bfdd43f1602bccbecf736a646
| 326,471,359,714,580,500,000,000,000,000,000,000,000 | 29 |
io_uring: fix race between timeout flush and removal
io_flush_timeouts() assumes the timeout isn't in progress of triggering
or being removed/canceled, so it unconditionally removes it from the
timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care
of it.
Cc: [email protected] # 5.5+
Signed-off-by: Jens Axboe <[email protected]>
|
static int server_verify(SSL *s)
{
unsigned char *p;
if (s->state == SSL2_ST_SEND_SERVER_VERIFY_A) {
p = (unsigned char *)s->init_buf->data;
*(p++) = SSL2_MT_SERVER_VERIFY;
if (s->s2->challenge_length > sizeof s->s2->challenge) {
SSLerr(SSL_F_SERVER_VERIFY, ERR_R_INTERNAL_ERROR);
return -1;
}
memcpy(p, s->s2->challenge, (unsigned int)s->s2->challenge_length);
/* p+=s->s2->challenge_length; */
s->state = SSL2_ST_SEND_SERVER_VERIFY_B;
s->init_num = s->s2->challenge_length + 1;
s->init_off = 0;
}
return (ssl2_do_write(s));
}
| 0 |
[
"CWE-20"
] |
openssl
|
86f8fb0e344d62454f8daf3e15236b2b59210756
| 160,114,509,024,936,650,000,000,000,000,000,000,000 | 20 |
Fix reachable assert in SSLv2 servers.
This assert is reachable for servers that support SSLv2 and export ciphers.
Therefore, such servers can be DoSed by sending a specially crafted
SSLv2 CLIENT-MASTER-KEY.
Also fix s2_srvr.c to error out early if the key lengths are malformed.
These lengths are sent unencrypted, so this does not introduce an oracle.
CVE-2015-0293
This issue was discovered by Sean Burford (Google) and Emilia Käsper of
the OpenSSL development team.
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Tim Hudson <[email protected]>
|
static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{
struct usb_composite_dev *cdev = f->config->cdev;
struct f_hidg *hidg = func_to_hidg(f);
struct usb_request *req_in = NULL;
unsigned long flags;
int i, status = 0;
VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt);
if (hidg->in_ep != NULL) {
/* restart endpoint */
usb_ep_disable(hidg->in_ep);
status = config_ep_by_speed(f->config->cdev->gadget, f,
hidg->in_ep);
if (status) {
ERROR(cdev, "config_ep_by_speed FAILED!\n");
goto fail;
}
status = usb_ep_enable(hidg->in_ep);
if (status < 0) {
ERROR(cdev, "Enable IN endpoint FAILED!\n");
goto fail;
}
hidg->in_ep->driver_data = hidg;
req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length);
if (!req_in) {
status = -ENOMEM;
goto disable_ep_in;
}
}
if (hidg->out_ep != NULL) {
/* restart endpoint */
usb_ep_disable(hidg->out_ep);
status = config_ep_by_speed(f->config->cdev->gadget, f,
hidg->out_ep);
if (status) {
ERROR(cdev, "config_ep_by_speed FAILED!\n");
goto free_req_in;
}
status = usb_ep_enable(hidg->out_ep);
if (status < 0) {
ERROR(cdev, "Enable OUT endpoint FAILED!\n");
goto free_req_in;
}
hidg->out_ep->driver_data = hidg;
/*
* allocate a bunch of read buffers and queue them all at once.
*/
for (i = 0; i < hidg->qlen && status == 0; i++) {
struct usb_request *req =
hidg_alloc_ep_req(hidg->out_ep,
hidg->report_length);
if (req) {
req->complete = hidg_set_report_complete;
req->context = hidg;
status = usb_ep_queue(hidg->out_ep, req,
GFP_ATOMIC);
if (status) {
ERROR(cdev, "%s queue req --> %d\n",
hidg->out_ep->name, status);
free_ep_req(hidg->out_ep, req);
}
} else {
status = -ENOMEM;
goto disable_out_ep;
}
}
}
if (hidg->in_ep != NULL) {
spin_lock_irqsave(&hidg->write_spinlock, flags);
hidg->req = req_in;
hidg->write_pending = 0;
spin_unlock_irqrestore(&hidg->write_spinlock, flags);
wake_up(&hidg->write_queue);
}
return 0;
disable_out_ep:
usb_ep_disable(hidg->out_ep);
free_req_in:
if (req_in)
free_ep_req(hidg->in_ep, req_in);
disable_ep_in:
if (hidg->in_ep)
usb_ep_disable(hidg->in_ep);
fail:
return status;
}
| 0 |
[
"CWE-703",
"CWE-667",
"CWE-189"
] |
linux
|
072684e8c58d17e853f8e8b9f6d9ce2e58d2b036
| 248,033,249,179,123,200,000,000,000,000,000,000,000 | 98 |
USB: gadget: f_hid: fix deadlock in f_hidg_write()
In f_hidg_write() the write_spinlock is acquired before calling
usb_ep_queue() which causes a deadlock when dummy_hcd is being used.
This is because dummy_queue() callbacks into f_hidg_req_complete() which
tries to acquire the same spinlock. This is (part of) the backtrace when
the deadlock occurs:
0xffffffffc06b1410 in f_hidg_req_complete
0xffffffffc06a590a in usb_gadget_giveback_request
0xffffffffc06cfff2 in dummy_queue
0xffffffffc06a4b96 in usb_ep_queue
0xffffffffc06b1eb6 in f_hidg_write
0xffffffff8127730b in __vfs_write
0xffffffff812774d1 in vfs_write
0xffffffff81277725 in SYSC_write
Fix this by releasing the write_spinlock before calling usb_ep_queue()
Reviewed-by: James Bottomley <[email protected]>
Tested-by: James Bottomley <[email protected]>
Cc: [email protected] # 4.11+
Fixes: 749494b6bdbb ("usb: gadget: f_hid: fix: Move IN request allocation to set_alt()")
Signed-off-by: Radoslav Gerganov <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
|
void set_peername_from_env(address_t *p, const char *env)
{
struct addrinfo hints = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV,
};
struct addrinfo *result;
char *c;
int s;
char *val = getenv(env);
csync_debug(3, "getenv(%s): >>%s<<\n", env, val ?: "");
if (!val)
return;
val = strdup(val);
if (!val)
return;
c = strchr(val, ' ');
if (!c)
return;
*c = '\0';
s = getaddrinfo(val, NULL, &hints, &result);
if (s != 0) {
csync_debug(1, "getaddrinfo: %s\n", gai_strerror(s));
return;
}
/* getaddrinfo() may return a list of address structures.
* Use the first one. */
if (result)
memcpy(p, result->ai_addr, result->ai_addrlen);
freeaddrinfo(result);
}
| 0 |
[
"CWE-703"
] |
csync2
|
416f1de878ef97e27e27508914f7ba8599a0be22
| 21,550,688,669,947,400,000,000,000,000,000,000,000 | 36 |
fail HELLO command when SSL is required
|
int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
struct kernfs_root *kf_root)
{
int len = 0;
char *buf = NULL;
struct cgroup_root *kf_cgroot = cgroup_root_from_kf(kf_root);
struct cgroup *ns_cgroup;
buf = kmalloc(PATH_MAX, GFP_KERNEL);
if (!buf)
return -ENOMEM;
spin_lock_irq(&css_set_lock);
ns_cgroup = current_cgns_cgroup_from_root(kf_cgroot);
len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
spin_unlock_irq(&css_set_lock);
if (len >= PATH_MAX)
len = -ERANGE;
else if (len > 0) {
seq_escape(sf, buf, " \t\n\\");
len = 0;
}
kfree(buf);
return len;
}
| 0 |
[
"CWE-416"
] |
linux
|
a06247c6804f1a7c86a2e5398a4c1f1db1471848
| 129,731,635,190,061,660,000,000,000,000,000,000,000 | 26 |
psi: Fix uaf issue when psi trigger is destroyed while being polled
With write operation on psi files replacing old trigger with a new one,
the lifetime of its waitqueue is totally arbitrary. Overwriting an
existing trigger causes its waitqueue to be freed and pending poll()
will stumble on trigger->event_wait which was destroyed.
Fix this by disallowing to redefine an existing psi trigger. If a write
operation is used on a file descriptor with an already existing psi
trigger, the operation will fail with EBUSY error.
Also bypass a check for psi_disabled in the psi_trigger_destroy as the
flag can be flipped after the trigger is created, leading to a memory
leak.
Fixes: 0e94682b73bf ("psi: introduce psi monitor")
Reported-by: [email protected]
Suggested-by: Linus Torvalds <[email protected]>
Analyzed-by: Eric Biggers <[email protected]>
Signed-off-by: Suren Baghdasaryan <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Eric Biggers <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
|
u32 gf_filter_get_max_extra_input_pids(GF_Filter *filter)
{
if (filter) return filter->max_extra_pids;
return 0;
}
| 0 |
[
"CWE-787"
] |
gpac
|
da37ec8582266983d0ec4b7550ec907401ec441e
| 189,061,151,764,658,300,000,000,000,000,000,000,000 | 5 |
fixed crashes for very long path - cf #1908
|
char closing_bracket_for(char opening_bracket) {
switch (opening_bracket) {
case '(': return ')';
case '[': return ']';
case '{': return '}';
default: return '\0';
}
}
| 0 |
[
"CWE-674"
] |
libsass
|
f2db04883e5fff4e03777dcc1eb60d4373c45be1
| 316,493,626,908,357,470,000,000,000,000,000,000,000 | 8 |
Make `parse_css_variable_value` non-recursive
Fixes #2658 stack overflow
|
struct section_t *MACH0_(get_sections)(struct MACH0_(obj_t) *bin) {
r_return_val_if_fail (bin, NULL);
struct section_t *sections;
char sectname[64], raw_segname[17];
size_t i, j, to;
/* for core files */
if (bin->nsects < 1 && bin->nsegs > 0) {
struct MACH0_(segment_command) *seg;
if (!(sections = calloc ((bin->nsegs + 1), sizeof (struct section_t)))) {
return NULL;
}
for (i = 0; i < bin->nsegs; i++) {
seg = &bin->segs[i];
sections[i].addr = seg->vmaddr;
sections[i].offset = seg->fileoff;
sections[i].size = seg->vmsize;
sections[i].vsize = seg->vmsize;
sections[i].align = 4096;
sections[i].flags = seg->flags;
r_str_ncpy (sectname, seg->segname, 16);
sectname[16] = 0;
r_str_filter (sectname, -1);
// hack to support multiple sections with same name
sections[i].perm = prot2perm (seg->initprot);
sections[i].last = 0;
}
sections[i].last = 1;
return sections;
}
if (!bin->sects) {
return NULL;
}
to = R_MIN (bin->nsects, 128); // limit number of sections here to avoid fuzzed bins
if (to < 1) {
return NULL;
}
if (!(sections = calloc (bin->nsects + 1, sizeof (struct section_t)))) {
return NULL;
}
for (i = 0; i < to; i++) {
sections[i].offset = (ut64)bin->sects[i].offset;
sections[i].addr = (ut64)bin->sects[i].addr;
sections[i].size = (bin->sects[i].flags == S_ZEROFILL) ? 0 : (ut64)bin->sects[i].size;
sections[i].vsize = (ut64)bin->sects[i].size;
sections[i].align = bin->sects[i].align;
sections[i].flags = bin->sects[i].flags;
r_str_ncpy (sectname, bin->sects[i].sectname, 17);
r_str_filter (sectname, -1);
r_str_ncpy (raw_segname, bin->sects[i].segname, 16);
for (j = 0; j < bin->nsegs; j++) {
if (sections[i].addr >= bin->segs[j].vmaddr &&
sections[i].addr < (bin->segs[j].vmaddr + bin->segs[j].vmsize)) {
sections[i].perm = prot2perm (bin->segs[j].initprot);
break;
}
}
snprintf (sections[i].name, sizeof (sections[i].name),
"%d.%s.%s", (int)i, raw_segname, sectname);
sections[i].last = 0;
}
sections[i].last = 1;
return sections;
}
| 0 |
[
"CWE-125",
"CWE-787"
] |
radare2
|
0052500c1ed5bf8263b26b9fd7773dbdc6f170c4
| 318,376,465,022,977,000,000,000,000,000,000,000,000 | 65 |
Fix heap OOB read in macho.iterate_chained_fixups ##crash
* Reported by peacock-doris via huntr.dev
* Reproducer 'tests_65305'
mrmacete:
* Return early if segs_count is 0
* Initialize segs_count also for reconstructed fixups
Co-authored-by: pancake <[email protected]>
Co-authored-by: Francesco Tamagni <[email protected]>
|
parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
cbc_opcode_t opcode) /**< opcode */
{
if (PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode)
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
{
parser_check_invalid_assign (context_p);
uint16_t unary_opcode;
if (opcode == CBC_DELETE_PUSH_RESULT)
{
if (JERRY_UNLIKELY (context_p->status_flags & PARSER_IS_STRICT))
{
parser_raise_error (context_p, PARSER_ERR_DELETE_IDENT_NOT_ALLOWED);
}
unary_opcode = CBC_DELETE_IDENT_PUSH_RESULT;
}
else
{
JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_LITERAL, opcode + CBC_UNARY_LVALUE_WITH_IDENT));
unary_opcode = (uint16_t) (opcode + CBC_UNARY_LVALUE_WITH_IDENT);
}
parser_emit_ident_reference (context_p, unary_opcode);
#if JERRY_ESNEXT
if (unary_opcode != CBC_DELETE_IDENT_PUSH_RESULT
&& scanner_literal_is_const_reg (context_p, context_p->last_cbc.literal_index))
{
/* The current value must be read, but it cannot be changed. */
context_p->last_cbc_opcode = CBC_PUSH_LITERAL;
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_ASSIGN_CONST_ERROR);
}
#endif /* JERRY_ESNEXT */
return;
}
if (context_p->last_cbc_opcode == CBC_PUSH_PROP)
{
JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_PROP, opcode));
context_p->last_cbc_opcode = (uint16_t) opcode;
return;
}
if (PARSER_IS_PUSH_PROP_LITERAL (context_p->last_cbc_opcode))
{
context_p->last_cbc_opcode = PARSER_PUSH_PROP_LITERAL_TO_PUSH_LITERAL (context_p->last_cbc_opcode);
}
else
{
/* Invalid LeftHandSide expression. */
if (opcode == CBC_DELETE_PUSH_RESULT)
{
#if JERRY_ESNEXT
if (context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP_LITERAL)
|| context_p->last_cbc_opcode == PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_SUPER_PROP))
{
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
parser_emit_cbc (context_p, CBC_POP);
return;
}
#endif /* JERRY_ESNEXT */
parser_emit_cbc (context_p, CBC_POP);
parser_emit_cbc (context_p, CBC_PUSH_TRUE);
return;
}
#if JERRY_ESNEXT
parser_check_invalid_new_target (context_p, opcode);
if (opcode == CBC_PRE_INCR || opcode == CBC_PRE_DECR)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_PREFIX_OP);
}
else
{
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_POSTFIX_OP);
}
#else /* JERRY_ESNEXT */
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
#endif /* JERRY_ESNEXT */
}
parser_emit_cbc (context_p, (uint16_t) opcode);
} /* parser_emit_unary_lvalue_opcode */
| 0 |
[
"CWE-416"
] |
jerryscript
|
3bcd48f72d4af01d1304b754ef19fe1a02c96049
| 291,707,890,636,327,440,000,000,000,000,000,000,000 | 86 |
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 sds getDotfilePath(char *envoverride, char *dotfilename) {
char *path = NULL;
sds dotPath = NULL;
/* Check the env for a dotfile override. */
path = getenv(envoverride);
if (path != NULL && *path != '\0') {
if (!strcmp("/dev/null", path)) {
return NULL;
}
/* If the env is set, return it. */
dotPath = sdsnew(path);
} else {
char *home = getenv("HOME");
if (home != NULL && *home != '\0') {
/* If no override is set use $HOME/<dotfilename>. */
dotPath = sdscatprintf(sdsempty(), "%s/%s", home, dotfilename);
}
}
return dotPath;
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
redis
|
9fdcc15962f9ff4baebe6fdd947816f43f730d50
| 181,689,025,627,478,650,000,000,000,000,000,000,000 | 22 |
Security: fix redis-cli buffer overflow.
Thanks to Fakhri Zulkifli for reporting it.
The fix switched to dynamic allocation, copying the final prompt in the
static buffer only at the end.
|
static void sig_print_starting(TEXT_DEST_REC *dest)
{
GSList *tmp;
if (printing_splits)
return;
for (tmp = servers; tmp != NULL; tmp = tmp->next) {
IRC_SERVER_REC *rec = tmp->data;
if (IS_IRC_SERVER(rec) && rec->split_servers != NULL)
print_splits(rec, NULL);
}
}
| 0 |
[
"CWE-416"
] |
irssi
|
38ba3ca2c40fc8ccccec8dc3f360c4087e7dd498
| 244,226,466,868,386,680,000,000,000,000,000,000,000 | 14 |
Merge pull request #824 from dequis/more-netsplit-revert
Revert more of the netsplit print optimisation to fix crashes
(cherry picked from commit cfcc021c81eea84bd982a64764f62e163128acf3)
|
xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,
const struct xfrm_tmpl *tmpl,
const xfrm_address_t *daddr, const xfrm_address_t *saddr,
unsigned short family)
{
struct xfrm_state_afinfo *afinfo = xfrm_state_afinfo_get_rcu(family);
if (!afinfo)
return;
afinfo->init_tempsel(&x->sel, fl);
if (family != tmpl->encap_family) {
afinfo = xfrm_state_afinfo_get_rcu(tmpl->encap_family);
if (!afinfo)
return;
}
afinfo->init_temprop(x, tmpl, daddr, saddr);
}
| 0 |
[
"CWE-416"
] |
linux
|
dbb2483b2a46fbaf833cfb5deb5ed9cace9c7399
| 291,562,276,539,108,860,000,000,000,000,000,000,000 | 19 |
xfrm: clean up xfrm protocol checks
In commit 6a53b7593233 ("xfrm: check id proto in validate_tmpl()")
I introduced a check for xfrm protocol, but according to Herbert
IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so
it should be removed from validate_tmpl().
And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific
protocols, this is why xfrm_state_flush() could still miss
IPPROTO_ROUTING, which leads that those entries are left in
net->xfrm.state_all before exit net. Fix this by replacing
IPSEC_PROTO_ANY with zero.
This patch also extracts the check from validate_tmpl() to
xfrm_id_proto_valid() and uses it in parse_ipsecrequest().
With this, no other protocols should be added into xfrm.
Fixes: 6a53b7593233 ("xfrm: check id proto in validate_tmpl()")
Reported-by: [email protected]
Cc: Steffen Klassert <[email protected]>
Cc: Herbert Xu <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Herbert Xu <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
|
rl_dump_variables (count, key)
int count, key;
{
if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
rl_variable_dumper (rl_explicit_arg);
rl_on_new_line ();
return (0);
}
| 0 |
[] |
bash
|
955543877583837c85470f7fb8a97b7aa8d45e6c
| 198,007,944,884,442,380,000,000,000,000,000,000,000 | 9 |
bash-4.4-rc2 release
|
term_pipeline_destination(j_compress_ptr cinfo)
{
QTC::TC("libtests", "Pl_DCT term_pipeline_destination");
dct_pipeline_dest* dest =
reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer);
}
| 0 |
[
"CWE-787"
] |
qpdf
|
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
| 147,949,179,554,189,760,000,000,000,000,000,000,000 | 7 |
Fix sign and conversion warnings (major)
This makes all integer type conversions that have potential data loss
explicit with calls that do range checks and raise an exception. After
this commit, qpdf builds with no warnings when -Wsign-conversion
-Wconversion is used with gcc or clang or when -W3 -Wd4800 is used
with MSVC. This significantly reduces the likelihood of potential
crashes from bogus integer values.
There are some parts of the code that take int when they should take
size_t or an offset. Such places would make qpdf not support files
with more than 2^31 of something that usually wouldn't be so large. In
the event that such a file shows up and is valid, at least qpdf would
raise an error in the right spot so the issue could be legitimately
addressed rather than failing in some weird way because of a silent
overflow condition.
|
static Status BuildDenseFeatureReader(const Tensor& values,
FeatureReaders* features) {
if (values.dtype() == DT_INT64) {
features->emplace_back(new DenseFeatureReader<int64>(values));
} else if (values.dtype() == DT_STRING) {
features->emplace_back(new DenseFeatureReader<tstring>(values));
} else {
return errors::InvalidArgument("Unexpected dtype for input ",
(features->size() + 1), ": ",
values.dtype());
}
return Status::OK();
}
| 0 |
[
"CWE-125",
"CWE-369"
] |
tensorflow
|
44b7f486c0143f68b56c34e2d01e146ee445134a
| 338,820,867,445,986,470,000,000,000,000,000,000,000 | 13 |
Fix out of bounds read in `ragged_cross_op.cc`.
PiperOrigin-RevId: 369757702
Change-Id: Ie6e5d2c21513a8d56bf41fcf35960caf76e890f9
|
static_runner() {
// Boost uses the current locale to generate a UTF-8 one
std::locale utf8_loc = boost::locale::generator().generate("");
// use a custom locale becasue we want to use out log.hpp functions in case of an invalid string.
utf8_loc = std::locale(utf8_loc, new customcodecvt());
boost::filesystem::path::imbue(utf8_loc);
}
| 0 |
[
"CWE-200"
] |
wesnoth
|
f8914468182e8d0a1551b430c0879ba236fe4d6d
| 88,564,048,742,028,850,000,000,000,000,000,000,000 | 7 |
Disallow inclusion of .pbl files from WML (bug #23504)
Note that this will also cause Lua wesnoth.have_file() to return false
on .pbl files.
|
static int multi_getsock(struct Curl_easy *data,
curl_socket_t *socks, /* points to numsocks number
of sockets */
int numsocks)
{
/* If the pipe broke, or if there's no connection left for this easy handle,
then we MUST bail out now with no bitmask set. The no connection case can
happen when this is called from curl_multi_remove_handle() =>
singlesocket() => multi_getsock().
*/
if(data->state.pipe_broke || !data->easy_conn)
return 0;
if(data->mstate > CURLM_STATE_CONNECT &&
data->mstate < CURLM_STATE_COMPLETED) {
/* Set up ownership correctly */
data->easy_conn->data = data;
}
switch(data->mstate) {
default:
#if 0 /* switch back on these cases to get the compiler to check for all enums
to be present */
case CURLM_STATE_TOOFAST: /* returns 0, so will not select. */
case CURLM_STATE_COMPLETED:
case CURLM_STATE_MSGSENT:
case CURLM_STATE_INIT:
case CURLM_STATE_CONNECT:
case CURLM_STATE_WAITDO:
case CURLM_STATE_DONE:
case CURLM_STATE_LAST:
/* this will get called with CURLM_STATE_COMPLETED when a handle is
removed */
#endif
return 0;
case CURLM_STATE_WAITRESOLVE:
return Curl_resolver_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_PROTOCONNECT:
case CURLM_STATE_SENDPROTOCONNECT:
return Curl_protocol_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_DO:
case CURLM_STATE_DOING:
return Curl_doing_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_WAITPROXYCONNECT:
return waitproxyconnect_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_WAITCONNECT:
return waitconnect_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_DO_MORE:
return domore_getsock(data->easy_conn, socks, numsocks);
case CURLM_STATE_DO_DONE: /* since is set after DO is completed, we switch
to waiting for the same as the *PERFORM
states */
case CURLM_STATE_PERFORM:
case CURLM_STATE_WAITPERFORM:
return Curl_single_getsock(data->easy_conn, socks, numsocks);
}
}
| 0 |
[
"CWE-416"
] |
curl
|
75dc096e01ef1e21b6c57690d99371dedb2c0b80
| 121,395,772,026,207,340,000,000,000,000,000,000,000 | 65 |
curl_multi_cleanup: clear connection pointer for easy handles
CVE-2016-5421
Bug: https://curl.haxx.se/docs/adv_20160803C.html
Reported-by: Marcelo Echeverria and Fernando Muñoz
|
void StreamEncoderImpl::endEncode() {
if (chunk_encoding_) {
connection_.buffer().add(LAST_CHUNK);
connection_.buffer().add(CRLF);
}
connection_.flushOutput(true);
connection_.onEncodeComplete();
}
| 0 |
[
"CWE-770"
] |
envoy
|
7ca28ff7d46454ae930e193d97b7d08156b1ba59
| 72,325,814,536,476,370,000,000,000,000,000,000,000 | 9 |
[http1] Include request URL in request header size computation, and reject partial headers that exceed configured limits (#145)
Signed-off-by: antonio <[email protected]>
|
void sock_pfree(struct sk_buff *skb)
{
if (sk_is_refcounted(skb->sk))
sock_gen_put(skb->sk);
}
| 0 |
[] |
net
|
35306eb23814444bd4021f8a1c3047d3cb0c8b2b
| 148,813,987,816,136,580,000,000,000,000,000,000,000 | 5 |
af_unix: fix races in sk_peer_pid and sk_peer_cred accesses
Jann Horn reported that SO_PEERCRED and SO_PEERGROUPS implementations
are racy, as af_unix can concurrently change sk_peer_pid and sk_peer_cred.
In order to fix this issue, this patch adds a new spinlock that needs
to be used whenever these fields are read or written.
Jann also pointed out that l2cap_sock_get_peer_pid_cb() is currently
reading sk->sk_peer_pid which makes no sense, as this field
is only possibly set by AF_UNIX sockets.
We will have to clean this in a separate patch.
This could be done by reverting b48596d1dc25 "Bluetooth: L2CAP: Add get_peer_pid callback"
or implementing what was truly expected.
Fixes: 109f6e39fa07 ("af_unix: Allow SO_PEERCRED to work across namespaces.")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Jann Horn <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Cc: Luiz Augusto von Dentz <[email protected]>
Cc: Marcel Holtmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
acceptSubAssoc(T_ASC_Network *aNet, T_ASC_Association **assoc)
{
const char *knownAbstractSyntaxes[] = {
UID_VerificationSOPClass
};
const char *transferSyntaxes[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
int numTransferSyntaxes;
OFString temp_str;
OFCondition cond = ASC_receiveAssociation(aNet, assoc, opt_maxPDU);
if (cond.good())
{
OFLOG_INFO(movescuLogger, "Sub-Association Received");
OFLOG_DEBUG(movescuLogger, "Parameters:" << OFendl << ASC_dumpParameters(temp_str, (*assoc)->params, ASC_ASSOC_RQ));
switch (opt_in_networkTransferSyntax)
{
case EXS_LittleEndianImplicit:
/* we only support Little Endian Implicit */
transferSyntaxes[0] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 1;
break;
case EXS_LittleEndianExplicit:
/* we prefer Little Endian Explicit */
transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
break;
case EXS_BigEndianExplicit:
/* we prefer Big Endian Explicit */
transferSyntaxes[0] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
break;
case EXS_JPEGProcess14SV1:
/* we prefer JPEGLossless:Hierarchical-1stOrderPrediction (default lossless) */
transferSyntaxes[0] = UID_JPEGProcess14SV1TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEGProcess1:
/* we prefer JPEGBaseline (default lossy for 8 bit images) */
transferSyntaxes[0] = UID_JPEGProcess1TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEGProcess2_4:
/* we prefer JPEGExtended (default lossy for 12 bit images) */
transferSyntaxes[0] = UID_JPEGProcess2_4TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEG2000LosslessOnly:
/* we prefer JPEG2000 Lossless */
transferSyntaxes[0] = UID_JPEG2000LosslessOnlyTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEG2000:
/* we prefer JPEG2000 Lossy */
transferSyntaxes[0] = UID_JPEG2000TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEGLSLossless:
/* we prefer JPEG-LS Lossless */
transferSyntaxes[0] = UID_JPEGLSLosslessTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_JPEGLSLossy:
/* we prefer JPEG-LS Lossy */
transferSyntaxes[0] = UID_JPEGLSLossyTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_MPEG2MainProfileAtMainLevel:
/* we prefer MPEG2 MP@ML */
transferSyntaxes[0] = UID_MPEG2MainProfileAtMainLevelTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_MPEG2MainProfileAtHighLevel:
/* we prefer MPEG2 MP@HL */
transferSyntaxes[0] = UID_MPEG2MainProfileAtHighLevelTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_MPEG4HighProfileLevel4_1:
/* we prefer MPEG4 HP/L4.1 */
transferSyntaxes[0] = UID_MPEG4HighProfileLevel4_1TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_MPEG4BDcompatibleHighProfileLevel4_1:
/* we prefer MPEG4 BD HP/L4.1 */
transferSyntaxes[0] = UID_MPEG4BDcompatibleHighProfileLevel4_1TransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
case EXS_RLELossless:
/* we prefer RLE Lossless */
transferSyntaxes[0] = UID_RLELosslessTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
#ifdef WITH_ZLIB
case EXS_DeflatedLittleEndianExplicit:
/* we prefer Deflated Explicit VR Little Endian */
transferSyntaxes[0] = UID_DeflatedExplicitVRLittleEndianTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[2] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[3] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 4;
break;
#endif
default:
if (opt_acceptAllXfers)
{
/* we accept all supported transfer syntaxes
* (similar to "AnyTransferSyntax" in "storescp.cfg")
*/
transferSyntaxes[0] = UID_JPEG2000TransferSyntax;
transferSyntaxes[1] = UID_JPEG2000LosslessOnlyTransferSyntax;
transferSyntaxes[2] = UID_JPEGProcess2_4TransferSyntax;
transferSyntaxes[3] = UID_JPEGProcess1TransferSyntax;
transferSyntaxes[4] = UID_JPEGProcess14SV1TransferSyntax;
transferSyntaxes[5] = UID_JPEGLSLossyTransferSyntax;
transferSyntaxes[6] = UID_JPEGLSLosslessTransferSyntax;
transferSyntaxes[7] = UID_RLELosslessTransferSyntax;
transferSyntaxes[8] = UID_MPEG2MainProfileAtMainLevelTransferSyntax;
transferSyntaxes[9] = UID_MPEG2MainProfileAtHighLevelTransferSyntax;
transferSyntaxes[10] = UID_MPEG4HighProfileLevel4_1TransferSyntax;
transferSyntaxes[11] = UID_MPEG4BDcompatibleHighProfileLevel4_1TransferSyntax;
transferSyntaxes[12] = UID_DeflatedExplicitVRLittleEndianTransferSyntax;
if (gLocalByteOrder == EBO_LittleEndian)
{
transferSyntaxes[13] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[14] = UID_BigEndianExplicitTransferSyntax;
} else {
transferSyntaxes[13] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[14] = UID_LittleEndianExplicitTransferSyntax;
}
transferSyntaxes[15] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 16;
} else {
/* We prefer explicit transfer syntaxes.
* If we are running on a Little Endian machine we prefer
* LittleEndianExplicitTransferSyntax to BigEndianTransferSyntax.
*/
if (gLocalByteOrder == EBO_LittleEndian) /* defined in dcxfer.h */
{
transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
} else {
transferSyntaxes[0] = UID_BigEndianExplicitTransferSyntax;
transferSyntaxes[1] = UID_LittleEndianExplicitTransferSyntax;
}
transferSyntaxes[2] = UID_LittleEndianImplicitTransferSyntax;
numTransferSyntaxes = 3;
}
break;
}
/* accept the Verification SOP Class if presented */
cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
(*assoc)->params,
knownAbstractSyntaxes, DIM_OF(knownAbstractSyntaxes),
transferSyntaxes, numTransferSyntaxes);
if (cond.good())
{
/* the array of Storage SOP Class UIDs comes from dcuid.h */
cond = ASC_acceptContextsWithPreferredTransferSyntaxes(
(*assoc)->params,
dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs,
transferSyntaxes, numTransferSyntaxes);
}
}
if (cond.good())
cond = ASC_acknowledgeAssociation(*assoc);
if (cond.good())
{
OFLOG_INFO(movescuLogger, "Sub-Association Acknowledged (Max Send PDV: " << (*assoc)->sendPDVLength << ")");
if (ASC_countAcceptedPresentationContexts((*assoc)->params) == 0)
OFLOG_INFO(movescuLogger, " (but no valid presentation contexts)");
/* dump the presentation contexts which have been accepted/refused */
OFLOG_DEBUG(movescuLogger, ASC_dumpParameters(temp_str, (*assoc)->params, ASC_ASSOC_AC));
} else {
OFLOG_ERROR(movescuLogger, DimseCondition::dump(temp_str, cond));
ASC_dropAssociation(*assoc);
ASC_destroyAssociation(assoc);
}
return cond;
}
| 0 |
[
"CWE-264"
] |
dcmtk
|
beaf5a5c24101daeeafa48c375120b16197c9e95
| 58,953,864,742,492,300,000,000,000,000,000,000,000 | 222 |
Make sure to handle setuid() return code properly.
In some tools the return value of setuid() is not checked. In the worst
case this could lead to privilege escalation since the process does not
give up its root privileges and continue as root.
|
networkstatus_compute_consensus(smartlist_t *votes,
int total_authorities,
crypto_pk_t *identity_key,
crypto_pk_t *signing_key,
const char *legacy_id_key_digest,
crypto_pk_t *legacy_signing_key,
consensus_flavor_t flavor)
{
smartlist_t *chunks;
char *result = NULL;
int consensus_method;
time_t valid_after, fresh_until, valid_until;
int vote_seconds, dist_seconds;
char *client_versions = NULL, *server_versions = NULL;
smartlist_t *flags;
const char *flavor_name;
uint32_t max_unmeasured_bw_kb = DEFAULT_MAX_UNMEASURED_BW_KB;
int64_t G=0, M=0, E=0, D=0, T=0; /* For bandwidth weights */
const routerstatus_format_type_t rs_format =
flavor == FLAV_NS ? NS_V3_CONSENSUS : NS_V3_CONSENSUS_MICRODESC;
char *params = NULL;
char *packages = NULL;
int added_weights = 0;
dircollator_t *collator = NULL;
smartlist_t *param_list = NULL;
tor_assert(flavor == FLAV_NS || flavor == FLAV_MICRODESC);
tor_assert(total_authorities >= smartlist_len(votes));
tor_assert(total_authorities > 0);
flavor_name = networkstatus_get_flavor_name(flavor);
if (!smartlist_len(votes)) {
log_warn(LD_DIR, "Can't compute a consensus from no votes.");
return NULL;
}
flags = smartlist_new();
consensus_method = compute_consensus_method(votes);
if (consensus_method_is_supported(consensus_method)) {
log_info(LD_DIR, "Generating consensus using method %d.",
consensus_method);
} else {
log_warn(LD_DIR, "The other authorities will use consensus method %d, "
"which I don't support. Maybe I should upgrade!",
consensus_method);
consensus_method = MAX_SUPPORTED_CONSENSUS_METHOD;
}
/* Compute medians of time-related things, and figure out how many
* routers we might need to talk about. */
{
int n_votes = smartlist_len(votes);
time_t *va_times = tor_calloc(n_votes, sizeof(time_t));
time_t *fu_times = tor_calloc(n_votes, sizeof(time_t));
time_t *vu_times = tor_calloc(n_votes, sizeof(time_t));
int *votesec_list = tor_calloc(n_votes, sizeof(int));
int *distsec_list = tor_calloc(n_votes, sizeof(int));
int n_versioning_clients = 0, n_versioning_servers = 0;
smartlist_t *combined_client_versions = smartlist_new();
smartlist_t *combined_server_versions = smartlist_new();
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
tor_assert(v->type == NS_TYPE_VOTE);
va_times[v_sl_idx] = v->valid_after;
fu_times[v_sl_idx] = v->fresh_until;
vu_times[v_sl_idx] = v->valid_until;
votesec_list[v_sl_idx] = v->vote_seconds;
distsec_list[v_sl_idx] = v->dist_seconds;
if (v->client_versions) {
smartlist_t *cv = smartlist_new();
++n_versioning_clients;
smartlist_split_string(cv, v->client_versions, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
sort_version_list(cv, 1);
smartlist_add_all(combined_client_versions, cv);
smartlist_free(cv); /* elements get freed later. */
}
if (v->server_versions) {
smartlist_t *sv = smartlist_new();
++n_versioning_servers;
smartlist_split_string(sv, v->server_versions, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
sort_version_list(sv, 1);
smartlist_add_all(combined_server_versions, sv);
smartlist_free(sv); /* elements get freed later. */
}
SMARTLIST_FOREACH(v->known_flags, const char *, cp,
smartlist_add(flags, tor_strdup(cp)));
} SMARTLIST_FOREACH_END(v);
valid_after = median_time(va_times, n_votes);
fresh_until = median_time(fu_times, n_votes);
valid_until = median_time(vu_times, n_votes);
vote_seconds = median_int(votesec_list, n_votes);
dist_seconds = median_int(distsec_list, n_votes);
tor_assert(valid_after +
(get_options()->TestingTorNetwork ?
MIN_VOTE_INTERVAL_TESTING : MIN_VOTE_INTERVAL) <= fresh_until);
tor_assert(fresh_until +
(get_options()->TestingTorNetwork ?
MIN_VOTE_INTERVAL_TESTING : MIN_VOTE_INTERVAL) <= valid_until);
tor_assert(vote_seconds >= MIN_VOTE_SECONDS);
tor_assert(dist_seconds >= MIN_DIST_SECONDS);
server_versions = compute_consensus_versions_list(combined_server_versions,
n_versioning_servers);
client_versions = compute_consensus_versions_list(combined_client_versions,
n_versioning_clients);
if (consensus_method >= MIN_METHOD_FOR_PACKAGE_LINES) {
packages = compute_consensus_package_lines(votes);
} else {
packages = tor_strdup("");
}
SMARTLIST_FOREACH(combined_server_versions, char *, cp, tor_free(cp));
SMARTLIST_FOREACH(combined_client_versions, char *, cp, tor_free(cp));
smartlist_free(combined_server_versions);
smartlist_free(combined_client_versions);
if (consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING)
smartlist_add(flags, tor_strdup("NoEdConsensus"));
smartlist_sort_strings(flags);
smartlist_uniq_strings(flags);
tor_free(va_times);
tor_free(fu_times);
tor_free(vu_times);
tor_free(votesec_list);
tor_free(distsec_list);
}
chunks = smartlist_new();
{
char va_buf[ISO_TIME_LEN+1], fu_buf[ISO_TIME_LEN+1],
vu_buf[ISO_TIME_LEN+1];
char *flaglist;
format_iso_time(va_buf, valid_after);
format_iso_time(fu_buf, fresh_until);
format_iso_time(vu_buf, valid_until);
flaglist = smartlist_join_strings(flags, " ", 0, NULL);
smartlist_add_asprintf(chunks, "network-status-version 3%s%s\n"
"vote-status consensus\n",
flavor == FLAV_NS ? "" : " ",
flavor == FLAV_NS ? "" : flavor_name);
smartlist_add_asprintf(chunks, "consensus-method %d\n",
consensus_method);
smartlist_add_asprintf(chunks,
"valid-after %s\n"
"fresh-until %s\n"
"valid-until %s\n"
"voting-delay %d %d\n"
"client-versions %s\n"
"server-versions %s\n"
"%s" /* packages */
"known-flags %s\n",
va_buf, fu_buf, vu_buf,
vote_seconds, dist_seconds,
client_versions, server_versions,
packages,
flaglist);
tor_free(flaglist);
}
if (consensus_method >= MIN_METHOD_FOR_RECOMMENDED_PROTOCOLS) {
int num_dirauth = get_n_authorities(V3_DIRINFO);
int idx;
for (idx = 0; idx < 4; ++idx) {
char *proto_line = compute_nth_protocol_set(idx, num_dirauth, votes);
if (BUG(!proto_line))
continue;
smartlist_add(chunks, proto_line);
}
}
param_list = dirvote_compute_params(votes, consensus_method,
total_authorities);
if (smartlist_len(param_list)) {
params = smartlist_join_strings(param_list, " ", 0, NULL);
smartlist_add(chunks, tor_strdup("params "));
smartlist_add(chunks, params);
smartlist_add(chunks, tor_strdup("\n"));
}
if (consensus_method >= MIN_METHOD_FOR_SHARED_RANDOM) {
int num_dirauth = get_n_authorities(V3_DIRINFO);
/* Default value of this is 2/3 of the total number of authorities. For
* instance, if we have 9 dirauth, the default value is 6. The following
* calculation will round it down. */
int32_t num_srv_agreements =
dirvote_get_intermediate_param_value(param_list,
"AuthDirNumSRVAgreements",
(num_dirauth * 2) / 3);
/* Add the shared random value. */
char *srv_lines = sr_get_string_for_consensus(votes, num_srv_agreements);
if (srv_lines != NULL) {
smartlist_add(chunks, srv_lines);
}
}
/* Sort the votes. */
smartlist_sort(votes, compare_votes_by_authority_id_);
/* Add the authority sections. */
{
smartlist_t *dir_sources = smartlist_new();
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
dir_src_ent_t *e = tor_malloc_zero(sizeof(dir_src_ent_t));
e->v = v;
e->digest = get_voter(v)->identity_digest;
e->is_legacy = 0;
smartlist_add(dir_sources, e);
if (!tor_digest_is_zero(get_voter(v)->legacy_id_digest)) {
dir_src_ent_t *e_legacy = tor_malloc_zero(sizeof(dir_src_ent_t));
e_legacy->v = v;
e_legacy->digest = get_voter(v)->legacy_id_digest;
e_legacy->is_legacy = 1;
smartlist_add(dir_sources, e_legacy);
}
} SMARTLIST_FOREACH_END(v);
smartlist_sort(dir_sources, compare_dir_src_ents_by_authority_id_);
SMARTLIST_FOREACH_BEGIN(dir_sources, const dir_src_ent_t *, e) {
char fingerprint[HEX_DIGEST_LEN+1];
char votedigest[HEX_DIGEST_LEN+1];
networkstatus_t *v = e->v;
networkstatus_voter_info_t *voter = get_voter(v);
base16_encode(fingerprint, sizeof(fingerprint), e->digest, DIGEST_LEN);
base16_encode(votedigest, sizeof(votedigest), voter->vote_digest,
DIGEST_LEN);
smartlist_add_asprintf(chunks,
"dir-source %s%s %s %s %s %d %d\n",
voter->nickname, e->is_legacy ? "-legacy" : "",
fingerprint, voter->address, fmt_addr32(voter->addr),
voter->dir_port,
voter->or_port);
if (! e->is_legacy) {
smartlist_add_asprintf(chunks,
"contact %s\n"
"vote-digest %s\n",
voter->contact,
votedigest);
}
} SMARTLIST_FOREACH_END(e);
SMARTLIST_FOREACH(dir_sources, dir_src_ent_t *, e, tor_free(e));
smartlist_free(dir_sources);
}
if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW) {
char *max_unmeasured_param = NULL;
/* XXXX Extract this code into a common function. Or don't! see #19011 */
if (params) {
if (strcmpstart(params, "maxunmeasuredbw=") == 0)
max_unmeasured_param = params;
else
max_unmeasured_param = strstr(params, " maxunmeasuredbw=");
}
if (max_unmeasured_param) {
int ok = 0;
char *eq = strchr(max_unmeasured_param, '=');
if (eq) {
max_unmeasured_bw_kb = (uint32_t)
tor_parse_ulong(eq+1, 10, 1, UINT32_MAX, &ok, NULL);
if (!ok) {
log_warn(LD_DIR, "Bad element '%s' in max unmeasured bw param",
escaped(max_unmeasured_param));
max_unmeasured_bw_kb = DEFAULT_MAX_UNMEASURED_BW_KB;
}
}
}
}
/* Add the actual router entries. */
{
int *size; /* size[j] is the number of routerstatuses in votes[j]. */
int *flag_counts; /* The number of voters that list flag[j] for the
* currently considered router. */
int i;
smartlist_t *matching_descs = smartlist_new();
smartlist_t *chosen_flags = smartlist_new();
smartlist_t *versions = smartlist_new();
smartlist_t *protocols = smartlist_new();
smartlist_t *exitsummaries = smartlist_new();
uint32_t *bandwidths_kb = tor_calloc(smartlist_len(votes),
sizeof(uint32_t));
uint32_t *measured_bws_kb = tor_calloc(smartlist_len(votes),
sizeof(uint32_t));
uint32_t *measured_guardfraction = tor_calloc(smartlist_len(votes),
sizeof(uint32_t));
int num_bandwidths;
int num_mbws;
int num_guardfraction_inputs;
int *n_voter_flags; /* n_voter_flags[j] is the number of flags that
* votes[j] knows about. */
int *n_flag_voters; /* n_flag_voters[f] is the number of votes that care
* about flags[f]. */
int **flag_map; /* flag_map[j][b] is an index f such that flag_map[f]
* is the same flag as votes[j]->known_flags[b]. */
int *named_flag; /* Index of the flag "Named" for votes[j] */
int *unnamed_flag; /* Index of the flag "Unnamed" for votes[j] */
int n_authorities_measuring_bandwidth;
strmap_t *name_to_id_map = strmap_new();
char conflict[DIGEST_LEN];
char unknown[DIGEST_LEN];
memset(conflict, 0, sizeof(conflict));
memset(unknown, 0xff, sizeof(conflict));
size = tor_calloc(smartlist_len(votes), sizeof(int));
n_voter_flags = tor_calloc(smartlist_len(votes), sizeof(int));
n_flag_voters = tor_calloc(smartlist_len(flags), sizeof(int));
flag_map = tor_calloc(smartlist_len(votes), sizeof(int *));
named_flag = tor_calloc(smartlist_len(votes), sizeof(int));
unnamed_flag = tor_calloc(smartlist_len(votes), sizeof(int));
for (i = 0; i < smartlist_len(votes); ++i)
unnamed_flag[i] = named_flag[i] = -1;
/* Build the flag indexes. Note that no vote can have more than 64 members
* for known_flags, so no value will be greater than 63, so it's safe to
* do U64_LITERAL(1) << index on these values. But note also that
* named_flag and unnamed_flag are initialized to -1, so we need to check
* that they're actually set before doing U64_LITERAL(1) << index with
* them.*/
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
flag_map[v_sl_idx] = tor_calloc(smartlist_len(v->known_flags),
sizeof(int));
if (smartlist_len(v->known_flags) > MAX_KNOWN_FLAGS_IN_VOTE) {
log_warn(LD_BUG, "Somehow, a vote has %d entries in known_flags",
smartlist_len(v->known_flags));
}
SMARTLIST_FOREACH_BEGIN(v->known_flags, const char *, fl) {
int p = smartlist_string_pos(flags, fl);
tor_assert(p >= 0);
flag_map[v_sl_idx][fl_sl_idx] = p;
++n_flag_voters[p];
if (!strcmp(fl, "Named"))
named_flag[v_sl_idx] = fl_sl_idx;
if (!strcmp(fl, "Unnamed"))
unnamed_flag[v_sl_idx] = fl_sl_idx;
} SMARTLIST_FOREACH_END(fl);
n_voter_flags[v_sl_idx] = smartlist_len(v->known_flags);
size[v_sl_idx] = smartlist_len(v->routerstatus_list);
} SMARTLIST_FOREACH_END(v);
/* Named and Unnamed get treated specially */
{
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
uint64_t nf;
if (named_flag[v_sl_idx]<0)
continue;
nf = U64_LITERAL(1) << named_flag[v_sl_idx];
SMARTLIST_FOREACH_BEGIN(v->routerstatus_list,
vote_routerstatus_t *, rs) {
if ((rs->flags & nf) != 0) {
const char *d = strmap_get_lc(name_to_id_map, rs->status.nickname);
if (!d) {
/* We have no name officially mapped to this digest. */
strmap_set_lc(name_to_id_map, rs->status.nickname,
rs->status.identity_digest);
} else if (d != conflict &&
fast_memcmp(d, rs->status.identity_digest, DIGEST_LEN)) {
/* Authorities disagree about this nickname. */
strmap_set_lc(name_to_id_map, rs->status.nickname, conflict);
} else {
/* It's already a conflict, or it's already this ID. */
}
}
} SMARTLIST_FOREACH_END(rs);
} SMARTLIST_FOREACH_END(v);
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
uint64_t uf;
if (unnamed_flag[v_sl_idx]<0)
continue;
uf = U64_LITERAL(1) << unnamed_flag[v_sl_idx];
SMARTLIST_FOREACH_BEGIN(v->routerstatus_list,
vote_routerstatus_t *, rs) {
if ((rs->flags & uf) != 0) {
const char *d = strmap_get_lc(name_to_id_map, rs->status.nickname);
if (d == conflict || d == unknown) {
/* Leave it alone; we know what it is. */
} else if (!d) {
/* We have no name officially mapped to this digest. */
strmap_set_lc(name_to_id_map, rs->status.nickname, unknown);
} else if (fast_memeq(d, rs->status.identity_digest, DIGEST_LEN)) {
/* Authorities disagree about this nickname. */
strmap_set_lc(name_to_id_map, rs->status.nickname, conflict);
} else {
/* It's mapped to a different name. */
}
}
} SMARTLIST_FOREACH_END(rs);
} SMARTLIST_FOREACH_END(v);
}
/* We need to know how many votes measure bandwidth. */
n_authorities_measuring_bandwidth = 0;
SMARTLIST_FOREACH(votes, const networkstatus_t *, v,
if (v->has_measured_bws) {
++n_authorities_measuring_bandwidth;
}
);
/* Populate the collator */
collator = dircollator_new(smartlist_len(votes), total_authorities);
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
dircollator_add_vote(collator, v);
} SMARTLIST_FOREACH_END(v);
dircollator_collate(collator, consensus_method);
/* Now go through all the votes */
flag_counts = tor_calloc(smartlist_len(flags), sizeof(int));
const int num_routers = dircollator_n_routers(collator);
for (i = 0; i < num_routers; ++i) {
vote_routerstatus_t **vrs_lst =
dircollator_get_votes_for_router(collator, i);
vote_routerstatus_t *rs;
routerstatus_t rs_out;
const char *current_rsa_id = NULL;
const char *chosen_version;
const char *chosen_protocol_list;
const char *chosen_name = NULL;
int exitsummary_disagreement = 0;
int is_named = 0, is_unnamed = 0, is_running = 0, is_valid = 0;
int is_guard = 0, is_exit = 0, is_bad_exit = 0;
int naming_conflict = 0;
int n_listing = 0;
char microdesc_digest[DIGEST256_LEN];
tor_addr_port_t alt_orport = {TOR_ADDR_NULL, 0};
memset(flag_counts, 0, sizeof(int)*smartlist_len(flags));
smartlist_clear(matching_descs);
smartlist_clear(chosen_flags);
smartlist_clear(versions);
smartlist_clear(protocols);
num_bandwidths = 0;
num_mbws = 0;
num_guardfraction_inputs = 0;
int ed_consensus = 0;
const uint8_t *ed_consensus_val = NULL;
/* Okay, go through all the entries for this digest. */
for (int voter_idx = 0; voter_idx < smartlist_len(votes); ++voter_idx) {
if (vrs_lst[voter_idx] == NULL)
continue; /* This voter had nothing to say about this entry. */
rs = vrs_lst[voter_idx];
++n_listing;
current_rsa_id = rs->status.identity_digest;
smartlist_add(matching_descs, rs);
if (rs->version && rs->version[0])
smartlist_add(versions, rs->version);
if (rs->protocols) {
/* We include this one even if it's empty: voting for an
* empty protocol list actually is meaningful. */
smartlist_add(protocols, rs->protocols);
}
/* Tally up all the flags. */
for (int flag = 0; flag < n_voter_flags[voter_idx]; ++flag) {
if (rs->flags & (U64_LITERAL(1) << flag))
++flag_counts[flag_map[voter_idx][flag]];
}
if (named_flag[voter_idx] >= 0 &&
(rs->flags & (U64_LITERAL(1) << named_flag[voter_idx]))) {
if (chosen_name && strcmp(chosen_name, rs->status.nickname)) {
log_notice(LD_DIR, "Conflict on naming for router: %s vs %s",
chosen_name, rs->status.nickname);
naming_conflict = 1;
}
chosen_name = rs->status.nickname;
}
/* Count guardfraction votes and note down the values. */
if (rs->status.has_guardfraction) {
measured_guardfraction[num_guardfraction_inputs++] =
rs->status.guardfraction_percentage;
}
/* count bandwidths */
if (rs->has_measured_bw)
measured_bws_kb[num_mbws++] = rs->measured_bw_kb;
if (rs->status.has_bandwidth)
bandwidths_kb[num_bandwidths++] = rs->status.bandwidth_kb;
/* Count number for which ed25519 is canonical. */
if (rs->ed25519_reflects_consensus) {
++ed_consensus;
if (ed_consensus_val) {
tor_assert(fast_memeq(ed_consensus_val, rs->ed25519_id,
ED25519_PUBKEY_LEN));
} else {
ed_consensus_val = rs->ed25519_id;
}
}
}
/* We don't include this router at all unless more than half of
* the authorities we believe in list it. */
if (n_listing <= total_authorities/2)
continue;
if (ed_consensus > 0) {
tor_assert(consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING);
if (ed_consensus <= total_authorities / 2) {
log_warn(LD_BUG, "Not enough entries had ed_consensus set; how "
"can we have a consensus of %d?", ed_consensus);
}
}
/* The clangalyzer can't figure out that this will never be NULL
* if n_listing is at least 1 */
tor_assert(current_rsa_id);
/* Figure out the most popular opinion of what the most recent
* routerinfo and its contents are. */
memset(microdesc_digest, 0, sizeof(microdesc_digest));
rs = compute_routerstatus_consensus(matching_descs, consensus_method,
microdesc_digest, &alt_orport);
/* Copy bits of that into rs_out. */
memset(&rs_out, 0, sizeof(rs_out));
tor_assert(fast_memeq(current_rsa_id,
rs->status.identity_digest,DIGEST_LEN));
memcpy(rs_out.identity_digest, current_rsa_id, DIGEST_LEN);
memcpy(rs_out.descriptor_digest, rs->status.descriptor_digest,
DIGEST_LEN);
rs_out.addr = rs->status.addr;
rs_out.published_on = rs->status.published_on;
rs_out.dir_port = rs->status.dir_port;
rs_out.or_port = rs->status.or_port;
if (consensus_method >= MIN_METHOD_FOR_A_LINES) {
tor_addr_copy(&rs_out.ipv6_addr, &alt_orport.addr);
rs_out.ipv6_orport = alt_orport.port;
}
rs_out.has_bandwidth = 0;
rs_out.has_exitsummary = 0;
if (chosen_name && !naming_conflict) {
strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname));
} else {
strlcpy(rs_out.nickname, rs->status.nickname, sizeof(rs_out.nickname));
}
{
const char *d = strmap_get_lc(name_to_id_map, rs_out.nickname);
if (!d) {
is_named = is_unnamed = 0;
} else if (fast_memeq(d, current_rsa_id, DIGEST_LEN)) {
is_named = 1; is_unnamed = 0;
} else {
is_named = 0; is_unnamed = 1;
}
}
/* Set the flags. */
smartlist_add(chosen_flags, (char*)"s"); /* for the start of the line. */
SMARTLIST_FOREACH_BEGIN(flags, const char *, fl) {
if (!strcmp(fl, "Named")) {
if (is_named)
smartlist_add(chosen_flags, (char*)fl);
} else if (!strcmp(fl, "Unnamed")) {
if (is_unnamed)
smartlist_add(chosen_flags, (char*)fl);
} else if (!strcmp(fl, "NoEdConsensus") &&
consensus_method >= MIN_METHOD_FOR_ED25519_ID_VOTING) {
if (ed_consensus <= total_authorities/2)
smartlist_add(chosen_flags, (char*)fl);
} else {
if (flag_counts[fl_sl_idx] > n_flag_voters[fl_sl_idx]/2) {
smartlist_add(chosen_flags, (char*)fl);
if (!strcmp(fl, "Exit"))
is_exit = 1;
else if (!strcmp(fl, "Guard"))
is_guard = 1;
else if (!strcmp(fl, "Running"))
is_running = 1;
else if (!strcmp(fl, "BadExit"))
is_bad_exit = 1;
else if (!strcmp(fl, "Valid"))
is_valid = 1;
}
}
} SMARTLIST_FOREACH_END(fl);
/* Starting with consensus method 4 we do not list servers
* that are not running in a consensus. See Proposal 138 */
if (!is_running)
continue;
/* Starting with consensus method 24, we don't list servers
* that are not valid in a consensus. See Proposal 272 */
if (!is_valid &&
consensus_method >= MIN_METHOD_FOR_EXCLUDING_INVALID_NODES)
continue;
/* Pick the version. */
if (smartlist_len(versions)) {
sort_version_list(versions, 0);
chosen_version = get_most_frequent_member(versions);
} else {
chosen_version = NULL;
}
/* Pick the protocol list */
if (smartlist_len(protocols)) {
smartlist_sort_strings(protocols);
chosen_protocol_list = get_most_frequent_member(protocols);
} else {
chosen_protocol_list = NULL;
}
/* If it's a guard and we have enough guardfraction votes,
calculate its consensus guardfraction value. */
if (is_guard && num_guardfraction_inputs > 2 &&
consensus_method >= MIN_METHOD_FOR_GUARDFRACTION) {
rs_out.has_guardfraction = 1;
rs_out.guardfraction_percentage = median_uint32(measured_guardfraction,
num_guardfraction_inputs);
/* final value should be an integer percentage! */
tor_assert(rs_out.guardfraction_percentage <= 100);
}
/* Pick a bandwidth */
if (num_mbws > 2) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 0;
rs_out.bandwidth_kb = median_uint32(measured_bws_kb, num_mbws);
} else if (num_bandwidths > 0) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 1;
rs_out.bandwidth_kb = median_uint32(bandwidths_kb, num_bandwidths);
if (consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW &&
n_authorities_measuring_bandwidth > 2) {
/* Cap non-measured bandwidths. */
if (rs_out.bandwidth_kb > max_unmeasured_bw_kb) {
rs_out.bandwidth_kb = max_unmeasured_bw_kb;
}
}
}
/* Fix bug 2203: Do not count BadExit nodes as Exits for bw weights */
is_exit = is_exit && !is_bad_exit;
/* Update total bandwidth weights with the bandwidths of this router. */
{
update_total_bandwidth_weights(&rs_out,
is_exit, is_guard,
&G, &M, &E, &D, &T);
}
/* Ok, we already picked a descriptor digest we want to list
* previously. Now we want to use the exit policy summary from
* that descriptor. If everybody plays nice all the voters who
* listed that descriptor will have the same summary. If not then
* something is fishy and we'll use the most common one (breaking
* ties in favor of lexicographically larger one (only because it
* lets me reuse more existing code)).
*
* The other case that can happen is that no authority that voted
* for that descriptor has an exit policy summary. That's
* probably quite unlikely but can happen. In that case we use
* the policy that was most often listed in votes, again breaking
* ties like in the previous case.
*/
{
/* Okay, go through all the votes for this router. We prepared
* that list previously */
const char *chosen_exitsummary = NULL;
smartlist_clear(exitsummaries);
SMARTLIST_FOREACH_BEGIN(matching_descs, vote_routerstatus_t *, vsr) {
/* Check if the vote where this status comes from had the
* proper descriptor */
tor_assert(fast_memeq(rs_out.identity_digest,
vsr->status.identity_digest,
DIGEST_LEN));
if (vsr->status.has_exitsummary &&
fast_memeq(rs_out.descriptor_digest,
vsr->status.descriptor_digest,
DIGEST_LEN)) {
tor_assert(vsr->status.exitsummary);
smartlist_add(exitsummaries, vsr->status.exitsummary);
if (!chosen_exitsummary) {
chosen_exitsummary = vsr->status.exitsummary;
} else if (strcmp(chosen_exitsummary, vsr->status.exitsummary)) {
/* Great. There's disagreement among the voters. That
* really shouldn't be */
exitsummary_disagreement = 1;
}
}
} SMARTLIST_FOREACH_END(vsr);
if (exitsummary_disagreement) {
char id[HEX_DIGEST_LEN+1];
char dd[HEX_DIGEST_LEN+1];
base16_encode(id, sizeof(dd), rs_out.identity_digest, DIGEST_LEN);
base16_encode(dd, sizeof(dd), rs_out.descriptor_digest, DIGEST_LEN);
log_warn(LD_DIR, "The voters disagreed on the exit policy summary "
" for router %s with descriptor %s. This really shouldn't"
" have happened.", id, dd);
smartlist_sort_strings(exitsummaries);
chosen_exitsummary = get_most_frequent_member(exitsummaries);
} else if (!chosen_exitsummary) {
char id[HEX_DIGEST_LEN+1];
char dd[HEX_DIGEST_LEN+1];
base16_encode(id, sizeof(dd), rs_out.identity_digest, DIGEST_LEN);
base16_encode(dd, sizeof(dd), rs_out.descriptor_digest, DIGEST_LEN);
log_warn(LD_DIR, "Not one of the voters that made us select"
"descriptor %s for router %s had an exit policy"
"summary", dd, id);
/* Ok, none of those voting for the digest we chose had an
* exit policy for us. Well, that kinda sucks.
*/
smartlist_clear(exitsummaries);
SMARTLIST_FOREACH(matching_descs, vote_routerstatus_t *, vsr, {
if (vsr->status.has_exitsummary)
smartlist_add(exitsummaries, vsr->status.exitsummary);
});
smartlist_sort_strings(exitsummaries);
chosen_exitsummary = get_most_frequent_member(exitsummaries);
if (!chosen_exitsummary)
log_warn(LD_DIR, "Wow, not one of the voters had an exit "
"policy summary for %s. Wow.", id);
}
if (chosen_exitsummary) {
rs_out.has_exitsummary = 1;
/* yea, discards the const */
rs_out.exitsummary = (char *)chosen_exitsummary;
}
}
if (flavor == FLAV_MICRODESC &&
tor_digest256_is_zero(microdesc_digest)) {
/* With no microdescriptor digest, we omit the entry entirely. */
continue;
}
{
char *buf;
/* Okay!! Now we can write the descriptor... */
/* First line goes into "buf". */
buf = routerstatus_format_entry(&rs_out, NULL, NULL, rs_format, NULL);
if (buf)
smartlist_add(chunks, buf);
}
/* Now an m line, if applicable. */
if (flavor == FLAV_MICRODESC &&
!tor_digest256_is_zero(microdesc_digest)) {
char m[BASE64_DIGEST256_LEN+1];
digest256_to_base64(m, microdesc_digest);
smartlist_add_asprintf(chunks, "m %s\n", m);
}
/* Next line is all flags. The "\n" is missing. */
smartlist_add(chunks,
smartlist_join_strings(chosen_flags, " ", 0, NULL));
/* Now the version line. */
if (chosen_version) {
smartlist_add(chunks, tor_strdup("\nv "));
smartlist_add(chunks, tor_strdup(chosen_version));
}
smartlist_add(chunks, tor_strdup("\n"));
if (chosen_protocol_list &&
consensus_method >= MIN_METHOD_FOR_RS_PROTOCOLS) {
smartlist_add_asprintf(chunks, "pr %s\n", chosen_protocol_list);
}
/* Now the weight line. */
if (rs_out.has_bandwidth) {
char *guardfraction_str = NULL;
int unmeasured = rs_out.bw_is_unmeasured &&
consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW;
/* If we have guardfraction info, include it in the 'w' line. */
if (rs_out.has_guardfraction) {
tor_asprintf(&guardfraction_str,
" GuardFraction=%u", rs_out.guardfraction_percentage);
}
smartlist_add_asprintf(chunks, "w Bandwidth=%d%s%s\n",
rs_out.bandwidth_kb,
unmeasured?" Unmeasured=1":"",
guardfraction_str ? guardfraction_str : "");
tor_free(guardfraction_str);
}
/* Now the exitpolicy summary line. */
if (rs_out.has_exitsummary && flavor == FLAV_NS) {
smartlist_add_asprintf(chunks, "p %s\n", rs_out.exitsummary);
}
/* And the loop is over and we move on to the next router */
}
tor_free(size);
tor_free(n_voter_flags);
tor_free(n_flag_voters);
for (i = 0; i < smartlist_len(votes); ++i)
tor_free(flag_map[i]);
tor_free(flag_map);
tor_free(flag_counts);
tor_free(named_flag);
tor_free(unnamed_flag);
strmap_free(name_to_id_map, NULL);
smartlist_free(matching_descs);
smartlist_free(chosen_flags);
smartlist_free(versions);
smartlist_free(protocols);
smartlist_free(exitsummaries);
tor_free(bandwidths_kb);
tor_free(measured_bws_kb);
tor_free(measured_guardfraction);
}
/* Mark the directory footer region */
smartlist_add(chunks, tor_strdup("directory-footer\n"));
{
int64_t weight_scale = BW_WEIGHT_SCALE;
char *bw_weight_param = NULL;
// Parse params, extract BW_WEIGHT_SCALE if present
// DO NOT use consensus_param_bw_weight_scale() in this code!
// The consensus is not formed yet!
/* XXXX Extract this code into a common function. Or not: #19011. */
if (params) {
if (strcmpstart(params, "bwweightscale=") == 0)
bw_weight_param = params;
else
bw_weight_param = strstr(params, " bwweightscale=");
}
if (bw_weight_param) {
int ok=0;
char *eq = strchr(bw_weight_param, '=');
if (eq) {
weight_scale = tor_parse_long(eq+1, 10, 1, INT32_MAX, &ok,
NULL);
if (!ok) {
log_warn(LD_DIR, "Bad element '%s' in bw weight param",
escaped(bw_weight_param));
weight_scale = BW_WEIGHT_SCALE;
}
} else {
log_warn(LD_DIR, "Bad element '%s' in bw weight param",
escaped(bw_weight_param));
weight_scale = BW_WEIGHT_SCALE;
}
}
added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
T, weight_scale);
}
/* Add a signature. */
{
char digest[DIGEST256_LEN];
char fingerprint[HEX_DIGEST_LEN+1];
char signing_key_fingerprint[HEX_DIGEST_LEN+1];
digest_algorithm_t digest_alg =
flavor == FLAV_NS ? DIGEST_SHA1 : DIGEST_SHA256;
size_t digest_len =
flavor == FLAV_NS ? DIGEST_LEN : DIGEST256_LEN;
const char *algname = crypto_digest_algorithm_get_name(digest_alg);
char *signature;
smartlist_add(chunks, tor_strdup("directory-signature "));
/* Compute the hash of the chunks. */
crypto_digest_smartlist(digest, digest_len, chunks, "", digest_alg);
/* Get the fingerprints */
crypto_pk_get_fingerprint(identity_key, fingerprint, 0);
crypto_pk_get_fingerprint(signing_key, signing_key_fingerprint, 0);
/* add the junk that will go at the end of the line. */
if (flavor == FLAV_NS) {
smartlist_add_asprintf(chunks, "%s %s\n", fingerprint,
signing_key_fingerprint);
} else {
smartlist_add_asprintf(chunks, "%s %s %s\n",
algname, fingerprint,
signing_key_fingerprint);
}
/* And the signature. */
if (!(signature = router_get_dirobj_signature(digest, digest_len,
signing_key))) {
log_warn(LD_BUG, "Couldn't sign consensus networkstatus.");
goto done;
}
smartlist_add(chunks, signature);
if (legacy_id_key_digest && legacy_signing_key) {
smartlist_add(chunks, tor_strdup("directory-signature "));
base16_encode(fingerprint, sizeof(fingerprint),
legacy_id_key_digest, DIGEST_LEN);
crypto_pk_get_fingerprint(legacy_signing_key,
signing_key_fingerprint, 0);
if (flavor == FLAV_NS) {
smartlist_add_asprintf(chunks, "%s %s\n", fingerprint,
signing_key_fingerprint);
} else {
smartlist_add_asprintf(chunks, "%s %s %s\n",
algname, fingerprint,
signing_key_fingerprint);
}
if (!(signature = router_get_dirobj_signature(digest, digest_len,
legacy_signing_key))) {
log_warn(LD_BUG, "Couldn't sign consensus networkstatus.");
goto done;
}
smartlist_add(chunks, signature);
}
}
result = smartlist_join_strings(chunks, "", 0, NULL);
{
networkstatus_t *c;
if (!(c = networkstatus_parse_vote_from_string(result, NULL,
NS_TYPE_CONSENSUS))) {
log_err(LD_BUG, "Generated a networkstatus consensus we couldn't "
"parse.");
tor_free(result);
goto done;
}
// Verify balancing parameters
if (added_weights) {
networkstatus_verify_bw_weights(c, consensus_method);
}
networkstatus_vote_free(c);
}
done:
dircollator_free(collator);
tor_free(client_versions);
tor_free(server_versions);
tor_free(packages);
SMARTLIST_FOREACH(flags, char *, cp, tor_free(cp));
smartlist_free(flags);
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
smartlist_free(chunks);
SMARTLIST_FOREACH(param_list, char *, cp, tor_free(cp));
smartlist_free(param_list);
return result;
}
| 0 |
[] |
tor
|
a0ef3cf0880e3cd343977b3fcbd0a2e7572f0cb4
| 128,960,987,997,211,830,000,000,000,000,000,000,000 | 964 |
Prevent int underflow in dirvote.c compare_vote_rs_.
This should be "impossible" without making a SHA1 collision, but
let's not keep the assumption that SHA1 collisions are super-hard.
This prevents another case related to 21278. There should be no
behavioral change unless -ftrapv is on.
|
static void call_nt_transact_notify_change(connection_struct *conn,
struct smb_request *req,
uint16 **ppsetup,
uint32 setup_count,
char **ppparams,
uint32 parameter_count,
char **ppdata, uint32 data_count,
uint32 max_data_count,
uint32 max_param_count)
{
uint16 *setup = *ppsetup;
files_struct *fsp;
uint32 filter;
NTSTATUS status;
bool recursive;
if(setup_count < 6) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
return;
}
fsp = file_fsp(req, SVAL(setup,4));
filter = IVAL(setup, 0);
recursive = (SVAL(setup, 6) != 0) ? True : False;
DEBUG(3,("call_nt_transact_notify_change\n"));
if(!fsp) {
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
return;
}
{
char *filter_string;
if (!(filter_string = notify_filter_string(NULL, filter))) {
reply_nterror(req,NT_STATUS_NO_MEMORY);
return;
}
DEBUG(3,("call_nt_transact_notify_change: notify change "
"called on %s, filter = %s, recursive = %d\n",
fsp_str_dbg(fsp), filter_string, recursive));
TALLOC_FREE(filter_string);
}
if((!fsp->is_directory) || (conn != fsp->conn)) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
return;
}
if (fsp->notify == NULL) {
status = change_notify_create(fsp, filter, recursive);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("change_notify_create returned %s\n",
nt_errstr(status)));
reply_nterror(req, status);
return;
}
}
if (fsp->notify->num_changes != 0) {
/*
* We've got changes pending, respond immediately
*/
/*
* TODO: write a torture test to check the filtering behaviour
* here.
*/
change_notify_reply(fsp->conn, req,
NT_STATUS_OK,
max_param_count,
fsp->notify,
smbd_smb1_notify_reply);
/*
* change_notify_reply() above has independently sent its
* results
*/
return;
}
/*
* No changes pending, queue the request
*/
status = change_notify_add_request(req,
max_param_count,
filter,
recursive, fsp,
smbd_smb1_notify_reply);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
}
return;
}
| 0 |
[
"CWE-189"
] |
samba
|
6ef0e33fe8afa0ebb81652b9d42b42d20efadf04
| 275,004,001,290,770,500,000,000,000,000,000,000,000 | 102 |
Fix bug #10010 - Missing integer wrap protection in EA list reading can cause server to loop with DOS.
Ensure we never wrap whilst adding client provided input.
CVE-2013-4124
Signed-off-by: Jeremy Allison <[email protected]>
|
R_API RBinJavaObj *r_bin_java_new(const char *file, ut64 loadaddr, Sdb *kv) {
ut8 *buf;
RBinJavaObj *bin = R_NEW0 (RBinJavaObj);
if (!bin) {
return NULL;
}
bin->file = strdup (file);
if (!(buf = (ut8 *) r_file_slurp (file, &bin->size))) {
return r_bin_java_free (bin);
}
if (!r_bin_java_new_bin (bin, loadaddr, kv, buf, bin->size)) {
r_bin_java_free (bin);
bin = NULL;
}
free (buf);
return bin;
}
| 0 |
[
"CWE-125"
] |
radare2
|
e9ce0d64faf19fa4e9c260250fbdf25e3c11e152
| 218,547,227,490,786,100,000,000,000,000,000,000,000 | 17 |
Fix #10498 - Fix crash in fuzzed java files (#10511)
|
int md_in_flight(struct mapped_device *md)
{
return atomic_read(&md->pending[READ]) +
atomic_read(&md->pending[WRITE]);
}
| 0 |
[
"CWE-362"
] |
linux
|
b9a41d21dceadf8104812626ef85dc56ee8a60ed
| 161,795,161,310,269,800,000,000,000,000,000,000,000 | 5 |
dm: fix race between dm_get_from_kobject() and __dm_destroy()
The following BUG_ON was hit when testing repeat creation and removal of
DM devices:
kernel BUG at drivers/md/dm.c:2919!
CPU: 7 PID: 750 Comm: systemd-udevd Not tainted 4.1.44
Call Trace:
[<ffffffff81649e8b>] dm_get_from_kobject+0x34/0x3a
[<ffffffff81650ef1>] dm_attr_show+0x2b/0x5e
[<ffffffff817b46d1>] ? mutex_lock+0x26/0x44
[<ffffffff811df7f5>] sysfs_kf_seq_show+0x83/0xcf
[<ffffffff811de257>] kernfs_seq_show+0x23/0x25
[<ffffffff81199118>] seq_read+0x16f/0x325
[<ffffffff811de994>] kernfs_fop_read+0x3a/0x13f
[<ffffffff8117b625>] __vfs_read+0x26/0x9d
[<ffffffff8130eb59>] ? security_file_permission+0x3c/0x44
[<ffffffff8117bdb8>] ? rw_verify_area+0x83/0xd9
[<ffffffff8117be9d>] vfs_read+0x8f/0xcf
[<ffffffff81193e34>] ? __fdget_pos+0x12/0x41
[<ffffffff8117c686>] SyS_read+0x4b/0x76
[<ffffffff817b606e>] system_call_fastpath+0x12/0x71
The bug can be easily triggered, if an extra delay (e.g. 10ms) is added
between the test of DMF_FREEING & DMF_DELETING and dm_get() in
dm_get_from_kobject().
To fix it, we need to ensure the test of DMF_FREEING & DMF_DELETING and
dm_get() are done in an atomic way, so _minor_lock is used.
The other callers of dm_get() have also been checked to be OK: some
callers invoke dm_get() under _minor_lock, some callers invoke it under
_hash_lock, and dm_start_request() invoke it after increasing
md->open_count.
Cc: [email protected]
Signed-off-by: Hou Tao <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
|
static int ql_wait_for_mii_ready(struct ql3_adapter *qdev)
{
struct ql3xxx_port_registers __iomem *port_regs =
qdev->mem_map_registers;
u32 temp;
int count = 1000;
while (count) {
temp = ql_read_page0_reg(qdev, &port_regs->macMIIStatusReg);
if (!(temp & MAC_MII_STATUS_BSY))
return 0;
udelay(10);
count--;
}
return -1;
}
| 0 |
[
"CWE-401"
] |
linux
|
1acb8f2a7a9f10543868ddd737e37424d5c36cf4
| 288,777,588,473,489,000,000,000,000,000,000,000,000 | 16 |
net: qlogic: Fix memory leak in ql_alloc_large_buffers
In ql_alloc_large_buffers, a new skb is allocated via netdev_alloc_skb.
This skb should be released if pci_dma_mapping_error fails.
Fixes: 0f8ab89e825f ("qla3xxx: Check return code from pci_map_single() in ql_release_to_lrg_buf_free_list(), ql_populate_free_queue(), ql_alloc_large_buffers(), and ql3xxx_send()")
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
static int __init pktsched_init(void)
{
register_qdisc(&pfifo_qdisc_ops);
register_qdisc(&bfifo_qdisc_ops);
proc_net_fops_create(&init_net, "psched", 0, &psched_fops);
rtnl_register(PF_UNSPEC, RTM_NEWQDISC, tc_modify_qdisc, NULL);
rtnl_register(PF_UNSPEC, RTM_DELQDISC, tc_get_qdisc, NULL);
rtnl_register(PF_UNSPEC, RTM_GETQDISC, tc_get_qdisc, tc_dump_qdisc);
rtnl_register(PF_UNSPEC, RTM_NEWTCLASS, tc_ctl_tclass, NULL);
rtnl_register(PF_UNSPEC, RTM_DELTCLASS, tc_ctl_tclass, NULL);
rtnl_register(PF_UNSPEC, RTM_GETTCLASS, tc_ctl_tclass, tc_dump_tclass);
return 0;
}
| 0 |
[
"CWE-909"
] |
linux-2.6
|
16ebb5e0b36ceadc8186f71d68b0c4fa4b6e781b
| 301,037,648,989,507,800,000,000,000,000,000,000,000 | 15 |
tc: Fix unitialized kernel memory leak
Three bytes of uninitialized kernel memory are currently leaked to user
Signed-off-by: Eric Dumazet <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
ves_icall_MonoField_SetValueInternal (MonoReflectionField *field, MonoObject *obj, MonoObject *value)
{
MonoClassField *cf = field->field;
gchar *v;
MONO_ARCH_SAVE_REGS;
if (field->klass->image->assembly->ref_only)
mono_raise_exception (mono_get_exception_invalid_operation (
"It is illegal to set the value on a field on a type loaded using the ReflectionOnly methods."));
if (mono_security_get_mode () == MONO_SECURITY_MODE_CORE_CLR)
mono_security_core_clr_ensure_reflection_access_field (cf);
v = (gchar *) value;
if (!cf->type->byref) {
switch (cf->type->type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4:
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
case MONO_TYPE_VALUETYPE:
if (v != NULL)
v += sizeof (MonoObject);
break;
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
case MONO_TYPE_CLASS:
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY:
/* Do nothing */
break;
case MONO_TYPE_GENERICINST: {
MonoGenericClass *gclass = cf->type->data.generic_class;
g_assert (!gclass->context.class_inst->is_open);
if (mono_class_is_nullable (mono_class_from_mono_type (cf->type))) {
MonoClass *nklass = mono_class_from_mono_type (cf->type);
MonoObject *nullable;
/*
* Convert the boxed vtype into a Nullable structure.
* This is complicated by the fact that Nullables have
* a variable structure.
*/
nullable = mono_object_new (mono_domain_get (), nklass);
mono_nullable_init (mono_object_unbox (nullable), value, nklass);
v = mono_object_unbox (nullable);
}
else
if (gclass->container_class->valuetype && (v != NULL))
v += sizeof (MonoObject);
break;
}
default:
g_error ("type 0x%x not handled in "
"ves_icall_FieldInfo_SetValueInternal", cf->type->type);
return;
}
}
if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
MonoVTable *vtable = mono_class_vtable_full (mono_object_domain (field), cf->parent, TRUE);
if (!vtable->initialized)
mono_runtime_class_init (vtable);
mono_field_static_set_value (vtable, cf, v);
} else {
mono_field_set_value (obj, cf, v);
}
}
| 0 |
[
"CWE-264"
] |
mono
|
035c8587c0d8d307e45f1b7171a0d337bb451f1e
| 143,330,207,182,095,980,000,000,000,000,000,000,000 | 82 |
Allow only primitive types/enums in RuntimeHelpers.InitializeArray ().
|
bit_read_B (Bit_Chain *dat)
{
unsigned char result;
unsigned char byte;
if (dat->byte >= dat->size)
{
loglevel = dat->opts & DWG_OPTS_LOGLEVEL;
LOG_ERROR ("%s buffer overflow at %lu", __FUNCTION__, dat->byte)
#ifdef DWG_ABORT
if (++errors > DWG_ABORT_LIMIT)
abort();
#endif
return 0;
}
byte = dat->chain[dat->byte];
result = (byte & (0x80 >> dat->bit)) >> (7 - dat->bit);
bit_advance_position (dat, 1);
return result;
}
| 0 |
[
"CWE-703",
"CWE-125"
] |
libredwg
|
95cc9300430d35feb05b06a9badf678419463dbe
| 138,574,278,503,869,060,000,000,000,000,000,000,000 | 21 |
encode: protect from stack under-flow
From GH #178 fuzzing
|
follow_tcp_tap_listener(void *tapdata, packet_info *pinfo,
epan_dissect_t *edt _U_, const void *data)
{
follow_record_t *follow_record;
follow_info_t *follow_info = (follow_info_t *)tapdata;
const tcp_follow_tap_data_t *follow_data = (const tcp_follow_tap_data_t *)data;
gboolean is_server;
guint32 sequence = follow_data->tcph->th_seq;
guint32 length = follow_data->tcph->th_seglen;
guint32 data_offset = 0;
guint32 data_length = tvb_captured_length(follow_data->tvb);
if (follow_data->tcph->th_flags & TH_SYN) {
sequence++;
}
if (follow_info->client_port == 0) {
follow_info->client_port = pinfo->srcport;
copy_address(&follow_info->client_ip, &pinfo->src);
follow_info->server_port = pinfo->destport;
copy_address(&follow_info->server_ip, &pinfo->dst);
}
is_server = !(addresses_equal(&follow_info->client_ip, &pinfo->src) && follow_info->client_port == pinfo->srcport);
/* Check whether this frame ACKs fragments in flow from the other direction.
* This happens when frames are not in the capture file, but were actually
* seen by the receiving host (Fixes bug 592).
*/
if (follow_info->fragments[!is_server] != NULL) {
while (check_follow_fragments(follow_info, !is_server, follow_data->tcph->th_ack, pinfo->fd->num));
}
/*
* If this is the first segment of this stream, initialize the next expected
* sequence number. If there is any data, it will be added below.
*/
if (follow_info->bytes_written[is_server] == 0 && follow_info->seq[is_server] == 0) {
follow_info->seq[is_server] = sequence;
}
/* We have already seen this src (and received some segments), let's figure
* out whether this segment extends the stream or overlaps a previous gap. */
if (LT_SEQ(sequence, follow_info->seq[is_server])) {
/* This sequence number seems dated, but check the end in case it was a
* retransmission with more data. */
guint32 nextseq = sequence + length;
if (GT_SEQ(nextseq, follow_info->seq[is_server])) {
/* The begin of the segment was already seen, try to add the
* remaining data that we have not seen to the payload. */
data_offset = follow_info->seq[is_server] - sequence;
if (data_length <= data_offset) {
data_length = 0;
} else {
data_length -= data_offset;
}
sequence = follow_info->seq[is_server];
length = nextseq - follow_info->seq[is_server];
}
}
/*
* Ignore segments that have no new data (either because it was empty, or
* because it was fully overlapping with previously received data).
*/
if (data_length == 0 || LT_SEQ(sequence, follow_info->seq[is_server])) {
return TAP_PACKET_DONT_REDRAW;
}
follow_record = g_new0(follow_record_t, 1);
follow_record->is_server = is_server;
follow_record->packet_num = pinfo->fd->num;
follow_record->seq = sequence; /* start of fragment, used by check_follow_fragments. */
follow_record->data = g_byte_array_append(g_byte_array_new(),
tvb_get_ptr(follow_data->tvb, data_offset, data_length),
data_length);
if (EQ_SEQ(sequence, follow_info->seq[is_server])) {
/* The segment overlaps or extends the previous end of stream. */
follow_info->seq[is_server] += length;
follow_info->bytes_written[is_server] += follow_record->data->len;
follow_info->payload = g_list_prepend(follow_info->payload, follow_record);
/* done with the packet, see if it caused a fragment to fit */
while(check_follow_fragments(follow_info, is_server, 0, pinfo->fd->num));
} else {
/* Out of order packet (more preceding segments are expected). */
follow_info->fragments[is_server] = g_list_append(follow_info->fragments[is_server], follow_record);
}
return TAP_PACKET_DONT_REDRAW;
}
| 0 |
[
"CWE-354"
] |
wireshark
|
7f3fe6164a68b76d9988c4253b24d43f498f1753
| 151,098,024,371,342,820,000,000,000,000,000,000,000 | 91 |
TCP: do not use an unknown status when the checksum is 0xffff
Otherwise it triggers an assert when adding the column as the field is
defined as BASE_NONE and not BASE_DEC or BASE_HEX. Thus an unknown value
(not in proto_checksum_vals[)array) cannot be represented.
Mark the checksum as bad even if we process the packet.
Closes #16816
Conflicts:
epan/dissectors/packet-tcp.c
|
static int ctnetlink_get_conntrack(struct net *net, struct sock *ctnl,
struct sk_buff *skb,
const struct nlmsghdr *nlh,
const struct nlattr * const cda[],
struct netlink_ext_ack *extack)
{
struct nf_conntrack_tuple_hash *h;
struct nf_conntrack_tuple tuple;
struct nf_conn *ct;
struct sk_buff *skb2 = NULL;
struct nfgenmsg *nfmsg = nlmsg_data(nlh);
u_int8_t u3 = nfmsg->nfgen_family;
struct nf_conntrack_zone zone;
int err;
if (nlh->nlmsg_flags & NLM_F_DUMP) {
struct netlink_dump_control c = {
.start = ctnetlink_start,
.dump = ctnetlink_dump_table,
.done = ctnetlink_done,
.data = (void *)cda,
};
return netlink_dump_start(ctnl, skb, nlh, &c);
}
err = ctnetlink_parse_zone(cda[CTA_ZONE], &zone);
if (err < 0)
return err;
if (cda[CTA_TUPLE_ORIG])
err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG,
u3, &zone);
else if (cda[CTA_TUPLE_REPLY])
err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY,
u3, &zone);
else
return -EINVAL;
if (err < 0)
return err;
h = nf_conntrack_find_get(net, &zone, &tuple);
if (!h)
return -ENOENT;
ct = nf_ct_tuplehash_to_ctrack(h);
err = -ENOMEM;
skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (skb2 == NULL) {
nf_ct_put(ct);
return -ENOMEM;
}
err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
NFNL_MSG_TYPE(nlh->nlmsg_type), ct, true, 0);
nf_ct_put(ct);
if (err <= 0)
goto free;
err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).portid, MSG_DONTWAIT);
if (err < 0)
goto out;
return 0;
free:
kfree_skb(skb2);
out:
/* this avoids a loop in nfnetlink. */
return err == -EAGAIN ? -ENOBUFS : err;
}
| 0 |
[
"CWE-120"
] |
linux
|
1cc5ef91d2ff94d2bf2de3b3585423e8a1051cb6
| 47,887,554,003,424,730,000,000,000,000,000,000,000 | 73 |
netfilter: ctnetlink: add a range check for l3/l4 protonum
The indexes to the nf_nat_l[34]protos arrays come from userspace. So
check the tuple's family, e.g. l3num, when creating the conntrack in
order to prevent an OOB memory access during setup. Here is an example
kernel panic on 4.14.180 when userspace passes in an index greater than
NFPROTO_NUMPROTO.
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
Modules linked in:...
Process poc (pid: 5614, stack limit = 0x00000000a3933121)
CPU: 4 PID: 5614 Comm: poc Tainted: G S W O 4.14.180-g051355490483
Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 Google Inc. MSM
task: 000000002a3dfffe task.stack: 00000000a3933121
pc : __cfi_check_fail+0x1c/0x24
lr : __cfi_check_fail+0x1c/0x24
...
Call trace:
__cfi_check_fail+0x1c/0x24
name_to_dev_t+0x0/0x468
nfnetlink_parse_nat_setup+0x234/0x258
ctnetlink_parse_nat_setup+0x4c/0x228
ctnetlink_new_conntrack+0x590/0xc40
nfnetlink_rcv_msg+0x31c/0x4d4
netlink_rcv_skb+0x100/0x184
nfnetlink_rcv+0xf4/0x180
netlink_unicast+0x360/0x770
netlink_sendmsg+0x5a0/0x6a4
___sys_sendmsg+0x314/0x46c
SyS_sendmsg+0xb4/0x108
el0_svc_naked+0x34/0x38
This crash is not happening since 5.4+, however, ctnetlink still
allows for creating entries with unsupported layer 3 protocol number.
Fixes: c1d10adb4a521 ("[NETFILTER]: Add ctnetlink port for nf_conntrack")
Signed-off-by: Will McVicker <[email protected]>
[[email protected]: rebased original patch on top of nf.git]
Signed-off-by: Pablo Neira Ayuso <[email protected]>
|
static ssize_t set_ignore_ce(struct device *s,
struct device_attribute *attr,
const char *buf, size_t size)
{
u64 new;
if (kstrtou64(buf, 0, &new) < 0)
return -EINVAL;
if (mca_cfg.ignore_ce ^ !!new) {
if (new) {
/* disable ce features */
mce_timer_delete_all();
on_each_cpu(mce_disable_cmci, NULL, 1);
mca_cfg.ignore_ce = true;
} else {
/* enable ce features */
mca_cfg.ignore_ce = false;
on_each_cpu(mce_enable_ce, (void *)1, 1);
}
}
return size;
}
| 1 |
[
"CWE-362"
] |
linux
|
b3b7c4795ccab5be71f080774c45bbbcc75c2aaf
| 115,321,783,154,327,250,000,000,000,000,000,000,000 | 23 |
x86/MCE: Serialize sysfs changes
The check_interval file in
/sys/devices/system/machinecheck/machinecheck<cpu number>
directory is a global timer value for MCE polling. If it is changed by one
CPU, mce_restart() broadcasts the event to other CPUs to delete and restart
the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the
mce_timer variable.
If more than one CPU writes a specific value to the check_interval file
concurrently, mce_timer is not protected from such concurrent accesses and
all kinds of explosions happen. Since only root can write to those sysfs
variables, the issue is not a big deal security-wise.
However, concurrent writes to these configuration variables is void of
reason so the proper thing to do is to serialize the access with a mutex.
Boris:
- Make store_int_with_restart() use device_store_ulong() to filter out
negative intervals
- Limit min interval to 1 second
- Correct locking
- Massage commit message
Signed-off-by: Seunghun Han <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: linux-edac <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
|
static int req_ssl_var_lookup(lua_State *L)
{
request_rec *r = ap_lua_check_request_rec(L, 1);
const char *s = luaL_checkstring(L, 2);
const char *res = ap_lua_ssl_val(r->pool, r->server, r->connection, r,
(char *)s);
lua_pushstring(L, res);
return 1;
}
| 0 |
[
"CWE-20"
] |
httpd
|
78eb3b9235515652ed141353d98c239237030410
| 182,630,685,532,245,500,000,000,000,000,000,000,000 | 9 |
*) SECURITY: CVE-2015-0228 (cve.mitre.org)
mod_lua: A maliciously crafted websockets PING after a script
calls r:wsupgrade() can cause a child process crash.
[Edward Lu <Chaosed0 gmail.com>]
Discovered by Guido Vranken <guidovranken gmail.com>
Submitted by: Edward Lu
Committed by: covener
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1657261 13f79535-47bb-0310-9956-ffa450edef68
|
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
struct archive_acl *abstract_acl, __LA_MODE_T mode)
{
int ret = ARCHIVE_OK;
(void)mode; /* UNUSED */
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
ret = set_acl(a, fd, name, abstract_acl,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
if (ret != ARCHIVE_OK)
return (ret);
}
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
ret = set_acl(a, fd, name, abstract_acl,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
/* Simultaneous POSIX.1e and NFSv4 is not supported */
return (ret);
}
#if ARCHIVE_ACL_FREEBSD_NFS4
else if ((archive_acl_types(abstract_acl) &
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
ret = set_acl(a, fd, name, abstract_acl,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
}
#endif
return (ret);
}
| 1 |
[
"CWE-59",
"CWE-61"
] |
libarchive
|
fba4f123cc456d2b2538f811bb831483bf336bad
| 5,215,138,025,683,637,000,000,000,000,000,000,000 | 33 |
Fix handling of symbolic link ACLs
On Linux ACLs on symbolic links are not supported.
We must avoid calling acl_set_file() on symbolic links as their
targets are modified instead.
While here, do not try to set default ACLs on non-directories.
Fixes #1565
|
SPL_METHOD(SplFileInfo, getRealPath)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char buff[MAXPATHLEN];
char *filename;
zend_error_handling error_handling;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
}
if (intern->orig_path) {
filename = intern->orig_path;
} else {
filename = intern->file_name;
}
if (filename && VCWD_REALPATH(filename, buff)) {
#ifdef ZTS
if (VCWD_ACCESS(buff, F_OK)) {
RETVAL_FALSE;
} else
#endif
RETVAL_STRING(buff, 1);
} else {
RETVAL_FALSE;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
| 0 |
[
"CWE-190"
] |
php-src
|
7245bff300d3fa8bacbef7897ff080a6f1c23eba
| 192,926,533,122,512,960,000,000,000,000,000,000,000 | 37 |
Fix bug #72262 - do not overflow int
|
Item_ref(THD *thd, Name_resolution_context *context_arg,
const char *db_arg, const char *table_name_arg,
const char *field_name_arg):
Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg),
set_properties_only(0), ref(0), reference_trough_name(1) {}
| 0 |
[
"CWE-617"
] |
server
|
2e7891080667c59ac80f788eef4d59d447595772
| 338,116,049,923,313,030,000,000,000,000,000,000,000 | 5 |
MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view
This bug could manifest itself after pushing a where condition over a
mergeable derived table / view / CTE DT into a grouping view / derived
table / CTE V whose item list contained set functions with constant
arguments such as MIN(2), SUM(1) etc. In such cases the field references
used in the condition pushed into the view V that correspond set functions
are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation
of the virtual method const_item() for the class Item_direct_view_ref the
wrapped set functions with constant arguments could be erroneously taken
for constant items. This could lead to a wrong result set returned by the
main select query in 10.2. In 10.4 where a possibility of pushing condition
from HAVING into WHERE had been added this could cause a crash.
Approved by Sergey Petrunya <[email protected]>
|
format_cb_window_layout(struct format_tree *ft, struct format_entry *fe)
{
struct window *w = ft->w;
if (w == NULL)
return;
if (w->saved_layout_root != NULL)
fe->value = layout_dump(w->saved_layout_root);
else
fe->value = layout_dump(w->layout_root);
}
| 0 |
[] |
src
|
b32e1d34e10a0da806823f57f02a4ae6e93d756e
| 122,672,744,401,711,770,000,000,000,000,000,000,000 | 12 |
evbuffer_new and bufferevent_new can both fail (when malloc fails) and
return NULL. GitHub issue 1547.
|
void CWebServer::RType_Notifications(WebEmSession & session, const request& req, Json::Value &root)
{
root["status"] = "OK";
root["title"] = "Notifications";
int ii = 0;
//Add known notification systems
for (const auto & ittNotifiers : m_notifications.m_notifiers)
{
root["notifiers"][ii]["name"] = ittNotifiers.first;
root["notifiers"][ii]["description"] = ittNotifiers.first;
ii++;
}
uint64_t idx = 0;
if (request::findValue(&req, "idx") != "")
{
idx = std::strtoull(request::findValue(&req, "idx").c_str(), nullptr, 10);
}
std::vector<_tNotification> notifications = m_notifications.GetNotifications(idx);
if (notifications.size() > 0)
{
ii = 0;
for (const auto & itt : notifications)
{
root["result"][ii]["idx"] = itt.ID;
std::string sParams = itt.Params;
if (sParams.empty()) {
sParams = "S";
}
root["result"][ii]["Params"] = sParams;
root["result"][ii]["Priority"] = itt.Priority;
root["result"][ii]["SendAlways"] = itt.SendAlways;
root["result"][ii]["CustomMessage"] = itt.CustomMessage;
root["result"][ii]["ActiveSystems"] = itt.ActiveSystems;
ii++;
}
}
}
| 0 |
[
"CWE-89"
] |
domoticz
|
ee70db46f81afa582c96b887b73bcd2a86feda00
| 226,574,471,154,961,560,000,000,000,000,000,000,000 | 40 |
Fixed possible SQL Injection Vulnerability (Thanks to Fabio Carretto!)
|
cdf_read_short_sector_chain(const cdf_header_t *h,
const cdf_sat_t *ssat, const cdf_stream_t *sst,
cdf_secid_t sid, size_t len, cdf_stream_t *scn)
{
size_t ss = CDF_SHORT_SEC_SIZE(h), i, j;
scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h));
scn->sst_dirlen = len;
if (sst->sst_tab == NULL || scn->sst_len == (size_t)-1)
return -1;
scn->sst_tab = calloc(scn->sst_len, ss);
if (scn->sst_tab == NULL)
return -1;
for (j = i = 0; sid >= 0; i++, j++) {
if (j >= CDF_LOOP_LIMIT) {
DPRINTF(("Read short sector chain loop limit"));
errno = EFTYPE;
goto out;
}
if (i >= scn->sst_len) {
DPRINTF(("Out of bounds reading short sector chain "
"%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n",
i, scn->sst_len));
errno = EFTYPE;
goto out;
}
if (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h,
sid) != (ssize_t)ss) {
DPRINTF(("Reading short sector chain %d", sid));
goto out;
}
sid = CDF_TOLE4((uint32_t)ssat->sat_tab[sid]);
}
return 0;
out:
free(scn->sst_tab);
return -1;
}
| 0 |
[
"CWE-119"
] |
file
|
1aec04dbf8a24b8a6ba64c4f74efa0628e36db0b
| 52,133,080,832,702,300,000,000,000,000,000,000,000 | 40 |
Fix bounds checks again.
|
static void tg3_switch_clocks(struct tg3 *tp)
{
u32 clock_ctrl;
u32 orig_clock_ctrl;
if (tg3_flag(tp, CPMU_PRESENT) || tg3_flag(tp, 5780_CLASS))
return;
clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
orig_clock_ctrl = clock_ctrl;
clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN |
CLOCK_CTRL_CLKRUN_OENABLE |
0x1f);
tp->pci_clock_ctrl = clock_ctrl;
if (tg3_flag(tp, 5705_PLUS)) {
if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
tw32_wait_f(TG3PCI_CLOCK_CTRL,
clock_ctrl | CLOCK_CTRL_625_CORE, 40);
}
} else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
tw32_wait_f(TG3PCI_CLOCK_CTRL,
clock_ctrl |
(CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK),
40);
tw32_wait_f(TG3PCI_CLOCK_CTRL,
clock_ctrl | (CLOCK_CTRL_ALTCLK),
40);
}
tw32_wait_f(TG3PCI_CLOCK_CTRL, clock_ctrl, 40);
}
| 0 |
[
"CWE-476",
"CWE-119"
] |
linux
|
715230a44310a8cf66fbfb5a46f9a62a9b2de424
| 34,557,761,779,857,195,000,000,000,000,000,000,000 | 32 |
tg3: fix length overflow in VPD firmware parsing
Commit 184b89044fb6e2a74611dafa69b1dce0d98612c6 ("tg3: Use VPD fw version
when present") introduced VPD parsing that contained a potential length
overflow.
Limit the hardware's reported firmware string length (max 255 bytes) to
stay inside the driver's firmware string length (32 bytes). On overflow,
truncate the formatted firmware string instead of potentially overwriting
portions of the tg3 struct.
http://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdf
Signed-off-by: Kees Cook <[email protected]>
Reported-by: Oded Horovitz <[email protected]>
Reported-by: Brad Spengler <[email protected]>
Cc: [email protected]
Cc: Matt Carlson <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
call_ready_callbacks (NautilusDirectory *directory)
{
gboolean found_any;
GList *node, *next;
ReadyCallback *callback;
found_any = FALSE;
/* Check if any callbacks are satisifed and mark them for call them if they are. */
for (node = directory->details->call_when_ready_list;
node != NULL; node = next)
{
next = node->next;
callback = node->data;
if (callback->active &&
request_is_satisfied (directory, callback->file, callback->request))
{
callback->active = FALSE;
found_any = TRUE;
}
}
if (found_any)
{
schedule_call_ready_callbacks (directory);
}
return found_any;
}
| 0 |
[
"CWE-20"
] |
nautilus
|
1630f53481f445ada0a455e9979236d31a8d3bb0
| 152,192,856,812,512,430,000,000,000,000,000,000,000 | 29 |
mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991
|
add_pack_dir_to_rtp(char_u *fname)
{
char_u *p4, *p3, *p2, *p1, *p;
char_u *entry;
char_u *insp = NULL;
int c;
char_u *new_rtp;
int keep;
size_t oldlen;
size_t addlen;
size_t new_rtp_len;
char_u *afterdir = NULL;
size_t afterlen = 0;
char_u *after_insp = NULL;
char_u *ffname = NULL;
size_t fname_len;
char_u *buf = NULL;
char_u *rtp_ffname;
int match;
int retval = FAIL;
p4 = p3 = p2 = p1 = get_past_head(fname);
for (p = p1; *p; MB_PTR_ADV(p))
if (vim_ispathsep_nocolon(*p))
{
p4 = p3; p3 = p2; p2 = p1; p1 = p;
}
// now we have:
// rtp/pack/name/start/name
// p4 p3 p2 p1
//
// find the part up to "pack" in 'runtimepath'
c = *++p4; // append pathsep in order to expand symlink
*p4 = NUL;
ffname = fix_fname(fname);
*p4 = c;
if (ffname == NULL)
return FAIL;
// Find "ffname" in "p_rtp", ignoring '/' vs '\' differences.
// Also stop at the first "after" directory.
fname_len = STRLEN(ffname);
buf = alloc(MAXPATHL);
if (buf == NULL)
goto theend;
for (entry = p_rtp; *entry != NUL; )
{
char_u *cur_entry = entry;
copy_option_part(&entry, buf, MAXPATHL, ",");
if (insp == NULL)
{
add_pathsep(buf);
rtp_ffname = fix_fname(buf);
if (rtp_ffname == NULL)
goto theend;
match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
vim_free(rtp_ffname);
if (match)
// Insert "ffname" after this entry (and comma).
insp = entry;
}
if ((p = (char_u *)strstr((char *)buf, "after")) != NULL
&& p > buf
&& vim_ispathsep(p[-1])
&& (vim_ispathsep(p[5]) || p[5] == NUL || p[5] == ','))
{
if (insp == NULL)
// Did not find "ffname" before the first "after" directory,
// insert it before this entry.
insp = cur_entry;
after_insp = cur_entry;
break;
}
}
if (insp == NULL)
// Both "fname" and "after" not found, append at the end.
insp = p_rtp + STRLEN(p_rtp);
// check if rtp/pack/name/start/name/after exists
afterdir = concat_fnames(fname, (char_u *)"after", TRUE);
if (afterdir != NULL && mch_isdir(afterdir))
afterlen = STRLEN(afterdir) + 1; // add one for comma
oldlen = STRLEN(p_rtp);
addlen = STRLEN(fname) + 1; // add one for comma
new_rtp = alloc(oldlen + addlen + afterlen + 1); // add one for NUL
if (new_rtp == NULL)
goto theend;
// We now have 'rtp' parts: {keep}{keep_after}{rest}.
// Create new_rtp, first: {keep},{fname}
keep = (int)(insp - p_rtp);
mch_memmove(new_rtp, p_rtp, keep);
new_rtp_len = keep;
if (*insp == NUL)
new_rtp[new_rtp_len++] = ','; // add comma before
mch_memmove(new_rtp + new_rtp_len, fname, addlen - 1);
new_rtp_len += addlen - 1;
if (*insp != NUL)
new_rtp[new_rtp_len++] = ','; // add comma after
if (afterlen > 0 && after_insp != NULL)
{
int keep_after = (int)(after_insp - p_rtp);
// Add to new_rtp: {keep},{fname}{keep_after},{afterdir}
mch_memmove(new_rtp + new_rtp_len, p_rtp + keep,
keep_after - keep);
new_rtp_len += keep_after - keep;
mch_memmove(new_rtp + new_rtp_len, afterdir, afterlen - 1);
new_rtp_len += afterlen - 1;
new_rtp[new_rtp_len++] = ',';
keep = keep_after;
}
if (p_rtp[keep] != NUL)
// Append rest: {keep},{fname}{keep_after},{afterdir}{rest}
mch_memmove(new_rtp + new_rtp_len, p_rtp + keep, oldlen - keep + 1);
else
new_rtp[new_rtp_len] = NUL;
if (afterlen > 0 && after_insp == NULL)
{
// Append afterdir when "after" was not found:
// {keep},{fname}{rest},{afterdir}
STRCAT(new_rtp, ",");
STRCAT(new_rtp, afterdir);
}
set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
vim_free(new_rtp);
retval = OK;
theend:
vim_free(buf);
vim_free(ffname);
vim_free(afterdir);
return retval;
}
| 0 |
[
"CWE-122"
] |
vim
|
2bdad6126778f907c0b98002bfebf0e611a3f5db
| 105,862,650,287,140,460,000,000,000,000,000,000,000 | 143 |
patch 8.2.4647: "source" can read past end of copied line
Problem: "source" can read past end of copied line.
Solution: Add a terminating NUL.
|
do_newobj (VerifyContext *ctx, int token)
{
ILStackDesc *value;
int i;
MonoMethodSignature *sig;
MonoMethod *method;
gboolean is_delegate = FALSE;
if (!(method = verifier_load_method (ctx, token, "newobj")))
return;
if (!mono_method_is_constructor (method)) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Method from token 0x%08x not a constructor at 0x%04x", token, ctx->ip_offset));
return;
}
if (method->klass->flags & (TYPE_ATTRIBUTE_ABSTRACT | TYPE_ATTRIBUTE_INTERFACE))
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Trying to instantiate an abstract or interface type at 0x%04x", ctx->ip_offset));
if (!mono_method_can_access_method_full (ctx->method, method, NULL)) {
char *from = mono_method_full_name (ctx->method, TRUE);
char *to = mono_method_full_name (method, TRUE);
CODE_NOT_VERIFIABLE2 (ctx, g_strdup_printf ("Constructor %s not visible from %s at 0x%04x", to, from, ctx->ip_offset), MONO_EXCEPTION_METHOD_ACCESS);
g_free (from);
g_free (to);
}
//FIXME use mono_method_get_signature_full
sig = mono_method_signature (method);
if (!sig) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Invalid constructor signature to newobj at 0x%04x", ctx->ip_offset));
return;
}
if (!sig->hasthis) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Invalid constructor signature missing hasthis at 0x%04x", ctx->ip_offset));
return;
}
if (!check_underflow (ctx, sig->param_count))
return;
is_delegate = method->klass->parent == mono_defaults.multicastdelegate_class;
if (is_delegate) {
ILStackDesc *funptr;
//first arg is object, second arg is fun ptr
if (sig->param_count != 2) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Invalid delegate constructor at 0x%04x", ctx->ip_offset));
return;
}
funptr = stack_pop (ctx);
value = stack_pop (ctx);
verify_delegate_compatibility (ctx, method->klass, value, funptr);
} else {
for (i = sig->param_count - 1; i >= 0; --i) {
VERIFIER_DEBUG ( printf ("verifying constructor argument %d\n", i); );
value = stack_pop (ctx);
if (!verify_stack_type_compatibility (ctx, sig->params [i], value)) {
char *stack_name = stack_slot_full_name (value);
char *sig_name = mono_type_full_name (sig->params [i]);
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Incompatible parameter value with constructor signature: %s X %s at 0x%04x", sig_name, stack_name, ctx->ip_offset));
g_free (stack_name);
g_free (sig_name);
}
if (stack_slot_is_managed_mutability_pointer (value))
CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Cannot use a readonly pointer as argument of newobj at 0x%04x", ctx->ip_offset));
}
}
if (check_overflow (ctx))
set_stack_value (ctx, stack_push (ctx), &method->klass->byval_arg, FALSE);
}
| 0 |
[
"CWE-20"
] |
mono
|
cf1ec146f7c6acdc6697032b3aaafc68ffacdcac
| 195,019,816,319,653,400,000,000,000,000,000,000,000 | 74 |
Handle invalid instantiation of generic methods.
* verify.c: Add new function to internal verifier API to check
method instantiations.
* reflection.c (mono_reflection_bind_generic_method_parameters):
Check the instantiation before returning it.
Fixes #655847
|
int main(int argc, char **argv)
{
char *password = "";
fz_document *doc = NULL;
int c;
fz_context *ctx;
trace_info info = { 0, 0, 0 };
fz_alloc_context alloc_ctx = { &info, trace_malloc, trace_realloc, trace_free };
fz_locks_context *locks = NULL;
fz_var(doc);
bgprint.active = 0; /* set by -P */
min_band_height = MIN_BAND_HEIGHT;
max_band_memory = BAND_MEMORY;
width = 0;
height = 0;
num_workers = NUM_RENDER_THREADS;
x_resolution = X_RESOLUTION;
y_resolution = Y_RESOLUTION;
while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:M:s:A:iW:H:S:T:U:XvP")) != -1)
{
switch (c)
{
default: return usage();
case 'p': password = fz_optarg; break;
case 'o': output = fz_optarg; break;
case 'F': format = fz_optarg; break;
case 'R': rotation = read_rotation(fz_optarg); break;
case 'r': read_resolution(fz_optarg); break;
case 'w': width = fz_atof(fz_optarg); break;
case 'h': height = fz_atof(fz_optarg); break;
case 'f': fit = 1; break;
case 'B': min_band_height = atoi(fz_optarg); break;
case 'M': max_band_memory = atoi(fz_optarg); break;
case 'W': layout_w = fz_atof(fz_optarg); break;
case 'H': layout_h = fz_atof(fz_optarg); break;
case 'S': layout_em = fz_atof(fz_optarg); break;
case 'U': layout_css = fz_optarg; break;
case 'X': layout_use_doc_css = 0; break;
case 's':
if (strchr(fz_optarg, 't')) ++showtime;
if (strchr(fz_optarg, 'm')) ++showmemory;
break;
case 'A':
{
char *sep;
alphabits_graphics = atoi(fz_optarg);
sep = strchr(fz_optarg, '/');
if (sep)
alphabits_text = atoi(sep+1);
else
alphabits_text = alphabits_graphics;
break;
}
case 'i': ignore_errors = 1; break;
case 'T':
#if MURASTER_THREADS != 0
num_workers = atoi(fz_optarg); break;
#else
fprintf(stderr, "Threads not enabled in this build\n");
break;
#endif
case 'P':
#if MURASTER_THREADS != 0
bgprint.active = 1; break;
#else
fprintf(stderr, "Threads not enabled in this build\n");
break;
#endif
case 'v': fprintf(stderr, "muraster version %s\n", FZ_VERSION); return 1;
}
}
if (width == 0)
width = x_resolution * PAPER_WIDTH;
if (height == 0)
height = y_resolution * PAPER_HEIGHT;
if (fz_optind == argc)
return usage();
if (min_band_height <= 0)
{
fprintf(stderr, "Require a positive minimum band height\n");
exit(1);
}
#ifndef DISABLE_MUTHREADS
locks = init_muraster_locks();
if (locks == NULL)
{
fprintf(stderr, "cannot initialise mutexes\n");
exit(1);
}
#endif
ctx = fz_new_context((showmemory == 0 ? NULL : &alloc_ctx), locks, FZ_STORE_DEFAULT);
if (!ctx)
{
fprintf(stderr, "cannot initialise context\n");
exit(1);
}
fz_set_text_aa_level(ctx, alphabits_text);
fz_set_graphics_aa_level(ctx, alphabits_graphics);
#ifndef DISABLE_MUTHREADS
if (bgprint.active)
{
int fail = 0;
bgprint.ctx = fz_clone_context(ctx);
fail |= mu_create_semaphore(&bgprint.start);
fail |= mu_create_semaphore(&bgprint.stop);
fail |= mu_create_thread(&bgprint.thread, bgprint_worker, NULL);
if (fail)
{
fprintf(stderr, "bgprint startup failed\n");
exit(1);
}
}
if (num_workers > 0)
{
int i;
int fail = 0;
workers = fz_calloc(ctx, num_workers, sizeof(*workers));
for (i = 0; i < num_workers; i++)
{
workers[i].ctx = fz_clone_context(ctx);
workers[i].num = i;
fail |= mu_create_semaphore(&workers[i].start);
fail |= mu_create_semaphore(&workers[i].stop);
fail |= mu_create_thread(&workers[i].thread, worker_thread, &workers[i]);
}
if (fail)
{
fprintf(stderr, "worker startup failed\n");
exit(1);
}
}
#endif /* DISABLE_MUTHREADS */
if (layout_css)
{
fz_buffer *buf = fz_read_file(ctx, layout_css);
fz_set_user_css(ctx, fz_string_from_buffer(ctx, buf));
fz_drop_buffer(ctx, buf);
}
fz_set_use_document_css(ctx, layout_use_doc_css);
output_format = suffix_table[0].format;
output_cs = suffix_table[0].cs;
if (format)
{
int i;
for (i = 0; i < (int)nelem(suffix_table); i++)
{
if (!strcmp(format, suffix_table[i].suffix+1))
{
output_format = suffix_table[i].format;
output_cs = suffix_table[i].cs;
break;
}
}
if (i == (int)nelem(suffix_table))
{
fprintf(stderr, "Unknown output format '%s'\n", format);
exit(1);
}
}
else if (output)
{
char *suffix = output;
int i;
for (i = 0; i < (int)nelem(suffix_table); i++)
{
char *s = strstr(suffix, suffix_table[i].suffix);
if (s != NULL)
{
suffix = s+1;
output_format = suffix_table[i].format;
output_cs = suffix_table[i].cs;
i = 0;
}
}
}
switch (output_cs)
{
case CS_GRAY:
colorspace = fz_device_gray(ctx);
break;
case CS_RGB:
colorspace = fz_device_rgb(ctx);
break;
case CS_CMYK:
colorspace = fz_device_cmyk(ctx);
break;
}
if (output && (output[0] != '-' || output[1] != 0) && *output != 0)
{
out = fz_new_output_with_path(ctx, output, 0);
}
else
out = fz_stdout(ctx);
timing.count = 0;
timing.total = 0;
timing.min = 1 << 30;
timing.max = 0;
timing.mininterp = 1 << 30;
timing.maxinterp = 0;
timing.minpage = 0;
timing.maxpage = 0;
timing.minfilename = "";
timing.maxfilename = "";
fz_try(ctx)
{
fz_register_document_handlers(ctx);
while (fz_optind < argc)
{
fz_try(ctx)
{
filename = argv[fz_optind++];
doc = fz_open_document(ctx, filename);
if (fz_needs_password(ctx, doc))
{
if (!fz_authenticate_password(ctx, doc, password))
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename);
}
fz_layout_document(ctx, doc, layout_w, layout_h, layout_em);
if (fz_optind == argc || !fz_is_page_range(ctx, argv[fz_optind]))
drawrange(ctx, doc, "1-N");
if (fz_optind < argc && fz_is_page_range(ctx, argv[fz_optind]))
drawrange(ctx, doc, argv[fz_optind++]);
fz_drop_document(ctx, doc);
doc = NULL;
}
fz_catch(ctx)
{
if (!ignore_errors)
fz_rethrow(ctx);
fz_drop_document(ctx, doc);
doc = NULL;
fz_warn(ctx, "ignoring error in '%s'", filename);
}
}
finish_bgprint(ctx);
}
fz_catch(ctx)
{
fz_drop_document(ctx, doc);
fprintf(stderr, "error: cannot draw '%s'\n", filename);
errored = 1;
}
if (showtime && timing.count > 0)
{
fprintf(stderr, "total %dms / %d pages for an average of %dms\n",
timing.total, timing.count, timing.total / timing.count);
fprintf(stderr, "fastest page %d: %dms\n", timing.minpage, timing.min);
fprintf(stderr, "slowest page %d: %dms\n", timing.maxpage, timing.max);
}
#ifndef DISABLE_MUTHREADS
if (num_workers > 0)
{
int i;
for (i = 0; i < num_workers; i++)
{
workers[i].band_start = -1;
mu_trigger_semaphore(&workers[i].start);
mu_wait_semaphore(&workers[i].stop);
mu_destroy_semaphore(&workers[i].start);
mu_destroy_semaphore(&workers[i].stop);
mu_destroy_thread(&workers[i].thread);
fz_drop_context(workers[i].ctx);
}
fz_free(ctx, workers);
}
if (bgprint.active)
{
bgprint.pagenum = -1;
mu_trigger_semaphore(&bgprint.start);
mu_wait_semaphore(&bgprint.stop);
mu_destroy_semaphore(&bgprint.start);
mu_destroy_semaphore(&bgprint.stop);
mu_destroy_thread(&bgprint.thread);
fz_drop_context(bgprint.ctx);
}
#endif /* DISABLE_MUTHREADS */
fz_close_output(ctx, out);
fz_drop_output(ctx, out);
out = NULL;
fz_drop_context(ctx);
#ifndef DISABLE_MUTHREADS
fin_muraster_locks();
#endif /* DISABLE_MUTHREADS */
if (showmemory)
{
char buf[100];
fz_snprintf(buf, sizeof buf, "Memory use total=%zu peak=%zu current=%zu", info.total, info.peak, info.current);
fprintf(stderr, "%s\n", buf);
}
return (errored != 0);
}
| 0 |
[
"CWE-369",
"CWE-22"
] |
mupdf
|
22c47acbd52949421f8c7cb46ea1556827d0fcbf
| 172,023,027,517,535,200,000,000,000,000,000,000,000 | 334 |
Bug 704834: Fix division by zero for zero width pages in muraster.
|
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
{
int ret = 0;
AVDictionary *tmp = NULL;
if (avcodec_is_open(avctx))
return 0;
if ((!codec && !avctx->codec)) {
av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
return AVERROR(EINVAL);
}
if ((codec && avctx->codec && codec != avctx->codec)) {
av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
"but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
return AVERROR(EINVAL);
}
if (!codec)
codec = avctx->codec;
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
if (options)
av_dict_copy(&tmp, *options, 0);
ret = ff_lock_avcodec(avctx);
if (ret < 0)
return ret;
avctx->internal = av_mallocz(sizeof(AVCodecInternal));
if (!avctx->internal) {
ret = AVERROR(ENOMEM);
goto end;
}
avctx->internal->pool = av_mallocz(sizeof(*avctx->internal->pool));
if (!avctx->internal->pool) {
ret = AVERROR(ENOMEM);
goto free_and_end;
}
avctx->internal->to_free = av_frame_alloc();
if (!avctx->internal->to_free) {
ret = AVERROR(ENOMEM);
goto free_and_end;
}
if (codec->priv_data_size > 0) {
if (!avctx->priv_data) {
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
}
if (codec->priv_class) {
*(const AVClass **)avctx->priv_data = codec->priv_class;
av_opt_set_defaults(avctx->priv_data);
}
}
if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
goto free_and_end;
} else {
avctx->priv_data = NULL;
}
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
goto free_and_end;
// only call ff_set_dimensions() for non H.264/VP6F codecs so as not to overwrite previously setup dimensions
if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F))) {
if (avctx->coded_width && avctx->coded_height)
ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
else if (avctx->width && avctx->height)
ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
if (ret < 0)
goto free_and_end;
}
if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
&& ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
|| av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
ff_set_dimensions(avctx, 0, 0);
}
/* if the decoder init function was already called previously,
* free the already allocated subtitle_header before overwriting it */
if (av_codec_is_decoder(codec))
av_freep(&avctx->subtitle_header);
if (avctx->channels > FF_SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}
avctx->codec = codec;
if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
avctx->codec_id == AV_CODEC_ID_NONE) {
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
}
if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
&& avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
ret = AVERROR(EINVAL);
goto free_and_end;
}
avctx->frame_number = 0;
avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
AVCodec *codec2;
av_log(avctx, AV_LOG_ERROR,
"The %s '%s' is experimental but experimental codecs are not enabled, "
"add '-strict %d' if you want to use it.\n",
codec_string, codec->name, FF_COMPLIANCE_EXPERIMENTAL);
codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
if (!(codec2->capabilities & CODEC_CAP_EXPERIMENTAL))
av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
codec_string, codec2->name);
ret = AVERROR_EXPERIMENTAL;
goto free_and_end;
}
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
(!avctx->time_base.num || !avctx->time_base.den)) {
avctx->time_base.num = 1;
avctx->time_base.den = avctx->sample_rate;
}
if (!HAVE_THREADS)
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
if (CONFIG_FRAME_THREAD_ENCODER) {
ff_unlock_avcodec(); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
ff_lock_avcodec(avctx);
if (ret < 0)
goto free_and_end;
}
if (HAVE_THREADS
&& !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
ret = ff_thread_init(avctx);
if (ret < 0) {
goto free_and_end;
}
}
if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS))
avctx->thread_count = 1;
if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
ret = AVERROR(EINVAL);
goto free_and_end;
}
if (av_codec_is_encoder(avctx->codec)) {
int i;
if (avctx->codec->sample_fmts) {
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
break;
if (avctx->channels == 1 &&
av_get_planar_sample_fmt(avctx->sample_fmt) ==
av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) {
avctx->sample_fmt = avctx->codec->sample_fmts[i];
break;
}
}
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
char buf[128];
snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt);
av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n",
(char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf));
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
if (avctx->codec->pix_fmts) {
for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
break;
if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
&& !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
&& avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) {
char buf[128];
snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n",
(char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), buf));
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
if (avctx->codec->supported_samplerates) {
for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
break;
if (avctx->codec->supported_samplerates[i] == 0) {
av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n",
avctx->sample_rate);
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
if (avctx->codec->channel_layouts) {
if (!avctx->channel_layout) {
av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n");
} else {
for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
if (avctx->channel_layout == avctx->codec->channel_layouts[i])
break;
if (avctx->codec->channel_layouts[i] == 0) {
char buf[512];
av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf);
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
}
if (avctx->channel_layout && avctx->channels) {
int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
if (channels != avctx->channels) {
char buf[512];
av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
av_log(avctx, AV_LOG_ERROR,
"Channel layout '%s' with %d channels does not match number of specified channels %d\n",
buf, channels, avctx->channels);
ret = AVERROR(EINVAL);
goto free_and_end;
}
} else if (avctx->channel_layout) {
avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
}
if(avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
avctx->codec_id != AV_CODEC_ID_PNG // For mplayer
) {
if (avctx->width <= 0 || avctx->height <= 0) {
av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
ret = AVERROR(EINVAL);
goto free_and_end;
}
}
if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
&& avctx->bit_rate>0 && avctx->bit_rate<1000) {
av_log(avctx, AV_LOG_WARNING, "Bitrate %d is extremely low, maybe you mean %dk\n", avctx->bit_rate, avctx->bit_rate);
}
if (!avctx->rc_initial_buffer_occupancy)
avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4;
}
avctx->pts_correction_num_faulty_pts =
avctx->pts_correction_num_faulty_dts = 0;
avctx->pts_correction_last_pts =
avctx->pts_correction_last_dts = INT64_MIN;
if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
|| avctx->internal->frame_thread_encoder)) {
ret = avctx->codec->init(avctx);
if (ret < 0) {
goto free_and_end;
}
}
ret=0;
if (av_codec_is_decoder(avctx->codec)) {
if (!avctx->bit_rate)
avctx->bit_rate = get_bit_rate(avctx);
/* validate channel layout from the decoder */
if (avctx->channel_layout) {
int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
if (!avctx->channels)
avctx->channels = channels;
else if (channels != avctx->channels) {
char buf[512];
av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
av_log(avctx, AV_LOG_WARNING,
"Channel layout '%s' with %d channels does not match specified number of channels %d: "
"ignoring specified channel layout\n",
buf, channels, avctx->channels);
avctx->channel_layout = 0;
}
}
if (avctx->channels && avctx->channels < 0 ||
avctx->channels > FF_SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}
if (avctx->sub_charenc) {
if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Character encoding is only "
"supported with subtitles codecs\n");
ret = AVERROR(EINVAL);
goto free_and_end;
} else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) {
av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, "
"subtitles character encoding will be ignored\n",
avctx->codec_descriptor->name);
avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_DO_NOTHING;
} else {
/* input character encoding is set for a text based subtitle
* codec at this point */
if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_AUTOMATIC)
avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_PRE_DECODER;
if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_PRE_DECODER) {
#if CONFIG_ICONV
iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
if (cd == (iconv_t)-1) {
av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
"with input character encoding \"%s\"\n", avctx->sub_charenc);
ret = AVERROR(errno);
goto free_and_end;
}
iconv_close(cd);
#else
av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles "
"conversion needs a libavcodec built with iconv support "
"for this codec\n");
ret = AVERROR(ENOSYS);
goto free_and_end;
#endif
}
}
}
}
end:
ff_unlock_avcodec();
if (options) {
av_dict_free(options);
*options = tmp;
}
return ret;
free_and_end:
av_dict_free(&tmp);
av_freep(&avctx->priv_data);
if (avctx->internal) {
av_frame_free(&avctx->internal->to_free);
av_freep(&avctx->internal->pool);
}
av_freep(&avctx->internal);
avctx->codec = NULL;
goto end;
}
| 0 |
[
"CWE-703"
] |
FFmpeg
|
e5c7229999182ad1cef13b9eca050dba7a5a08da
| 110,423,017,138,766,180,000,000,000,000,000,000,000 | 352 |
avcodec/utils: set AVFrame format unconditional
Fixes inconsistency and out of array accesses
Fixes: 10cdd7e63e7f66e3e66273939e0863dd-asan_heap-oob_1a4ff32_7078_cov_4056274555_mov_h264_aac__mp4box_frag.mp4
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <[email protected]>
|
int perf_proc_update_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (ret || !write)
return ret;
max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ);
perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate;
update_perf_cpu_limits();
return 0;
}
| 0 |
[
"CWE-284",
"CWE-264"
] |
linux
|
f63a8daa5812afef4f06c962351687e1ff9ccb2b
| 83,074,217,356,222,720,000,000,000,000,000,000,000 | 15 |
perf: Fix event->ctx locking
There have been a few reported issues wrt. the lack of locking around
changing event->ctx. This patch tries to address those.
It avoids the whole rwsem thing; and while it appears to work, please
give it some thought in review.
What I did fail at is sensible runtime checks on the use of
event->ctx, the RCU use makes it very hard.
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
|
int mg_base64_encode(const unsigned char *p, int n, char *to) {
int i, len = 0;
for (i = 0; i < n; i++) len = mg_base64_update(p[i], to, len);
len = mg_base64_final(to, len);
return len;
}
| 0 |
[
"CWE-552"
] |
mongoose
|
c65c8fdaaa257e0487ab0aaae9e8f6b439335945
| 330,658,133,853,040,920,000,000,000,000,000,000,000 | 6 |
Protect against the directory traversal in mg_upload()
|
Subsets and Splits
CWE 416 & 19
The query filters records related to specific CWEs (Common Weakness Enumerations), providing a basic overview of entries with these vulnerabilities but without deeper analysis.
CWE Frequency in Train Set
Counts the occurrences of each CWE (Common Weakness Enumeration) in the dataset, providing a basic distribution but limited insight.