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
|
---|---|---|---|---|---|---|---|
_dbus_get_is_errno_eagain_or_ewouldblock (int e)
{
/* Avoid the -Wlogical-op GCC warning, which can be triggered when EAGAIN and
* EWOULDBLOCK are numerically equal, which is permitted as described by
* errno(3).
*/
#if EAGAIN == EWOULDBLOCK
return e == EAGAIN;
#else
return e == EAGAIN || e == EWOULDBLOCK;
#endif
}
| 0 |
[
"CWE-404"
] |
dbus
|
872b085f12f56da25a2dbd9bd0b2dff31d5aea63
| 95,117,412,833,017,200,000,000,000,000,000,000,000 | 12 |
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
|
template<typename tz, typename tp, typename tf, typename tc, typename to>
CImg<T>& _draw_object3d(void *const pboard, CImg<tz>& zbuffer,
const float X, const float Y, const float Z,
const CImg<tp>& vertices,
const CImgList<tf>& primitives,
const CImgList<tc>& colors,
const to& opacities,
const unsigned int render_type,
const bool is_double_sided, const float focale,
const float lightx, const float lighty, const float lightz,
const float specular_lightness, const float specular_shininess,
const float g_opacity, const float sprite_scale) {
typedef typename cimg::superset2<tp,tz,float>::type tpfloat;
typedef typename to::value_type _to;
if (is_empty() || !vertices || !primitives) return *this;
CImg<char> error_message(1024);
if (!vertices.is_object3d(primitives,colors,opacities,false,error_message))
throw CImgArgumentException(_cimg_instance
"draw_object3d(): Invalid specified 3D object (%u,%u) (%s).",
cimg_instance,vertices._width,primitives._width,error_message.data());
#ifndef cimg_use_board
if (pboard) return *this;
#endif
if (render_type==5) cimg::mutex(10); // Static variable used in this case, breaks thread-safety
const float
nspec = 1 - (specular_lightness<0.f?0.f:(specular_lightness>1.f?1.f:specular_lightness)),
nspec2 = 1 + (specular_shininess<0.f?0.f:specular_shininess),
nsl1 = (nspec2 - 1)/cimg::sqr(nspec - 1),
nsl2 = 1 - 2*nsl1*nspec,
nsl3 = nspec2 - nsl1 - nsl2;
// Create light texture for phong-like rendering.
CImg<floatT> light_texture;
if (render_type==5) {
if (colors._width>primitives._width) {
static CImg<floatT> default_light_texture;
static const tc *lptr = 0;
static tc ref_values[64] = { 0 };
const CImg<tc>& img = colors.back();
bool is_same_texture = (lptr==img._data);
if (is_same_texture)
for (unsigned int r = 0, j = 0; j<8; ++j)
for (unsigned int i = 0; i<8; ++i)
if (ref_values[r++]!=img(i*img._width/9,j*img._height/9,0,(i + j)%img._spectrum)) {
is_same_texture = false; break;
}
if (!is_same_texture || default_light_texture._spectrum<_spectrum) {
(default_light_texture.assign(img,false)/=255).resize(-100,-100,1,_spectrum);
lptr = colors.back().data();
for (unsigned int r = 0, j = 0; j<8; ++j)
for (unsigned int i = 0; i<8; ++i)
ref_values[r++] = img(i*img._width/9,j*img._height/9,0,(i + j)%img._spectrum);
}
light_texture.assign(default_light_texture,true);
} else {
static CImg<floatT> default_light_texture;
static float olightx = 0, olighty = 0, olightz = 0, ospecular_shininess = 0;
if (!default_light_texture ||
lightx!=olightx || lighty!=olighty || lightz!=olightz ||
specular_shininess!=ospecular_shininess || default_light_texture._spectrum<_spectrum) {
default_light_texture.assign(512,512);
const float
dlx = lightx - X,
dly = lighty - Y,
dlz = lightz - Z,
nl = cimg::hypot(dlx,dly,dlz),
nlx = (default_light_texture._width - 1)/2*(1 + dlx/nl),
nly = (default_light_texture._height - 1)/2*(1 + dly/nl),
white[] = { 1 };
default_light_texture.draw_gaussian(nlx,nly,default_light_texture._width/3.f,white);
cimg_forXY(default_light_texture,x,y) {
const float factor = default_light_texture(x,y);
if (factor>nspec) default_light_texture(x,y) = std::min(2.f,nsl1*factor*factor + nsl2*factor + nsl3);
}
default_light_texture.resize(-100,-100,1,_spectrum);
olightx = lightx; olighty = lighty; olightz = lightz; ospecular_shininess = specular_shininess;
}
light_texture.assign(default_light_texture,true);
}
}
// Compute 3D to 2D projection.
CImg<tpfloat> projections(vertices._width,2);
tpfloat parallzmin = cimg::type<tpfloat>::max();
const float absfocale = focale?cimg::abs(focale):0;
if (absfocale) {
cimg_pragma_openmp(parallel for cimg_openmp_if_size(projections.size(),4096))
cimg_forX(projections,l) { // Perspective projection
const tpfloat
x = (tpfloat)vertices(l,0),
y = (tpfloat)vertices(l,1),
z = (tpfloat)vertices(l,2);
const tpfloat projectedz = z + Z + absfocale;
projections(l,1) = Y + absfocale*y/projectedz;
projections(l,0) = X + absfocale*x/projectedz;
}
} else {
cimg_pragma_openmp(parallel for cimg_openmp_if_size(projections.size(),4096))
cimg_forX(projections,l) { // Parallel projection
const tpfloat
x = (tpfloat)vertices(l,0),
y = (tpfloat)vertices(l,1),
z = (tpfloat)vertices(l,2);
if (z<parallzmin) parallzmin = z;
projections(l,1) = Y + y;
projections(l,0) = X + x;
}
}
const float _focale = absfocale?absfocale:(1e5f-parallzmin);
float zmax = 0;
if (zbuffer) zmax = vertices.get_shared_row(2).max();
// Compute visible primitives.
CImg<uintT> visibles(primitives._width,1,1,1,~0U);
CImg<tpfloat> zrange(primitives._width);
const tpfloat zmin = absfocale?(tpfloat)(1.5f - absfocale):cimg::type<tpfloat>::min();
bool is_forward = zbuffer?true:false;
cimg_pragma_openmp(parallel for cimg_openmp_if_size(primitives.size(),4096))
cimglist_for(primitives,l) {
const CImg<tf>& primitive = primitives[l];
switch (primitive.size()) {
case 1 : { // Point
CImg<_to> _opacity;
__draw_object3d(opacities,l,_opacity);
if (l<=colors.width() && (colors[l].size()!=_spectrum || _opacity)) is_forward = false;
const unsigned int i0 = (unsigned int)primitive(0);
const tpfloat z0 = Z + vertices(i0,2);
if (z0>zmin) {
visibles(l) = (unsigned int)l;
zrange(l) = z0;
}
} break;
case 5 : { // Sphere
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1);
const tpfloat
Xc = 0.5f*((float)vertices(i0,0) + (float)vertices(i1,0)),
Yc = 0.5f*((float)vertices(i0,1) + (float)vertices(i1,1)),
Zc = 0.5f*((float)vertices(i0,2) + (float)vertices(i1,2)),
_zc = Z + Zc,
zc = _zc + _focale,
xc = X + Xc*(absfocale?absfocale/zc:1),
yc = Y + Yc*(absfocale?absfocale/zc:1),
radius = 0.5f*cimg::hypot(vertices(i1,0) - vertices(i0,0),
vertices(i1,1) - vertices(i0,1),
vertices(i1,2) - vertices(i0,2))*(absfocale?absfocale/zc:1),
xm = xc - radius,
ym = yc - radius,
xM = xc + radius,
yM = yc + radius;
if (xM>=0 && xm<_width && yM>=0 && ym<_height && _zc>zmin) {
visibles(l) = (unsigned int)l;
zrange(l) = _zc;
}
is_forward = false;
} break;
case 2 : case 6 : { // Segment
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1);
const tpfloat
x0 = projections(i0,0), y0 = projections(i0,1), z0 = Z + vertices(i0,2),
x1 = projections(i1,0), y1 = projections(i1,1), z1 = Z + vertices(i1,2);
tpfloat xm, xM, ym, yM;
if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
if (xM>=0 && xm<_width && yM>=0 && ym<_height && z0>zmin && z1>zmin) {
visibles(l) = (unsigned int)l;
zrange(l) = (z0 + z1)/2;
}
} break;
case 3 : case 9 : { // Triangle
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1),
i2 = (unsigned int)primitive(2);
const tpfloat
x0 = projections(i0,0), y0 = projections(i0,1), z0 = Z + vertices(i0,2),
x1 = projections(i1,0), y1 = projections(i1,1), z1 = Z + vertices(i1,2),
x2 = projections(i2,0), y2 = projections(i2,1), z2 = Z + vertices(i2,2);
tpfloat xm, xM, ym, yM;
if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
if (x2<xm) xm = x2;
if (x2>xM) xM = x2;
if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
if (y2<ym) ym = y2;
if (y2>yM) yM = y2;
if (xM>=0 && xm<_width && yM>=0 && ym<_height && z0>zmin && z1>zmin && z2>zmin) {
const tpfloat d = (x1-x0)*(y2-y0) - (x2-x0)*(y1-y0);
if (is_double_sided || d<0) {
visibles(l) = (unsigned int)l;
zrange(l) = (z0 + z1 + z2)/3;
}
}
} 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);
const tpfloat
x0 = projections(i0,0), y0 = projections(i0,1), z0 = Z + vertices(i0,2),
x1 = projections(i1,0), y1 = projections(i1,1), z1 = Z + vertices(i1,2),
x2 = projections(i2,0), y2 = projections(i2,1), z2 = Z + vertices(i2,2),
x3 = projections(i3,0), y3 = projections(i3,1), z3 = Z + vertices(i3,2);
tpfloat xm, xM, ym, yM;
if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
if (x2<xm) xm = x2;
if (x2>xM) xM = x2;
if (x3<xm) xm = x3;
if (x3>xM) xM = x3;
if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
if (y2<ym) ym = y2;
if (y2>yM) yM = y2;
if (y3<ym) ym = y3;
if (y3>yM) yM = y3;
if (xM>=0 && xm<_width && yM>=0 && ym<_height && z0>zmin && z1>zmin && z2>zmin && z3>zmin) {
const float d = (x1 - x0)*(y2 - y0) - (x2 - x0)*(y1 - y0);
if (is_double_sided || d<0) {
visibles(l) = (unsigned int)l;
zrange(l) = (z0 + z1 + z2 + z3)/4;
}
}
} break;
default :
if (render_type==5) cimg::mutex(10,0);
throw CImgArgumentException(_cimg_instance
"draw_object3d(): Invalid primitive[%u] with size %u "
"(should have size 1,2,3,4,5,6,9 or 12).",
cimg_instance,
l,primitive.size());
}
}
// Force transparent primitives to be drawn last when zbuffer is activated
// (and if object contains no spheres or sprites).
if (is_forward)
cimglist_for(primitives,l)
if (___draw_object3d(opacities,l)!=1) zrange(l) = 2*zmax - zrange(l);
// Sort only visibles primitives.
unsigned int *p_visibles = visibles._data;
tpfloat *p_zrange = zrange._data;
const tpfloat *ptrz = p_zrange;
cimg_for(visibles,ptr,unsigned int) {
if (*ptr!=~0U) { *(p_visibles++) = *ptr; *(p_zrange++) = *ptrz; }
++ptrz;
}
const unsigned int nb_visibles = (unsigned int)(p_zrange - zrange._data);
if (!nb_visibles) {
if (render_type==5) cimg::mutex(10,0);
return *this;
}
CImg<uintT> permutations;
CImg<tpfloat>(zrange._data,nb_visibles,1,1,1,true).sort(permutations,is_forward);
// Compute light properties
CImg<floatT> lightprops;
switch (render_type) {
case 3 : { // Flat Shading
lightprops.assign(nb_visibles);
cimg_pragma_openmp(parallel for cimg_openmp_if_size(nb_visibles,4096))
cimg_forX(lightprops,l) {
const CImg<tf>& primitive = primitives(visibles(permutations(l)));
const unsigned int psize = (unsigned int)primitive.size();
if (psize==3 || psize==4 || psize==9 || psize==12) {
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1),
i2 = (unsigned int)primitive(2);
const tpfloat
x0 = (tpfloat)vertices(i0,0), y0 = (tpfloat)vertices(i0,1), z0 = (tpfloat)vertices(i0,2),
x1 = (tpfloat)vertices(i1,0), y1 = (tpfloat)vertices(i1,1), z1 = (tpfloat)vertices(i1,2),
x2 = (tpfloat)vertices(i2,0), y2 = (tpfloat)vertices(i2,1), z2 = (tpfloat)vertices(i2,2),
dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
nx = dy1*dz2 - dz1*dy2,
ny = dz1*dx2 - dx1*dz2,
nz = dx1*dy2 - dy1*dx2,
norm = 1e-5f + cimg::hypot(nx,ny,nz),
lx = X + (x0 + x1 + x2)/3 - lightx,
ly = Y + (y0 + y1 + y2)/3 - lighty,
lz = Z + (z0 + z1 + z2)/3 - lightz,
nl = 1e-5f + cimg::hypot(lx,ly,lz),
factor = std::max(cimg::abs(-lx*nx - ly*ny - lz*nz)/(norm*nl),(tpfloat)0);
lightprops[l] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
} else lightprops[l] = 1;
}
} break;
case 4 : // Gouraud Shading
case 5 : { // Phong-Shading
CImg<tpfloat> vertices_normals(vertices._width,6,1,1,0);
cimg_pragma_openmp(parallel for cimg_openmp_if_size(nb_visibles,4096))
for (int l = 0; l<(int)nb_visibles; ++l) {
const CImg<tf>& primitive = primitives[visibles(l)];
const unsigned int psize = (unsigned int)primitive.size();
const bool
triangle_flag = (psize==3) || (psize==9),
quadrangle_flag = (psize==4) || (psize==12);
if (triangle_flag || quadrangle_flag) {
const unsigned int
i0 = (unsigned int)primitive(0),
i1 = (unsigned int)primitive(1),
i2 = (unsigned int)primitive(2),
i3 = quadrangle_flag?(unsigned int)primitive(3):0;
const tpfloat
x0 = (tpfloat)vertices(i0,0), y0 = (tpfloat)vertices(i0,1), z0 = (tpfloat)vertices(i0,2),
x1 = (tpfloat)vertices(i1,0), y1 = (tpfloat)vertices(i1,1), z1 = (tpfloat)vertices(i1,2),
x2 = (tpfloat)vertices(i2,0), y2 = (tpfloat)vertices(i2,1), z2 = (tpfloat)vertices(i2,2),
dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
nnx = dy1*dz2 - dz1*dy2,
nny = dz1*dx2 - dx1*dz2,
nnz = dx1*dy2 - dy1*dx2,
norm = 1e-5f + cimg::hypot(nnx,nny,nnz),
nx = nnx/norm,
ny = nny/norm,
nz = nnz/norm;
unsigned int ix = 0, iy = 1, iz = 2;
if (is_double_sided && nz>0) { ix = 3; iy = 4; iz = 5; }
vertices_normals(i0,ix)+=nx; vertices_normals(i0,iy)+=ny; vertices_normals(i0,iz)+=nz;
vertices_normals(i1,ix)+=nx; vertices_normals(i1,iy)+=ny; vertices_normals(i1,iz)+=nz;
vertices_normals(i2,ix)+=nx; vertices_normals(i2,iy)+=ny; vertices_normals(i2,iz)+=nz;
if (quadrangle_flag) {
vertices_normals(i3,ix)+=nx; vertices_normals(i3,iy)+=ny; vertices_normals(i3,iz)+=nz;
}
}
}
if (is_double_sided) cimg_forX(vertices_normals,p) {
const float
nx0 = vertices_normals(p,0), ny0 = vertices_normals(p,1), nz0 = vertices_normals(p,2),
nx1 = vertices_normals(p,3), ny1 = vertices_normals(p,4), nz1 = vertices_normals(p,5),
n0 = nx0*nx0 + ny0*ny0 + nz0*nz0, n1 = nx1*nx1 + ny1*ny1 + nz1*nz1;
if (n1>n0) {
vertices_normals(p,0) = -nx1;
vertices_normals(p,1) = -ny1;
vertices_normals(p,2) = -nz1;
}
}
if (render_type==4) {
lightprops.assign(vertices._width);
cimg_pragma_openmp(parallel for cimg_openmp_if_size(nb_visibles,4096))
cimg_forX(lightprops,l) {
const tpfloat
nx = vertices_normals(l,0),
ny = vertices_normals(l,1),
nz = vertices_normals(l,2),
norm = 1e-5f + cimg::hypot(nx,ny,nz),
lx = X + vertices(l,0) - lightx,
ly = Y + vertices(l,1) - lighty,
lz = Z + vertices(l,2) - lightz,
nl = 1e-5f + cimg::hypot(lx,ly,lz),
factor = std::max((-lx*nx - ly*ny - lz*nz)/(norm*nl),(tpfloat)0);
lightprops[l] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
}
} else {
const unsigned int
lw2 = light_texture._width/2 - 1,
lh2 = light_texture._height/2 - 1;
lightprops.assign(vertices._width,2);
cimg_pragma_openmp(parallel for cimg_openmp_if_size(nb_visibles,4096))
cimg_forX(lightprops,l) {
const tpfloat
nx = vertices_normals(l,0),
ny = vertices_normals(l,1),
nz = vertices_normals(l,2),
norm = 1e-5f + cimg::hypot(nx,ny,nz),
nnx = nx/norm,
nny = ny/norm;
lightprops(l,0) = lw2*(1 + nnx);
lightprops(l,1) = lh2*(1 + nny);
}
}
} break;
}
// Draw visible primitives
const CImg<tc> default_color(1,_spectrum,1,1,(tc)200);
CImg<_to> _opacity;
for (unsigned int l = 0; l<nb_visibles; ++l) {
const unsigned int n_primitive = visibles(permutations(l));
const CImg<tf>& primitive = primitives[n_primitive];
const CImg<tc>
&__color = n_primitive<colors._width?colors[n_primitive]:CImg<tc>(),
_color = (__color && __color.size()!=_spectrum && __color._spectrum<_spectrum)?
__color.get_resize(-100,-100,-100,_spectrum,0):CImg<tc>(),
&color = _color?_color:(__color?__color:default_color);
const tc *const pcolor = color._data;
float opacity = __draw_object3d(opacities,n_primitive,_opacity);
if (_opacity.is_empty()) opacity*=g_opacity;
#ifdef cimg_use_board
LibBoard::Board &board = *(LibBoard::Board*)pboard;
#endif
switch (primitive.size()) {
case 1 : { // Colored point or sprite
const unsigned int n0 = (unsigned int)primitive[0];
const int x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1));
if (_opacity.is_empty()) { // Scalar opacity
if (color.size()==_spectrum) { // Colored point
draw_point(x0,y0,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawDot((float)x0,height()-(float)y0);
}
#endif
} else { // Sprite
const tpfloat z = Z + vertices(n0,2);
const float factor = focale<0?1:sprite_scale*(absfocale?absfocale/(z + absfocale):1);
const unsigned int
_sw = (unsigned int)(color._width*factor),
_sh = (unsigned int)(color._height*factor),
sw = _sw?_sw:1, sh = _sh?_sh:1;
const int nx0 = x0 - (int)sw/2, ny0 = y0 - (int)sh/2;
if (sw<=3*_width/2 && sh<=3*_height/2 &&
(nx0 + (int)sw/2>=0 || nx0 - (int)sw/2<width() || ny0 + (int)sh/2>=0 || ny0 - (int)sh/2<height())) {
const CImg<tc>
_sprite = (sw!=color._width || sh!=color._height)?
color.get_resize(sw,sh,1,-100,render_type<=3?1:3):CImg<tc>(),
&sprite = _sprite?_sprite:color;
draw_image(nx0,ny0,sprite,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128);
board.setFillColor(LibBoard::Color::Null);
board.drawRectangle((float)nx0,height() - (float)ny0,sw,sh);
}
#endif
}
}
} else { // Opacity mask
const tpfloat z = Z + vertices(n0,2);
const float factor = focale<0?1:sprite_scale*(absfocale?absfocale/(z + absfocale):1);
const unsigned int
_sw = (unsigned int)(std::max(color._width,_opacity._width)*factor),
_sh = (unsigned int)(std::max(color._height,_opacity._height)*factor),
sw = _sw?_sw:1, sh = _sh?_sh:1;
const int nx0 = x0 - (int)sw/2, ny0 = y0 - (int)sh/2;
if (sw<=3*_width/2 && sh<=3*_height/2 &&
(nx0 + (int)sw/2>=0 || nx0 - (int)sw/2<width() || ny0 + (int)sh/2>=0 || ny0 - (int)sh/2<height())) {
const CImg<tc>
_sprite = (sw!=color._width || sh!=color._height)?
color.get_resize(sw,sh,1,-100,render_type<=3?1:3):CImg<tc>(),
&sprite = _sprite?_sprite:color;
const CImg<_to>
_nopacity = (sw!=_opacity._width || sh!=_opacity._height)?
_opacity.get_resize(sw,sh,1,-100,render_type<=3?1:3):CImg<_to>(),
&nopacity = _nopacity?_nopacity:_opacity;
draw_image(nx0,ny0,sprite,nopacity,g_opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128);
board.setFillColor(LibBoard::Color::Null);
board.drawRectangle((float)nx0,height() - (float)ny0,sw,sh);
}
#endif
}
}
} break;
case 2 : { // Colored line
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1];
const int
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1));
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale;
if (render_type) {
if (zbuffer) draw_line(zbuffer,x0,y0,z0,x1,y1,z1,pcolor,opacity);
else draw_line(x0,y0,x1,y1,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,x1,height() - (float)y1);
}
#endif
} else {
draw_point(x0,y0,pcolor,opacity).draw_point(x1,y1,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
}
#endif
}
} break;
case 5 : { // Colored sphere
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1],
is_wireframe = (unsigned int)primitive[2];
const float
Xc = 0.5f*((float)vertices(n0,0) + (float)vertices(n1,0)),
Yc = 0.5f*((float)vertices(n0,1) + (float)vertices(n1,1)),
Zc = 0.5f*((float)vertices(n0,2) + (float)vertices(n1,2)),
zc = Z + Zc + _focale,
xc = X + Xc*(absfocale?absfocale/zc:1),
yc = Y + Yc*(absfocale?absfocale/zc:1),
radius = 0.5f*cimg::hypot(vertices(n1,0) - vertices(n0,0),
vertices(n1,1) - vertices(n0,1),
vertices(n1,2) - vertices(n0,2))*(absfocale?absfocale/zc:1);
switch (render_type) {
case 0 :
draw_point((int)xc,(int)yc,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawDot(xc,height() - yc);
}
#endif
break;
case 1 :
draw_circle((int)xc,(int)yc,(int)radius,pcolor,opacity,~0U);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.setFillColor(LibBoard::Color::Null);
board.drawCircle(xc,height() - yc,radius);
}
#endif
break;
default :
if (is_wireframe) draw_circle((int)xc,(int)yc,(int)radius,pcolor,opacity,~0U);
else draw_circle((int)xc,(int)yc,(int)radius,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
if (!is_wireframe) board.fillCircle(xc,height() - yc,radius);
else {
board.setFillColor(LibBoard::Color::Null);
board.drawCircle(xc,height() - yc,radius);
}
}
#endif
break;
}
} break;
case 6 : { // Textured line
if (!__color) {
if (render_type==5) cimg::mutex(10,0);
throw CImgArgumentException(_cimg_instance
"draw_object3d(): Undefined texture for line primitive [%u].",
cimg_instance,n_primitive);
}
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1];
const int
tx0 = (int)primitive[2], ty0 = (int)primitive[3],
tx1 = (int)primitive[4], ty1 = (int)primitive[5],
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1));
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale;
if (render_type) {
if (zbuffer) draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity);
else draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,(float)x1,height() - (float)y1);
}
#endif
} else {
draw_point(x0,y0,color.get_vector_at(tx0<=0?0:tx0>=color.width()?color.width() - 1:tx0,
ty0<=0?0:ty0>=color.height()?color.height() - 1:ty0)._data,opacity).
draw_point(x1,y1,color.get_vector_at(tx1<=0?0:tx1>=color.width()?color.width() - 1:tx1,
ty1<=0?0:ty1>=color.height()?color.height() - 1:ty1)._data,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
}
#endif
}
} break;
case 3 : { // Colored triangle
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1],
n2 = (unsigned int)primitive[2];
const int
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1)),
x2 = cimg::uiround(projections(n2,0)), y2 = cimg::uiround(projections(n2,1));
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale,
z2 = vertices(n2,2) + Z + _focale;
switch (render_type) {
case 0 :
draw_point(x0,y0,pcolor,opacity).draw_point(x1,y1,pcolor,opacity).draw_point(x2,y2,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
board.drawDot((float)x2,height() - (float)y2);
}
#endif
break;
case 1 :
if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,pcolor,opacity).draw_line(zbuffer,x0,y0,z0,x2,y2,z2,pcolor,opacity).
draw_line(zbuffer,x1,y1,z1,x2,y2,z2,pcolor,opacity);
else
draw_line(x0,y0,x1,y1,pcolor,opacity).draw_line(x0,y0,x2,y2,pcolor,opacity).
draw_line(x1,y1,x2,y2,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,(float)x1,height() - (float)y1);
board.drawLine((float)x0,height() - (float)y0,(float)x2,height() - (float)y2);
board.drawLine((float)x1,height() - (float)y1,(float)x2,height() - (float)y2);
}
#endif
break;
case 2 :
if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,opacity);
else draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
}
#endif
break;
case 3 :
if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,opacity,lightprops(l));
else _draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,opacity,lightprops(l));
#ifdef cimg_use_board
if (pboard) {
const float lp = std::min(lightprops(l),1.f);
board.setPenColorRGBi((unsigned char)(color[0]*lp),
(unsigned char)(color[1]*lp),
(unsigned char)(color[2]*lp),
(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
}
#endif
break;
case 4 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,
lightprops(n0),lightprops(n1),lightprops(n2),opacity);
else draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,lightprops(n0),lightprops(n1),lightprops(n2),opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi((unsigned char)(color[0]),
(unsigned char)(color[1]),
(unsigned char)(color[2]),
(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,lightprops(n0),
(float)x1,height() - (float)y1,lightprops(n1),
(float)x2,height() - (float)y2,lightprops(n2));
}
#endif
break;
case 5 : {
const unsigned int
lx0 = (unsigned int)cimg::uiround(lightprops(n0,0)), ly0 = (unsigned int)cimg::uiround(lightprops(n0,1)),
lx1 = (unsigned int)cimg::uiround(lightprops(n1,0)), ly1 = (unsigned int)cimg::uiround(lightprops(n1,1)),
lx2 = (unsigned int)cimg::uiround(lightprops(n2,0)), ly2 = (unsigned int)cimg::uiround(lightprops(n2,1));
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
else draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
#ifdef cimg_use_board
if (pboard) {
const float
l0 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n0,0))),
(int)(light_texture.height()/2*(1 + lightprops(n0,1)))),
l1 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n1,0))),
(int)(light_texture.height()/2*(1 + lightprops(n1,1)))),
l2 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n2,0))),
(int)(light_texture.height()/2*(1 + lightprops(n2,1))));
board.setPenColorRGBi((unsigned char)(color[0]),
(unsigned char)(color[1]),
(unsigned char)(color[2]),
(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,l0,
(float)x1,height() - (float)y1,l1,
(float)x2,height() - (float)y2,l2);
}
#endif
} break;
}
} break;
case 4 : { // Colored quadrangle
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1],
n2 = (unsigned int)primitive[2],
n3 = (unsigned int)primitive[3];
const int
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1)),
x2 = cimg::uiround(projections(n2,0)), y2 = cimg::uiround(projections(n2,1)),
x3 = cimg::uiround(projections(n3,0)), y3 = cimg::uiround(projections(n3,1)),
xc = (x0 + x1 + x2 + x3)/4, yc = (y0 + y1 + y2 + y3)/4;
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale,
z2 = vertices(n2,2) + Z + _focale,
z3 = vertices(n3,2) + Z + _focale,
zc = (z0 + z1 + z2 + z3)/4;
switch (render_type) {
case 0 :
draw_point(x0,y0,pcolor,opacity).draw_point(x1,y1,pcolor,opacity).
draw_point(x2,y2,pcolor,opacity).draw_point(x3,y3,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
board.drawDot((float)x2,height() - (float)y2);
board.drawDot((float)x3,height() - (float)y3);
}
#endif
break;
case 1 :
if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,pcolor,opacity).draw_line(zbuffer,x1,y1,z1,x2,y2,z2,pcolor,opacity).
draw_line(zbuffer,x2,y2,z2,x3,y3,z3,pcolor,opacity).draw_line(zbuffer,x3,y3,z3,x0,y0,z0,pcolor,opacity);
else
draw_line(x0,y0,x1,y1,pcolor,opacity).draw_line(x1,y1,x2,y2,pcolor,opacity).
draw_line(x2,y2,x3,y3,pcolor,opacity).draw_line(x3,y3,x0,y0,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,(float)x1,height() - (float)y1);
board.drawLine((float)x1,height() - (float)y1,(float)x2,height() - (float)y2);
board.drawLine((float)x2,height() - (float)y2,(float)x3,height() - (float)y3);
board.drawLine((float)x3,height() - (float)y3,(float)x0,height() - (float)y0);
}
#endif
break;
case 2 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,opacity).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,pcolor,opacity);
else
draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,opacity).draw_triangle(x0,y0,x2,y2,x3,y3,pcolor,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
board.fillTriangle((float)x0,height() - (float)y0,
(float)x2,height() - (float)y2,
(float)x3,height() - (float)y3);
}
#endif
break;
case 3 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,pcolor,opacity,lightprops(l)).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,pcolor,opacity,lightprops(l));
else
_draw_triangle(x0,y0,x1,y1,x2,y2,pcolor,opacity,lightprops(l)).
_draw_triangle(x0,y0,x2,y2,x3,y3,pcolor,opacity,lightprops(l));
#ifdef cimg_use_board
if (pboard) {
const float lp = std::min(lightprops(l),1.f);
board.setPenColorRGBi((unsigned char)(color[0]*lp),
(unsigned char)(color[1]*lp),
(unsigned char)(color[2]*lp),(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
board.fillTriangle((float)x0,height() - (float)y0,
(float)x2,height() - (float)y2,
(float)x3,height() - (float)y3);
}
#endif
break;
case 4 : {
const float
lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
lightprop2 = lightprops(n2), lightprop3 = lightprops(n3),
lightpropc = (lightprop0 + lightprop1 + lightprop2 + lightprop2)/4;
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,xc,yc,zc,pcolor,lightprop0,lightprop1,lightpropc,opacity).
draw_triangle(zbuffer,x1,y1,z1,x2,y2,z2,xc,yc,zc,pcolor,lightprop1,lightprop2,lightpropc,opacity).
draw_triangle(zbuffer,x2,y2,z2,x3,y3,z3,xc,yc,zc,pcolor,lightprop2,lightprop3,lightpropc,opacity).
draw_triangle(zbuffer,x3,y3,z3,x0,y0,z0,xc,yc,zc,pcolor,lightprop3,lightprop0,lightpropc,opacity);
else
draw_triangle(x0,y0,x1,y1,xc,yc,pcolor,lightprop0,lightprop1,lightpropc,opacity).
draw_triangle(x1,y1,x2,y2,xc,yc,pcolor,lightprop1,lightprop2,lightpropc,opacity).
draw_triangle(x2,y2,x3,y3,xc,yc,pcolor,lightprop2,lightprop3,lightpropc,opacity).
draw_triangle(x3,y3,x0,y0,xc,yc,pcolor,lightprop3,lightprop0,lightpropc,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi((unsigned char)(color[0]),
(unsigned char)(color[1]),
(unsigned char)(color[2]),
(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,lightprop0,
(float)x1,height() - (float)y1,lightprop1,
(float)x2,height() - (float)y2,lightprop2);
board.fillGouraudTriangle((float)x0,height() - (float)y0,lightprop0,
(float)x2,height() - (float)y2,lightprop2,
(float)x3,height() - (float)y3,lightprop3);
}
#endif
} break;
case 5 : {
const unsigned int
lx0 = (unsigned int)cimg::uiround(lightprops(n0,0)), ly0 = (unsigned int)cimg::uiround(lightprops(n0,1)),
lx1 = (unsigned int)cimg::uiround(lightprops(n1,0)), ly1 = (unsigned int)cimg::uiround(lightprops(n1,1)),
lx2 = (unsigned int)cimg::uiround(lightprops(n2,0)), ly2 = (unsigned int)cimg::uiround(lightprops(n2,1)),
lx3 = (unsigned int)cimg::uiround(lightprops(n3,0)), ly3 = (unsigned int)cimg::uiround(lightprops(n3,1)),
lxc = (lx0 + lx1 + lx2 + lx3)/4, lyc = (ly0 + ly1 + ly2 + ly3)/4;
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,xc,yc,zc,pcolor,light_texture,lx0,ly0,lx1,ly1,lxc,lyc,opacity).
draw_triangle(zbuffer,x1,y1,z1,x2,y2,z2,xc,yc,zc,pcolor,light_texture,lx1,ly1,lx2,ly2,lxc,lyc,opacity).
draw_triangle(zbuffer,x2,y2,z2,x3,y3,z3,xc,yc,zc,pcolor,light_texture,lx2,ly2,lx3,ly3,lxc,lyc,opacity).
draw_triangle(zbuffer,x3,y3,z3,x0,y0,z0,xc,yc,zc,pcolor,light_texture,lx3,ly3,lx0,ly0,lxc,lyc,opacity);
else
draw_triangle(x0,y0,x1,y1,xc,yc,pcolor,light_texture,lx0,ly0,lx1,ly1,lxc,lyc,opacity).
draw_triangle(x1,y1,x2,y2,xc,yc,pcolor,light_texture,lx1,ly1,lx2,ly2,lxc,lyc,opacity).
draw_triangle(x2,y2,x3,y3,xc,yc,pcolor,light_texture,lx2,ly2,lx3,ly3,lxc,lyc,opacity).
draw_triangle(x3,y3,x0,y0,xc,yc,pcolor,light_texture,lx3,ly3,lx0,ly0,lxc,lyc,opacity);
#ifdef cimg_use_board
if (pboard) {
const float
l0 = light_texture((int)(light_texture.width()/2*(1 + lx0)), (int)(light_texture.height()/2*(1 + ly0))),
l1 = light_texture((int)(light_texture.width()/2*(1 + lx1)), (int)(light_texture.height()/2*(1 + ly1))),
l2 = light_texture((int)(light_texture.width()/2*(1 + lx2)), (int)(light_texture.height()/2*(1 + ly2))),
l3 = light_texture((int)(light_texture.width()/2*(1 + lx3)), (int)(light_texture.height()/2*(1 + ly3)));
board.setPenColorRGBi((unsigned char)(color[0]),
(unsigned char)(color[1]),
(unsigned char)(color[2]),
(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,l0,
(float)x1,height() - (float)y1,l1,
(float)x2,height() - (float)y2,l2);
board.fillGouraudTriangle((float)x0,height() - (float)y0,l0,
(float)x2,height() - (float)y2,l2,
(float)x3,height() - (float)y3,l3);
}
#endif
} break;
}
} break;
case 9 : { // Textured triangle
if (!__color) {
if (render_type==5) cimg::mutex(10,0);
throw CImgArgumentException(_cimg_instance
"draw_object3d(): Undefined texture for triangle primitive [%u].",
cimg_instance,n_primitive);
}
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1],
n2 = (unsigned int)primitive[2];
const int
tx0 = (int)primitive[3], ty0 = (int)primitive[4],
tx1 = (int)primitive[5], ty1 = (int)primitive[6],
tx2 = (int)primitive[7], ty2 = (int)primitive[8],
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1)),
x2 = cimg::uiround(projections(n2,0)), y2 = cimg::uiround(projections(n2,1));
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale,
z2 = vertices(n2,2) + Z + _focale;
switch (render_type) {
case 0 :
draw_point(x0,y0,color.get_vector_at(tx0<=0?0:tx0>=color.width()?color.width() - 1:tx0,
ty0<=0?0:ty0>=color.height()?color.height() - 1:ty0)._data,opacity).
draw_point(x1,y1,color.get_vector_at(tx1<=0?0:tx1>=color.width()?color.width() - 1:tx1,
ty1<=0?0:ty1>=color.height()?color.height() - 1:ty1)._data,opacity).
draw_point(x2,y2,color.get_vector_at(tx2<=0?0:tx2>=color.width()?color.width() - 1:tx2,
ty2<=0?0:ty2>=color.height()?color.height() - 1:ty2)._data,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
board.drawDot((float)x2,height() - (float)y2);
}
#endif
break;
case 1 :
if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity).
draw_line(zbuffer,x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opacity).
draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opacity);
else
draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity).
draw_line(x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opacity).
draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,(float)x1,height() - (float)y1);
board.drawLine((float)x0,height() - (float)y0,(float)x2,height() - (float)y2);
board.drawLine((float)x1,height() - (float)y1,(float)x2,height() - (float)y2);
}
#endif
break;
case 2 :
if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity);
else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
}
#endif
break;
case 3 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity,lightprops(l));
else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity,lightprops(l));
#ifdef cimg_use_board
if (pboard) {
const float lp = std::min(lightprops(l),1.f);
board.setPenColorRGBi((unsigned char)(128*lp),
(unsigned char)(128*lp),
(unsigned char)(128*lp),
(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
}
#endif
break;
case 4 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
lightprops(n0),lightprops(n1),lightprops(n2),opacity);
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
lightprops(n0),lightprops(n1),lightprops(n2),opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,lightprops(n0),
(float)x1,height() - (float)y1,lightprops(n1),
(float)x2,height() - (float)y2,lightprops(n2));
}
#endif
break;
case 5 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
(unsigned int)lightprops(n0,0),(unsigned int)lightprops(n0,1),
(unsigned int)lightprops(n1,0),(unsigned int)lightprops(n1,1),
(unsigned int)lightprops(n2,0),(unsigned int)lightprops(n2,1),
opacity);
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
(unsigned int)lightprops(n0,0),(unsigned int)lightprops(n0,1),
(unsigned int)lightprops(n1,0),(unsigned int)lightprops(n1,1),
(unsigned int)lightprops(n2,0),(unsigned int)lightprops(n2,1),
opacity);
#ifdef cimg_use_board
if (pboard) {
const float
l0 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n0,0))),
(int)(light_texture.height()/2*(1 + lightprops(n0,1)))),
l1 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n1,0))),
(int)(light_texture.height()/2*(1 + lightprops(n1,1)))),
l2 = light_texture((int)(light_texture.width()/2*(1 + lightprops(n2,0))),
(int)(light_texture.height()/2*(1 + lightprops(n2,1))));
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,l0,
(float)x1,height() - (float)y1,l1,
(float)x2,height() - (float)y2,l2);
}
#endif
break;
}
} break;
case 12 : { // Textured quadrangle
if (!__color) {
if (render_type==5) cimg::mutex(10,0);
throw CImgArgumentException(_cimg_instance
"draw_object3d(): Undefined texture for quadrangle primitive [%u].",
cimg_instance,n_primitive);
}
const unsigned int
n0 = (unsigned int)primitive[0],
n1 = (unsigned int)primitive[1],
n2 = (unsigned int)primitive[2],
n3 = (unsigned int)primitive[3];
const int
tx0 = (int)primitive[4], ty0 = (int)primitive[5],
tx1 = (int)primitive[6], ty1 = (int)primitive[7],
tx2 = (int)primitive[8], ty2 = (int)primitive[9],
tx3 = (int)primitive[10], ty3 = (int)primitive[11],
x0 = cimg::uiround(projections(n0,0)), y0 = cimg::uiround(projections(n0,1)),
x1 = cimg::uiround(projections(n1,0)), y1 = cimg::uiround(projections(n1,1)),
x2 = cimg::uiround(projections(n2,0)), y2 = cimg::uiround(projections(n2,1)),
x3 = cimg::uiround(projections(n3,0)), y3 = cimg::uiround(projections(n3,1));
const float
z0 = vertices(n0,2) + Z + _focale,
z1 = vertices(n1,2) + Z + _focale,
z2 = vertices(n2,2) + Z + _focale,
z3 = vertices(n3,2) + Z + _focale;
switch (render_type) {
case 0 :
draw_point(x0,y0,color.get_vector_at(tx0<=0?0:tx0>=color.width()?color.width() - 1:tx0,
ty0<=0?0:ty0>=color.height()?color.height() - 1:ty0)._data,opacity).
draw_point(x1,y1,color.get_vector_at(tx1<=0?0:tx1>=color.width()?color.width() - 1:tx1,
ty1<=0?0:ty1>=color.height()?color.height() - 1:ty1)._data,opacity).
draw_point(x2,y2,color.get_vector_at(tx2<=0?0:tx2>=color.width()?color.width() - 1:tx2,
ty2<=0?0:ty2>=color.height()?color.height() - 1:ty2)._data,opacity).
draw_point(x3,y3,color.get_vector_at(tx3<=0?0:tx3>=color.width()?color.width() - 1:tx3,
ty3<=0?0:ty3>=color.height()?color.height() - 1:ty3)._data,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawDot((float)x0,height() - (float)y0);
board.drawDot((float)x1,height() - (float)y1);
board.drawDot((float)x2,height() - (float)y2);
board.drawDot((float)x3,height() - (float)y3);
}
#endif
break;
case 1 :
if (zbuffer)
draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity).
draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opacity).
draw_line(zbuffer,x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opacity).
draw_line(zbuffer,x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opacity);
else
draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opacity).
draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opacity).
draw_line(x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opacity).
draw_line(x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.drawLine((float)x0,height() - (float)y0,(float)x1,height() - (float)y1);
board.drawLine((float)x1,height() - (float)y1,(float)x2,height() - (float)y2);
board.drawLine((float)x2,height() - (float)y2,(float)x3,height() - (float)y3);
board.drawLine((float)x3,height() - (float)y3,(float)x0,height() - (float)y0);
}
#endif
break;
case 2 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opacity);
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity).
draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
board.fillTriangle((float)x0,height() - (float)y0,
(float)x2,height() - (float)y2,
(float)x3,height() - (float)y3);
}
#endif
break;
case 3 :
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity,lightprops(l)).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opacity,lightprops(l));
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opacity,lightprops(l)).
draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opacity,lightprops(l));
#ifdef cimg_use_board
if (pboard) {
const float lp = std::min(lightprops(l),1.f);
board.setPenColorRGBi((unsigned char)(128*lp),
(unsigned char)(128*lp),
(unsigned char)(128*lp),
(unsigned char)(opacity*255));
board.fillTriangle((float)x0,height() - (float)y0,
(float)x1,height() - (float)y1,
(float)x2,height() - (float)y2);
board.fillTriangle((float)x0,height() - (float)y0,
(float)x2,height() - (float)y2,
(float)x3,height() - (float)y3);
}
#endif
break;
case 4 : {
const float
lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
lightprop2 = lightprops(n2), lightprop3 = lightprops(n3);
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
lightprop0,lightprop1,lightprop2,opacity).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,
lightprop0,lightprop2,lightprop3,opacity);
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
lightprop0,lightprop1,lightprop2,opacity).
draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,
lightprop0,lightprop2,lightprop3,opacity);
#ifdef cimg_use_board
if (pboard) {
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,lightprop0,
(float)x1,height() - (float)y1,lightprop1,
(float)x2,height() - (float)y2,lightprop2);
board.fillGouraudTriangle((float)x0,height() -(float)y0,lightprop0,
(float)x2,height() - (float)y2,lightprop2,
(float)x3,height() - (float)y3,lightprop3);
}
#endif
} break;
case 5 : {
const unsigned int
lx0 = (unsigned int)cimg::uiround(lightprops(n0,0)), ly0 = (unsigned int)cimg::uiround(lightprops(n0,1)),
lx1 = (unsigned int)cimg::uiround(lightprops(n1,0)), ly1 = (unsigned int)cimg::uiround(lightprops(n1,1)),
lx2 = (unsigned int)cimg::uiround(lightprops(n2,0)), ly2 = (unsigned int)cimg::uiround(lightprops(n2,1)),
lx3 = (unsigned int)cimg::uiround(lightprops(n3,0)), ly3 = (unsigned int)cimg::uiround(lightprops(n3,1));
if (zbuffer)
draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opacity).
draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,
light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opacity);
else
draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,
light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opacity).
draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,
light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opacity);
#ifdef cimg_use_board
if (pboard) {
const float
l0 = light_texture((int)(light_texture.width()/2*(1 + lx0)), (int)(light_texture.height()/2*(1 + ly0))),
l1 = light_texture((int)(light_texture.width()/2*(1 + lx1)), (int)(light_texture.height()/2*(1 + ly1))),
l2 = light_texture((int)(light_texture.width()/2*(1 + lx2)), (int)(light_texture.height()/2*(1 + ly2))),
l3 = light_texture((int)(light_texture.width()/2*(1 + lx3)), (int)(light_texture.height()/2*(1 + ly3)));
board.setPenColorRGBi(128,128,128,(unsigned char)(opacity*255));
board.fillGouraudTriangle((float)x0,height() - (float)y0,l0,
(float)x1,height() - (float)y1,l1,
(float)x2,height() - (float)y2,l2);
board.fillGouraudTriangle((float)x0,height() -(float)y0,l0,
(float)x2,height() - (float)y2,l2,
(float)x3,height() - (float)y3,l3);
}
#endif
} break;
}
} break;
}
}
if (render_type==5) cimg::mutex(10,0);
return *this;
| 0 |
[
"CWE-119",
"CWE-787"
] |
CImg
|
ac8003393569aba51048c9d67e1491559877b1d1
| 145,075,964,578,189,520,000,000,000,000,000,000,000 | 1,208 |
.
|
Constant(constant value, int lineno, int col_offset, int end_lineno, int
end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
PyErr_SetString(PyExc_ValueError,
"field value is required for Constant");
return NULL;
}
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Constant_kind;
p->v.Constant.value = value;
p->lineno = lineno;
p->col_offset = col_offset;
p->end_lineno = end_lineno;
p->end_col_offset = end_col_offset;
return p;
}
| 0 |
[
"CWE-125"
] |
cpython
|
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
| 220,455,760,091,085,300,000,000,000,000,000,000,000 | 20 |
bpo-35766: Merge typed_ast back into CPython (GH-11645)
|
void CLASS parse_mos (int offset)
{
char data[40];
int skip, from, i, c, neut[4], planes=0, frot=0;
static const char *mod[] =
{ "","DCB2","Volare","Cantare","CMost","Valeo 6","Valeo 11","Valeo 22",
"Valeo 11p","Valeo 17","","Aptus 17","Aptus 22","Aptus 75","Aptus 65",
"Aptus 54S","Aptus 65S","Aptus 75S","AFi 5","AFi 6","AFi 7",
"AFi-II 7","Aptus-II 7","","Aptus-II 6","","","Aptus-II 10","Aptus-II 5",
"","","","","Aptus-II 10R","Aptus-II 8","","Aptus-II 12","","AFi-II 12" };
float romm_cam[3][3];
fseek (ifp, offset, SEEK_SET);
while (1) {
if (get4() != 0x504b5453) break;
get4();
fread (data, 1, 40, ifp);
skip = get4();
from = ftell(ifp);
// IB start
#ifdef LIBRAW_LIBRARY_BUILD
if (!strcmp(data,"CameraObj_camera_type")) {
stmread(imgdata.lens.makernotes.body, skip, ifp);
}
if (!strcmp(data,"back_serial_number")) {
char buffer [sizeof(imgdata.shootinginfo.BodySerial)];
char *words[4];
int nwords;
stmread(buffer, skip, ifp);
nwords = getwords(buffer, words, 4,sizeof(imgdata.shootinginfo.BodySerial));
strcpy (imgdata.shootinginfo.BodySerial, words[0]);
}
if (!strcmp(data,"CaptProf_serial_number")) {
char buffer [sizeof(imgdata.shootinginfo.InternalBodySerial)];
char *words[4];
int nwords;
stmread(buffer, skip, ifp);
nwords = getwords(buffer, words, 4,sizeof(imgdata.shootinginfo.InternalBodySerial));
strcpy (imgdata.shootinginfo.InternalBodySerial, words[0]);
}
#endif
// IB end
if (!strcmp(data,"JPEG_preview_data")) {
thumb_offset = from;
thumb_length = skip;
}
if (!strcmp(data,"icc_camera_profile")) {
profile_offset = from;
profile_length = skip;
}
if (!strcmp(data,"ShootObj_back_type")) {
fscanf (ifp, "%d", &i);
if ((unsigned) i < sizeof mod / sizeof (*mod))
strcpy (model, mod[i]);
}
if (!strcmp(data,"icc_camera_to_tone_matrix")) {
for (i=0; i < 9; i++)
((float *)romm_cam)[i] = int_to_float(get4());
romm_coeff (romm_cam);
}
if (!strcmp(data,"CaptProf_color_matrix")) {
for (i=0; i < 9; i++)
fscanf (ifp, "%f", (float *)romm_cam + i);
romm_coeff (romm_cam);
}
if (!strcmp(data,"CaptProf_number_of_planes"))
fscanf (ifp, "%d", &planes);
if (!strcmp(data,"CaptProf_raw_data_rotation"))
fscanf (ifp, "%d", &flip);
if (!strcmp(data,"CaptProf_mosaic_pattern"))
FORC4 {
fscanf (ifp, "%d", &i);
if (i == 1) frot = c ^ (c >> 1);
}
if (!strcmp(data,"ImgProf_rotation_angle")) {
fscanf (ifp, "%d", &i);
flip = i - flip;
}
if (!strcmp(data,"NeutObj_neutrals") && !cam_mul[0]) {
FORC4 fscanf (ifp, "%d", neut+c);
FORC3 cam_mul[c] = (float) neut[0] / neut[c+1];
}
if (!strcmp(data,"Rows_data"))
load_flags = get4();
parse_mos (from);
fseek (ifp, skip+from, SEEK_SET);
}
if (planes)
filters = (planes == 1) * 0x01010101 *
(uchar) "\x94\x61\x16\x49"[(flip/90 + frot) & 3];
}
| 0 |
[
"CWE-119",
"CWE-125",
"CWE-787"
] |
LibRaw
|
d13e8f6d1e987b7491182040a188c16a395f1d21
| 260,308,343,620,899,340,000,000,000,000,000,000,000 | 92 |
CVE-2017-1438 credits; fix for Kodak 65000 out of bounds access
|
get_dns_cert (const char *name, estream_t *r_key,
unsigned char **r_fpr, size_t *r_fprlen, char **r_url)
{
#ifdef USE_DNS_CERT
#ifdef USE_ADNS
gpg_error_t err;
adns_state state;
adns_answer *answer = NULL;
unsigned int ctype;
int count;
*r_key = NULL;
*r_fpr = NULL;
*r_fprlen = 0;
*r_url = NULL;
if (adns_init (&state, adns_if_noerrprint, NULL))
{
err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
log_error ("error initializing adns: %s\n", strerror (errno));
return err;
}
if (adns_synchronous (state, name, (adns_r_unknown | my_adns_r_cert),
adns_qf_quoteok_query, &answer))
{
err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
/* log_error ("DNS query failed: %s\n", strerror (errno)); */
adns_finish (state);
return err;
}
if (answer->status != adns_s_ok)
{
/* log_error ("DNS query returned an error: %s (%s)\n", */
/* adns_strerror (answer->status), */
/* adns_errabbrev (answer->status)); */
err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
goto leave;
}
err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
for (count = 0; count < answer->nrrs; count++)
{
int datalen = answer->rrs.byteblock[count].len;
const unsigned char *data = answer->rrs.byteblock[count].data;
if (datalen < 5)
continue; /* Truncated CERT record - skip. */
ctype = ((data[0] << 8) | data[1]);
/* (key tag and algorithm fields are not required.) */
data += 5;
datalen -= 5;
if (ctype == CERTTYPE_PGP && datalen >= 11)
{
/* CERT type is PGP. Gpg checks for a minimum length of 11,
thus we do the same. */
*r_key = es_fopenmem_init (0, "rwb", data, datalen);
if (!*r_key)
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
else
err = 0;
goto leave;
}
else if (ctype == CERTTYPE_IPGP && datalen && datalen < 1023
&& datalen >= data[0] + 1 && r_fpr && r_fprlen && r_url)
{
/* CERT type is IPGP. We made sure that the data is
plausible and that the caller requested this
information. */
*r_fprlen = data[0];
if (*r_fprlen)
{
*r_fpr = xtrymalloc (*r_fprlen);
if (!*r_fpr)
{
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
goto leave;
}
memcpy (*r_fpr, data + 1, *r_fprlen);
}
else
*r_fpr = NULL;
if (datalen > *r_fprlen + 1)
{
*r_url = xtrymalloc (datalen - (*r_fprlen + 1) + 1);
if (!*r_url)
{
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
xfree (*r_fpr);
*r_fpr = NULL;
goto leave;
}
memcpy (*r_url,
data + (*r_fprlen + 1), datalen - (*r_fprlen + 1));
(*r_url)[datalen - (*r_fprlen + 1)] = '\0';
}
else
*r_url = NULL;
err = 0;
goto leave;
}
}
leave:
adns_free (answer);
adns_finish (state);
return err;
#else /*!USE_ADNS*/
gpg_error_t err;
unsigned char *answer;
int r;
u16 count;
*r_key = NULL;
*r_fpr = NULL;
*r_fprlen = 0;
*r_url = NULL;
/* Allocate a 64k buffer which is the limit for an DNS response. */
answer = xtrymalloc (65536);
if (!answer)
return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
err = gpg_err_make (default_errsource, GPG_ERR_NOT_FOUND);
r = res_query (name, C_IN, T_CERT, answer, 65536);
/* Not too big, not too small, no errors and at least 1 answer. */
if (r >= sizeof (HEADER) && r <= 65536
&& (((HEADER *) answer)->rcode) == NOERROR
&& (count = ntohs (((HEADER *) answer)->ancount)))
{
int rc;
unsigned char *pt, *emsg;
emsg = &answer[r];
pt = &answer[sizeof (HEADER)];
/* Skip over the query */
rc = dn_skipname (pt, emsg);
if (rc == -1)
{
err = gpg_err_make (default_errsource, GPG_ERR_INV_OBJ);
goto leave;
}
pt += rc + QFIXEDSZ;
/* There are several possible response types for a CERT request.
We're interested in the PGP (a key) and IPGP (a URI) types.
Skip all others. TODO: A key is better than a URI since
we've gone through all this bother to fetch it, so favor that
if we have both PGP and IPGP? */
while (count-- > 0 && pt < emsg)
{
u16 type, class, dlen, ctype;
rc = dn_skipname (pt, emsg); /* the name we just queried for */
if (rc == -1)
{
err = gpg_err_make (default_errsource, GPG_ERR_INV_OBJ);
goto leave;
}
pt += rc;
/* Truncated message? 15 bytes takes us to the point where
we start looking at the ctype. */
if ((emsg - pt) < 15)
break;
type = *pt++ << 8;
type |= *pt++;
class = *pt++ << 8;
class |= *pt++;
/* We asked for IN and got something else !? */
if (class != C_IN)
break;
/* ttl */
pt += 4;
/* data length */
dlen = *pt++ << 8;
dlen |= *pt++;
/* We asked for CERT and got something else - might be a
CNAME, so loop around again. */
if (type != T_CERT)
{
pt += dlen;
continue;
}
/* The CERT type */
ctype = *pt++ << 8;
ctype |= *pt++;
/* Skip the CERT key tag and algo which we don't need. */
pt += 3;
dlen -= 5;
/* 15 bytes takes us to here */
if (ctype == CERTTYPE_PGP && dlen)
{
/* PGP type */
*r_key = es_fopenmem_init (0, "rwb", pt, dlen);
if (!*r_key)
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
else
err = 0;
goto leave;
}
else if (ctype == CERTTYPE_IPGP
&& dlen && dlen < 1023 && dlen >= pt[0] + 1)
{
/* IPGP type */
*r_fprlen = pt[0];
if (*r_fprlen)
{
*r_fpr = xtrymalloc (*r_fprlen);
if (!*r_fpr)
{
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
goto leave;
}
memcpy (*r_fpr, &pt[1], *r_fprlen);
}
else
*r_fpr = NULL;
if (dlen > *r_fprlen + 1)
{
*r_url = xtrymalloc (dlen - (*r_fprlen + 1) + 1);
if (!*r_fpr)
{
err = gpg_err_make (default_errsource,
gpg_err_code_from_syserror ());
xfree (*r_fpr);
*r_fpr = NULL;
goto leave;
}
memcpy (*r_url, &pt[*r_fprlen + 1], dlen - (*r_fprlen + 1));
(*r_url)[dlen - (*r_fprlen + 1)] = '\0';
}
else
*r_url = NULL;
err = 0;
goto leave;
}
/* Neither type matches, so go around to the next answer. */
pt += dlen;
}
}
leave:
xfree (answer);
return err;
#endif /*!USE_ADNS */
#else /* !USE_DNS_CERT */
(void)name;
*r_key = NULL;
*r_fpr = NULL;
*r_fprlen = 0;
*r_url = NULL;
return gpg_err_make (default_errsource, GPG_ERR_NOT_SUPPORTED);
#endif
}
| 1 |
[
"CWE-20"
] |
gnupg
|
2183683bd633818dd031b090b5530951de76f392
| 63,275,781,158,038,290,000,000,000,000,000,000,000 | 287 |
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 bool vxlan_set_mac(struct vxlan_dev *vxlan,
struct vxlan_sock *vs,
struct sk_buff *skb, __be32 vni)
{
union vxlan_addr saddr;
u32 ifindex = skb->dev->ifindex;
skb_reset_mac_header(skb);
skb->protocol = eth_type_trans(skb, vxlan->dev);
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
/* Ignore packet loops (and multicast echo) */
if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
return false;
/* Get address from the outer IP header */
if (vxlan_get_sk_family(vs) == AF_INET) {
saddr.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
saddr.sa.sa_family = AF_INET;
#if IS_ENABLED(CONFIG_IPV6)
} else {
saddr.sin6.sin6_addr = ipv6_hdr(skb)->saddr;
saddr.sa.sa_family = AF_INET6;
#endif
}
if ((vxlan->cfg.flags & VXLAN_F_LEARN) &&
vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni))
return false;
return true;
}
| 0 |
[] |
net
|
6c8991f41546c3c472503dff1ea9daaddf9331c2
| 150,132,247,940,306,020,000,000,000,000,000,000,000 | 32 |
net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup
ipv6_stub uses the ip6_dst_lookup function to allow other modules to
perform IPv6 lookups. However, this function skips the XFRM layer
entirely.
All users of ipv6_stub->ip6_dst_lookup use ip_route_output_flow (via the
ip_route_output_key and ip_route_output helpers) for their IPv4 lookups,
which calls xfrm_lookup_route(). This patch fixes this inconsistent
behavior by switching the stub to ip6_dst_lookup_flow, which also calls
xfrm_lookup_route().
This requires some changes in all the callers, as these two functions
take different arguments and have different return types.
Fixes: 5f81bd2e5d80 ("ipv6: export a stub for IPv6 symbols used by vxlan")
Reported-by: Xiumei Mu <[email protected]>
Signed-off-by: Sabrina Dubroca <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
static void *packet_lookup_frame(struct packet_sock *po,
struct packet_ring_buffer *rb,
unsigned int position,
int status)
{
unsigned int pg_vec_pos, frame_offset;
union {
struct tpacket_hdr *h1;
struct tpacket2_hdr *h2;
void *raw;
} h;
pg_vec_pos = position / rb->frames_per_block;
frame_offset = position % rb->frames_per_block;
h.raw = rb->pg_vec[pg_vec_pos] + (frame_offset * rb->frame_size);
if (status != __packet_get_status(po, h.raw))
return NULL;
return h.raw;
}
| 0 |
[
"CWE-909"
] |
linux-2.6
|
67286640f638f5ad41a946b9a3dc75327950248f
| 94,124,080,245,751,400,000,000,000,000,000,000,000 | 22 |
net: packet: fix information leak to userland
packet_getname_spkt() doesn't initialize all members of sa_data field of
sockaddr struct if strlen(dev->name) < 13. This structure is then copied
to userland. It leads to leaking of contents of kernel stack memory.
We have to fully fill sa_data with strncpy() instead of strlcpy().
The same with packet_getname(): it doesn't initialize sll_pkttype field of
sockaddr_ll. Set it to zero.
Signed-off-by: Vasiliy Kulikov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
static void openssl_lock(int mode, openssl_lock_t *lock, const char *file,
int line)
{
int err;
char const *what;
switch (mode) {
case CRYPTO_LOCK|CRYPTO_READ:
what = "read lock";
err= mysql_rwlock_rdlock(&lock->lock);
break;
case CRYPTO_LOCK|CRYPTO_WRITE:
what = "write lock";
err= mysql_rwlock_wrlock(&lock->lock);
break;
case CRYPTO_UNLOCK|CRYPTO_READ:
case CRYPTO_UNLOCK|CRYPTO_WRITE:
what = "unlock";
err= mysql_rwlock_unlock(&lock->lock);
break;
default:
/* Unknown locking mode. */
sql_print_error("Fatal: OpenSSL interface problem (mode=0x%x)", mode);
abort();
}
if (err)
{
sql_print_error("Fatal: can't %s OpenSSL lock", what);
abort();
}
}
| 0 |
[
"CWE-264"
] |
mysql-server
|
48bd8b16fe382be302c6f0b45931be5aa6f29a0e
| 16,192,924,593,679,034,000,000,000,000,000,000,000 | 31 |
Bug#24388753: PRIVILEGE ESCALATION USING MYSQLD_SAFE
[This is the 5.5/5.6 version of the bugfix].
The problem was that it was possible to write log files ending
in .ini/.cnf that later could be parsed as an options file.
This made it possible for users to specify startup options
without the permissions to do so.
This patch fixes the problem by disallowing general query log
and slow query log to be written to files ending in .ini and .cnf.
|
_gcry_mpi_ec_dup_point (mpi_point_t result, mpi_point_t point, mpi_ec_t ctx)
{
switch (ctx->model)
{
case MPI_EC_WEIERSTRASS:
dup_point_weierstrass (result, point, ctx);
break;
case MPI_EC_MONTGOMERY:
dup_point_montgomery (result, point, ctx);
break;
case MPI_EC_EDWARDS:
dup_point_edwards (result, point, ctx);
break;
}
}
| 0 |
[
"CWE-200"
] |
libgcrypt
|
88e1358962e902ff1cbec8d53ba3eee46407851a
| 137,502,033,472,893,340,000,000,000,000,000,000,000 | 15 |
ecc: Constant-time multiplication for Weierstrass curve.
* mpi/ec.c (_gcry_mpi_ec_mul_point): Use simple left-to-right binary
method for Weierstrass curve when SCALAR is secure.
|
R_API void r_bin_java_print_interfacemethodref_cp_summary(RBinJavaCPTypeObj *obj) {
if (!obj) {
eprintf ("Attempting to print an invalid RBinJavaCPTypeObj* InterfaceMethodRef.\n");
return;
}
eprintf ("InterfaceMethodRef ConstantPool Type (%d) ", obj->metas->ord);
eprintf (" Offset: 0x%08"PFMT64x"", obj->file_offset);
eprintf (" Class Index = %d\n", obj->info.cp_interface.class_idx);
eprintf (" Name and type Index = %d\n", obj->info.cp_interface.name_and_type_idx);
}
| 0 |
[
"CWE-119",
"CWE-788"
] |
radare2
|
6c4428f018d385fc80a33ecddcb37becea685dd5
| 212,517,372,745,763,800,000,000,000,000,000,000,000 | 10 |
Improve boundary checks to fix oobread segfaults ##crash
* Reported by Cen Zhang via huntr.dev
* Reproducer: bins/fuzzed/javaoob-havoc.class
|
static void free_String(String* string) {
if (string) {
free (string->szKey);
free (string->Value);
free (string);
}
}
| 0 |
[
"CWE-400",
"CWE-703"
] |
radare2
|
634b886e84a5c568d243e744becc6b3223e089cf
| 50,814,769,710,624,960,000,000,000,000,000,000,000 | 7 |
Fix DoS in PE/QNX/DYLDCACHE/PSX parsers ##crash
* Reported by lazymio
* Reproducer: AAA4AAAAAB4=
|
static void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
{
#if defined(CONFIG_UNIX)
if (ctx->ring_sock) {
struct sock *sock = ctx->ring_sock->sk;
struct sk_buff *skb;
while ((skb = skb_dequeue(&sock->sk_receive_queue)) != NULL)
kfree_skb(skb);
}
#else
int i;
for (i = 0; i < ctx->nr_user_files; i++) {
struct file *file;
file = io_file_from_index(ctx, i);
if (file)
fput(file);
}
#endif
}
| 0 |
[] |
linux
|
181e448d8709e517c9c7b523fcd209f24eb38ca7
| 19,599,256,725,824,610,000,000,000,000,000,000,000 | 22 |
io_uring: async workers should inherit the user creds
If we don't inherit the original task creds, then we can confuse users
like fuse that pass creds in the request header. See link below on
identical aio issue.
Link: https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u
Signed-off-by: Jens Axboe <[email protected]>
|
LoRaMacStatus_t LoRaMacMcChannelDelete( AddressIdentifier_t groupID )
{
if( ( MacCtx.MacState & LORAMAC_TX_RUNNING ) == LORAMAC_TX_RUNNING )
{
return LORAMAC_STATUS_BUSY;
}
if( ( groupID >= LORAMAC_MAX_MC_CTX ) ||
( MacCtx.NvmCtx->MulticastChannelList[groupID].ChannelParams.IsEnabled == false ) )
{
return LORAMAC_STATUS_MC_GROUP_UNDEFINED;
}
McChannelParams_t channel;
// Set all channel fields with 0
memset1( ( uint8_t* )&channel, 0, sizeof( McChannelParams_t ) );
MacCtx.NvmCtx->MulticastChannelList[groupID].ChannelParams = channel;
EventMacNvmCtxChanged( );
EventRegionNvmCtxChanged( );
return LORAMAC_STATUS_OK;
}
| 0 |
[
"CWE-120",
"CWE-787"
] |
LoRaMac-node
|
e3063a91daa7ad8a687223efa63079f0c24568e4
| 245,400,953,951,205,500,000,000,000,000,000,000,000 | 24 |
Added received buffer size checks.
|
compare_directories_by_count (NautilusFile *file_1, NautilusFile *file_2)
{
/* Sort order:
* Directories with unknown # of items
* Directories with "unknowable" # of items
* Directories with 0 items
* Directories with n items
*/
Knowledge count_known_1, count_known_2;
guint count_1, count_2;
count_known_1 = get_item_count (file_1, &count_1);
count_known_2 = get_item_count (file_2, &count_2);
if (count_known_1 > count_known_2) {
return -1;
}
if (count_known_1 < count_known_2) {
return +1;
}
/* count_known_1 and count_known_2 are equal now. Check if count
* details are UNKNOWABLE or UNKNOWN.
*/
if (count_known_1 == UNKNOWABLE || count_known_1 == UNKNOWN) {
return 0;
}
if (count_1 < count_2) {
return -1;
}
if (count_1 > count_2) {
return +1;
}
return 0;
}
| 0 |
[] |
nautilus
|
7632a3e13874a2c5e8988428ca913620a25df983
| 67,201,809,799,777,630,000,000,000,000,000,000,000 | 38 |
Check for trusted desktop file launchers.
2009-02-24 Alexander Larsson <[email protected]>
* libnautilus-private/nautilus-directory-async.c:
Check for trusted desktop file launchers.
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.c:
* libnautilus-private/nautilus-file.h:
Add nautilus_file_is_trusted_link.
Allow unsetting of custom display name.
* libnautilus-private/nautilus-mime-actions.c:
Display dialog when trying to launch a non-trusted desktop file.
svn path=/trunk/; revision=15003
|
int mp_invmod (mp_int * a, mp_int * b, mp_int * c)
#endif
{
return fp_invmod(a, b, c);
}
| 0 |
[
"CWE-326",
"CWE-203"
] |
wolfssl
|
1de07da61f0c8e9926dcbd68119f73230dae283f
| 104,605,090,417,145,240,000,000,000,000,000,000,000 | 5 |
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.
|
bool ldb_dn_minimise(struct ldb_dn *dn)
{
unsigned int i;
if (!ldb_dn_validate(dn)) {
return false;
}
if (dn->ext_comp_num == 0) {
return true;
}
/* free components */
for (i = 0; i < dn->comp_num; i++) {
LDB_FREE(dn->components[i].name);
LDB_FREE(dn->components[i].value.data);
LDB_FREE(dn->components[i].cf_name);
LDB_FREE(dn->components[i].cf_value.data);
}
dn->comp_num = 0;
dn->valid_case = false;
LDB_FREE(dn->casefold);
LDB_FREE(dn->linearized);
/* note that we don't free dn->components as this there are
* several places in ldb_dn.c that rely on it being non-NULL
* for an exploded DN
*/
for (i = 1; i < dn->ext_comp_num; i++) {
LDB_FREE(dn->ext_components[i].name);
LDB_FREE(dn->ext_components[i].value.data);
}
dn->ext_comp_num = 1;
dn->ext_components = talloc_realloc(dn, dn->ext_components, struct ldb_dn_ext_component, 1);
if (dn->ext_components == NULL) {
ldb_dn_mark_invalid(dn);
return false;
}
LDB_FREE(dn->ext_linearized);
return true;
}
| 0 |
[
"CWE-200"
] |
samba
|
7f51ec8c4ed9ba1f53d722e44fb6fb3cde933b72
| 21,666,045,848,969,076,000,000,000,000,000,000,000 | 45 |
CVE-2015-5330: ldb_dn: simplify and fix ldb_dn_escape_internal()
Previously we relied on NUL terminated strings and jumped back and
forth between copying escaped bytes and memcpy()ing un-escaped chunks.
This simple version is easier to reason about and works with
unterminated strings. It may also be faster as it avoids reading the
string twice (first with strcspn, then with memcpy).
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11599
Signed-off-by: Douglas Bagnall <[email protected]>
Pair-programmed-with: Andrew Bartlett <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
|
static av_cold int hevc_decode_init(AVCodecContext *avctx)
{
HEVCContext *s = avctx->priv_data;
int ret;
ff_init_cabac_states();
avctx->internal->allocate_progress = 1;
ret = hevc_init_context(avctx);
if (ret < 0)
return ret;
if (avctx->extradata_size > 0 && avctx->extradata) {
ret = hevc_decode_extradata(s);
if (ret < 0) {
hevc_decode_free(avctx);
return ret;
}
}
return 0;
}
| 0 |
[
"CWE-703"
] |
FFmpeg
|
b25e84b7399bd91605596b67d761d3464dbe8a6e
| 43,493,856,033,508,730,000,000,000,000,000,000,000 | 23 |
hevc: check that the VCL NAL types are the same for all slice segments of a frame
Fixes possible invalid memory access for mismatching skipped/non-skipped
slice segments.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Sample-Id: 00001533-google
|
struct rds_connection *rds_conn_create_outgoing(struct net *net,
const struct in6_addr *laddr,
const struct in6_addr *faddr,
struct rds_transport *trans,
u8 tos, gfp_t gfp, int dev_if)
{
return __rds_conn_create(net, laddr, faddr, trans, gfp, tos, 1, dev_if);
}
| 0 |
[
"CWE-401"
] |
linux
|
5f9562ebe710c307adc5f666bf1a2162ee7977c0
| 227,752,365,158,994,800,000,000,000,000,000,000,000 | 8 |
rds: memory leak in __rds_conn_create()
__rds_conn_create() did not release conn->c_path when loop_trans != 0 and
trans->t_prefer_loopback != 0 and is_outgoing == 0.
Fixes: aced3ce57cd3 ("RDS tcp loopback connection can hang")
Signed-off-by: Hangyu Hua <[email protected]>
Reviewed-by: Sharath Srinivasan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
c_pdf14trans_is_closing(const gs_composite_t * composite_action, gs_composite_t ** ppcte,
gx_device *dev)
{
gs_pdf14trans_t *pct0 = (gs_pdf14trans_t *)composite_action;
int op0 = pct0->params.pdf14_op;
switch (op0) {
default: return_error(gs_error_unregistered); /* Must not happen. */
case PDF14_PUSH_DEVICE:
return COMP_ENQUEUE;
case PDF14_ABORT_DEVICE:
return COMP_ENQUEUE;
case PDF14_POP_DEVICE:
if (*ppcte == NULL)
return COMP_ENQUEUE;
else {
gs_compositor_closing_state state = find_opening_op(PDF14_PUSH_DEVICE, ppcte, COMP_EXEC_IDLE);
if (state == COMP_EXEC_IDLE)
return COMP_DROP_QUEUE;
return state;
}
case PDF14_BEGIN_TRANS_GROUP:
return COMP_ENQUEUE;
case PDF14_END_TRANS_GROUP:
case PDF14_END_TRANS_TEXT_GROUP:
if (*ppcte == NULL)
return COMP_EXEC_QUEUE;
return find_opening_op(PDF14_BEGIN_TRANS_GROUP, ppcte, COMP_MARK_IDLE);
case PDF14_BEGIN_TRANS_MASK:
return COMP_ENQUEUE;
case PDF14_PUSH_TRANS_STATE:
return COMP_ENQUEUE;
case PDF14_POP_TRANS_STATE:
return COMP_ENQUEUE;
case PDF14_PUSH_SMASK_COLOR:
return COMP_ENQUEUE;
break;
case PDF14_POP_SMASK_COLOR:
return COMP_ENQUEUE;
break;
case PDF14_END_TRANS_MASK:
if (*ppcte == NULL)
return COMP_EXEC_QUEUE;
return find_opening_op(PDF14_BEGIN_TRANS_MASK, ppcte, COMP_MARK_IDLE);
case PDF14_SET_BLEND_PARAMS:
if (*ppcte == NULL)
return COMP_ENQUEUE;
/* hack : ignore csel - here it is always zero : */
return find_same_op(composite_action, PDF14_SET_BLEND_PARAMS, ppcte);
}
}
| 0 |
[] |
ghostpdl
|
c432131c3fdb2143e148e8ba88555f7f7a63b25e
| 195,812,951,446,796,800,000,000,000,000,000,000,000 | 52 |
Bug 699661: Avoid sharing pointers between pdf14 compositors
If a copdevice is triggered when the pdf14 compositor is the device, we make
a copy of the device, then throw an error because, by default we're only allowed
to copy the device prototype - then freeing it calls the finalize, which frees
several pointers shared with the parent.
Make a pdf14 specific finish_copydevice() which NULLs the relevant pointers,
before, possibly, throwing the same error as the default method.
This also highlighted a problem with reopening the X11 devices, where a custom
error handler could be replaced with itself, meaning it also called itself,
and infifite recursion resulted.
Keep a note of if the handler replacement has been done, and don't do it a
second time.
|
static gboolean vdagent_message_check_size(const VDAgentMessage *message_header)
{
uint32_t min_size = 0;
if (message_header->protocol != VD_AGENT_PROTOCOL) {
syslog(LOG_ERR, "message with wrong protocol version ignoring");
return FALSE;
}
if (!message_header->type ||
message_header->type >= G_N_ELEMENTS(vdagent_message_min_size)) {
syslog(LOG_WARNING, "unknown message type %d, ignoring",
message_header->type);
return FALSE;
}
min_size = vdagent_message_min_size[message_header->type];
if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size,
VD_AGENT_CAP_CLIPBOARD_SELECTION)) {
switch (message_header->type) {
case VD_AGENT_CLIPBOARD_GRAB:
case VD_AGENT_CLIPBOARD_REQUEST:
case VD_AGENT_CLIPBOARD:
case VD_AGENT_CLIPBOARD_RELEASE:
min_size += 4;
}
}
if (VD_AGENT_HAS_CAPABILITY(capabilities, capabilities_size,
VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)
&& message_header->type == VD_AGENT_CLIPBOARD_GRAB) {
min_size += 4;
}
switch (message_header->type) {
case VD_AGENT_MONITORS_CONFIG:
case VD_AGENT_FILE_XFER_START:
case VD_AGENT_FILE_XFER_DATA:
case VD_AGENT_CLIPBOARD:
case VD_AGENT_CLIPBOARD_GRAB:
case VD_AGENT_AUDIO_VOLUME_SYNC:
case VD_AGENT_ANNOUNCE_CAPABILITIES:
case VD_AGENT_GRAPHICS_DEVICE_INFO:
if (message_header->size < min_size) {
syslog(LOG_ERR, "read: invalid message size: %u for message type: %u",
message_header->size, message_header->type);
return FALSE;
}
break;
case VD_AGENT_MOUSE_STATE:
case VD_AGENT_FILE_XFER_STATUS:
case VD_AGENT_DISPLAY_CONFIG:
case VD_AGENT_REPLY:
case VD_AGENT_CLIPBOARD_REQUEST:
case VD_AGENT_CLIPBOARD_RELEASE:
case VD_AGENT_MAX_CLIPBOARD:
case VD_AGENT_CLIENT_DISCONNECTED:
if (message_header->size != min_size) {
syslog(LOG_ERR, "read: invalid message size: %u for message type: %u",
message_header->size, message_header->type);
return FALSE;
}
break;
default:
g_warn_if_reached();
return FALSE;
}
return TRUE;
}
| 0 |
[
"CWE-770"
] |
spice-vd_agent
|
1a8b93ca6ac0b690339ab7f0afc6fc45d198d332
| 273,472,690,783,709,100,000,000,000,000,000,000,000 | 69 |
Avoids unchecked file transfer IDs allocation and usage
Avoid agents allocating file transfers.
The "active_xfers" entries are now inserted when client start sending
files.
Also different agents cannot mess with other agent transfers as a
transfer is bound to a single agent.
This issue was reported by SUSE security team.
Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]>
|
void OSD::build_initial_pg_history(
spg_t pgid,
epoch_t created,
utime_t created_stamp,
pg_history_t *h,
PastIntervals *pi)
{
dout(10) << __func__ << " " << pgid << " created " << created << dendl;
h->epoch_created = created;
h->epoch_pool_created = created;
h->same_interval_since = created;
h->same_up_since = created;
h->same_primary_since = created;
h->last_scrub_stamp = created_stamp;
h->last_deep_scrub_stamp = created_stamp;
h->last_clean_scrub_stamp = created_stamp;
OSDMapRef lastmap = service.get_map(created);
int up_primary, acting_primary;
vector<int> up, acting;
lastmap->pg_to_up_acting_osds(
pgid.pgid, &up, &up_primary, &acting, &acting_primary);
ostringstream debug;
for (epoch_t e = created + 1; e <= osdmap->get_epoch(); ++e) {
OSDMapRef osdmap = service.get_map(e);
int new_up_primary, new_acting_primary;
vector<int> new_up, new_acting;
osdmap->pg_to_up_acting_osds(
pgid.pgid, &new_up, &new_up_primary, &new_acting, &new_acting_primary);
// this is a bit imprecise, but sufficient?
struct min_size_predicate_t : public IsPGRecoverablePredicate {
const pg_pool_t *pi;
bool operator()(const set<pg_shard_t> &have) const {
return have.size() >= pi->min_size;
}
min_size_predicate_t(const pg_pool_t *i) : pi(i) {}
} min_size_predicate(osdmap->get_pg_pool(pgid.pgid.pool()));
bool new_interval = PastIntervals::check_new_interval(
acting_primary,
new_acting_primary,
acting, new_acting,
up_primary,
new_up_primary,
up, new_up,
h->same_interval_since,
h->last_epoch_clean,
osdmap,
lastmap,
pgid.pgid,
&min_size_predicate,
pi,
&debug);
if (new_interval) {
h->same_interval_since = e;
if (up != new_up) {
h->same_up_since = e;
}
if (acting_primary != new_acting_primary) {
h->same_primary_since = e;
}
if (pgid.pgid.is_split(lastmap->get_pg_num(pgid.pgid.pool()),
osdmap->get_pg_num(pgid.pgid.pool()),
nullptr)) {
h->last_epoch_split = e;
}
up = new_up;
acting = new_acting;
up_primary = new_up_primary;
acting_primary = new_acting_primary;
}
lastmap = osdmap;
}
dout(20) << __func__ << " " << debug.str() << dendl;
dout(10) << __func__ << " " << *h << " " << *pi
<< " [" << (pi->empty() ? pair<epoch_t,epoch_t>(0,0) :
pi->get_bounds()) << ")"
<< dendl;
}
| 0 |
[
"CWE-287",
"CWE-284"
] |
ceph
|
5ead97120e07054d80623dada90a5cc764c28468
| 146,728,407,212,469,340,000,000,000,000,000,000,000 | 81 |
auth/cephx: add authorizer challenge
Allow the accepting side of a connection to reject an initial authorizer
with a random challenge. The connecting side then has to respond with an
updated authorizer proving they are able to decrypt the service's challenge
and that the new authorizer was produced for this specific connection
instance.
The accepting side requires this challenge and response unconditionally
if the client side advertises they have the feature bit. Servers wishing
to require this improved level of authentication simply have to require
the appropriate feature.
Signed-off-by: Sage Weil <[email protected]>
(cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b)
# Conflicts:
# src/auth/Auth.h
# src/auth/cephx/CephxProtocol.cc
# src/auth/cephx/CephxProtocol.h
# src/auth/none/AuthNoneProtocol.h
# src/msg/Dispatcher.h
# src/msg/async/AsyncConnection.cc
- const_iterator
- ::decode vs decode
- AsyncConnection ctor arg noise
- get_random_bytes(), not cct->random()
|
GF_Err pitm_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_PrimaryItemBox *ptr = (GF_PrimaryItemBox *)s;
if (!s) return GF_BAD_PARAM;
e = gf_isom_full_box_write(s, bs);
if (e) return e;
gf_bs_write_u16(bs, ptr->item_ID);
return GF_OK;
}
| 0 |
[
"CWE-401",
"CWE-787"
] |
gpac
|
ec64c7b8966d7e4642d12debb888be5acf18efb9
| 64,456,545,925,359,740,000,000,000,000,000,000,000 | 10 |
fixed #1786 (fuzz)
|
static struct binder_ref *binder_get_ref_olocked(struct binder_proc *proc,
u32 desc, bool need_strong_ref)
{
struct rb_node *n = proc->refs_by_desc.rb_node;
struct binder_ref *ref;
while (n) {
ref = rb_entry(n, struct binder_ref, rb_node_desc);
if (desc < ref->data.desc) {
n = n->rb_left;
} else if (desc > ref->data.desc) {
n = n->rb_right;
} else if (need_strong_ref && !ref->data.strong) {
binder_user_error("tried to use weak ref as strong ref\n");
return NULL;
} else {
return ref;
}
}
return NULL;
}
| 0 |
[
"CWE-416"
] |
linux
|
7bada55ab50697861eee6bb7d60b41e68a961a9c
| 56,516,614,822,902,200,000,000,000,000,000,000,000 | 22 |
binder: fix race that allows malicious free of live buffer
Malicious code can attempt to free buffers using the BC_FREE_BUFFER
ioctl to binder. There are protections against a user freeing a buffer
while in use by the kernel, however there was a window where
BC_FREE_BUFFER could be used to free a recently allocated buffer that
was not completely initialized. This resulted in a use-after-free
detected by KASAN with a malicious test program.
This window is closed by setting the buffer's allow_user_free attribute
to 0 when the buffer is allocated or when the user has previously freed
it instead of waiting for the caller to set it. The problem was that
when the struct buffer was recycled, allow_user_free was stale and set
to 1 allowing a free to go through.
Signed-off-by: Todd Kjos <[email protected]>
Acked-by: Arve Hjønnevåg <[email protected]>
Cc: stable <[email protected]> # 4.14
Signed-off-by: Greg Kroah-Hartman <[email protected]>
|
static int toneport_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
return line6_probe(interface, id, "Line6-TonePort",
&toneport_properties_table[id->driver_info],
toneport_init, sizeof(struct usb_line6_toneport));
}
| 0 |
[
"CWE-476"
] |
linux
|
0b074ab7fc0d575247b9cc9f93bb7e007ca38840
| 210,499,103,033,752,800,000,000,000,000,000,000,000 | 7 |
ALSA: line6: Assure canceling delayed work at disconnection
The current code performs the cancel of a delayed work at the late
stage of disconnection procedure, which may lead to the access to the
already cleared state.
This patch assures to call cancel_delayed_work_sync() at the beginning
of the disconnection procedure for avoiding that race. The delayed
work object is now assigned in the common line6 object instead of its
derivative, so that we can call cancel_delayed_work_sync().
Along with the change, the startup function is called via the new
callback instead. This will make it easier to port other LINE6
drivers to use the delayed work for startup in later patches.
Reported-by: [email protected]
Fixes: 7f84ff68be05 ("ALSA: line6: toneport: Fix broken usage of timer for delayed execution")
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
|
static char *__filterQuotedShell(const char *arg) {
r_return_val_if_fail (arg, NULL);
char *a = malloc (strlen (arg) + 1);
if (!a) {
return NULL;
}
char *b = a;
while (*arg) {
switch (*arg) {
case ' ':
case '=':
case '\r':
case '\n':
break;
default:
*b++ = *arg;
break;
}
arg++;
}
*b = 0;
return a;
}
| 1 |
[
"CWE-78"
] |
radare2
|
5411543a310a470b1257fb93273cdd6e8dfcb3af
| 148,488,630,594,518,490,000,000,000,000,000,000,000 | 23 |
More fixes for the CVE-2019-14745
|
format_id(const u_char *id)
{
static char buf[25];
snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
buf[24] = '\0';
return buf;
}
| 0 |
[
"CWE-125"
] |
tcpdump
|
12f66f69f7bf1ec1266ddbee90a7616cbf33696b
| 330,680,753,417,845,100,000,000,000,000,000,000,000 | 8 |
(for 4.9.3) CVE-2018-14470/Babel: fix an existing length check
In babel_print_v2() the non-verbose branch for an Update TLV compared
the TLV Length against 1 instead of 10 (probably a typo), put it right.
This fixes a buffer over-read discovered by Henri Salo from Nixu
Corporation.
Add a test using the capture file supplied by the reporter(s).
|
void TABLE_LIST::reset_const_table()
{
table->const_table= 0;
if (is_merged_derived())
{
SELECT_LEX *select_lex= get_unit()->first_select();
TABLE_LIST *tl;
List_iterator<TABLE_LIST> ti(select_lex->leaf_tables);
while ((tl= ti++))
tl->reset_const_table();
}
}
| 0 |
[
"CWE-416"
] |
server
|
c02ebf3510850ba78a106be9974c94c3b97d8585
| 244,426,128,903,967,970,000,000,000,000,000,000,000 | 12 |
MDEV-24176 Preparations
1. moved fix_vcol_exprs() call to open_table()
mysql_alter_table() doesn't do lock_tables() so it cannot win from
fix_vcol_exprs() from there. Tests affected: main.default_session
2. Vanilla cleanups and comments.
|
static int mark_chain_precision(struct bpf_verifier_env *env, int regno)
{
return __mark_chain_precision(env, regno, -1);
}
| 0 |
[
"CWE-119",
"CWE-681",
"CWE-787"
] |
linux
|
5b9fbeb75b6a98955f628e205ac26689bcb1383e
| 237,605,576,940,561,700,000,000,000,000,000,000,000 | 4 |
bpf: Fix scalar32_min_max_or bounds tracking
Simon reported an issue with the current scalar32_min_max_or() implementation.
That is, compared to the other 32 bit subreg tracking functions, the code in
scalar32_min_max_or() stands out that it's using the 64 bit registers instead
of 32 bit ones. This leads to bounds tracking issues, for example:
[...]
8: R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R10=fp0 fp-8=mmmmmmmm
8: (79) r1 = *(u64 *)(r0 +0)
R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R10=fp0 fp-8=mmmmmmmm
9: R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R1_w=inv(id=0) R10=fp0 fp-8=mmmmmmmm
9: (b7) r0 = 1
10: R0_w=inv1 R1_w=inv(id=0) R10=fp0 fp-8=mmmmmmmm
10: (18) r2 = 0x600000002
12: R0_w=inv1 R1_w=inv(id=0) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
12: (ad) if r1 < r2 goto pc+1
R0_w=inv1 R1_w=inv(id=0,umin_value=25769803778) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
13: R0_w=inv1 R1_w=inv(id=0,umin_value=25769803778) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
13: (95) exit
14: R0_w=inv1 R1_w=inv(id=0,umax_value=25769803777,var_off=(0x0; 0x7ffffffff)) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
14: (25) if r1 > 0x0 goto pc+1
R0_w=inv1 R1_w=inv(id=0,umax_value=0,var_off=(0x0; 0x7fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
15: R0_w=inv1 R1_w=inv(id=0,umax_value=0,var_off=(0x0; 0x7fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
15: (95) exit
16: R0_w=inv1 R1_w=inv(id=0,umin_value=1,umax_value=25769803777,var_off=(0x0; 0x77fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
16: (47) r1 |= 0
17: R0_w=inv1 R1_w=inv(id=0,umin_value=1,umax_value=32212254719,var_off=(0x1; 0x700000000),s32_max_value=1,u32_max_value=1) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
[...]
The bound tests on the map value force the upper unsigned bound to be 25769803777
in 64 bit (0b11000000000000000000000000000000001) and then lower one to be 1. By
using OR they are truncated and thus result in the range [1,1] for the 32 bit reg
tracker. This is incorrect given the only thing we know is that the value must be
positive and thus 2147483647 (0b1111111111111111111111111111111) at max for the
subregs. Fix it by using the {u,s}32_{min,max}_value vars instead. This also makes
sense, for example, for the case where we update dst_reg->s32_{min,max}_value in
the else branch we need to use the newly computed dst_reg->u32_{min,max}_value as
we know that these are positive. Previously, in the else branch the 64 bit values
of umin_value=1 and umax_value=32212254719 were used and latter got truncated to
be 1 as upper bound there. After the fix the subreg range is now correct:
[...]
8: R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R10=fp0 fp-8=mmmmmmmm
8: (79) r1 = *(u64 *)(r0 +0)
R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R10=fp0 fp-8=mmmmmmmm
9: R0=map_value(id=0,off=0,ks=4,vs=48,imm=0) R1_w=inv(id=0) R10=fp0 fp-8=mmmmmmmm
9: (b7) r0 = 1
10: R0_w=inv1 R1_w=inv(id=0) R10=fp0 fp-8=mmmmmmmm
10: (18) r2 = 0x600000002
12: R0_w=inv1 R1_w=inv(id=0) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
12: (ad) if r1 < r2 goto pc+1
R0_w=inv1 R1_w=inv(id=0,umin_value=25769803778) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
13: R0_w=inv1 R1_w=inv(id=0,umin_value=25769803778) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
13: (95) exit
14: R0_w=inv1 R1_w=inv(id=0,umax_value=25769803777,var_off=(0x0; 0x7ffffffff)) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
14: (25) if r1 > 0x0 goto pc+1
R0_w=inv1 R1_w=inv(id=0,umax_value=0,var_off=(0x0; 0x7fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
15: R0_w=inv1 R1_w=inv(id=0,umax_value=0,var_off=(0x0; 0x7fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
15: (95) exit
16: R0_w=inv1 R1_w=inv(id=0,umin_value=1,umax_value=25769803777,var_off=(0x0; 0x77fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
16: (47) r1 |= 0
17: R0_w=inv1 R1_w=inv(id=0,umin_value=1,umax_value=32212254719,var_off=(0x0; 0x77fffffff),u32_max_value=2147483647) R2_w=inv25769803778 R10=fp0 fp-8=mmmmmmmm
[...]
Fixes: 3f50f132d840 ("bpf: Verifier, do explicit ALU32 bounds tracking")
Reported-by: Simon Scannell <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: John Fastabend <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
|
**/
CImg<T>& load(const char *const filename) {
if (!filename)
throw CImgArgumentException(_cimg_instance
"load(): Specified filename is (null).",
cimg_instance);
if (!cimg::strncasecmp(filename,"http://",7) || !cimg::strncasecmp(filename,"https://",8)) {
CImg<charT> filename_local(256);
load(cimg::load_network(filename,filename_local));
std::remove(filename_local);
return *this;
}
const char *const ext = cimg::split_filename(filename);
const unsigned int omode = cimg::exception_mode();
cimg::exception_mode(0);
bool is_loaded = true;
try {
#ifdef cimg_load_plugin
cimg_load_plugin(filename);
#endif
#ifdef cimg_load_plugin1
cimg_load_plugin1(filename);
#endif
#ifdef cimg_load_plugin2
cimg_load_plugin2(filename);
#endif
#ifdef cimg_load_plugin3
cimg_load_plugin3(filename);
#endif
#ifdef cimg_load_plugin4
cimg_load_plugin4(filename);
#endif
#ifdef cimg_load_plugin5
cimg_load_plugin5(filename);
#endif
#ifdef cimg_load_plugin6
cimg_load_plugin6(filename);
#endif
#ifdef cimg_load_plugin7
cimg_load_plugin7(filename);
#endif
#ifdef cimg_load_plugin8
cimg_load_plugin8(filename);
#endif
// Ascii formats
if (!cimg::strcasecmp(ext,"asc")) load_ascii(filename);
else if (!cimg::strcasecmp(ext,"dlm") ||
!cimg::strcasecmp(ext,"txt")) load_dlm(filename);
// 2D binary formats
else if (!cimg::strcasecmp(ext,"bmp")) load_bmp(filename);
else if (!cimg::strcasecmp(ext,"jpg") ||
!cimg::strcasecmp(ext,"jpeg") ||
!cimg::strcasecmp(ext,"jpe") ||
!cimg::strcasecmp(ext,"jfif") ||
!cimg::strcasecmp(ext,"jif")) load_jpeg(filename);
else if (!cimg::strcasecmp(ext,"png")) load_png(filename);
else if (!cimg::strcasecmp(ext,"ppm") ||
!cimg::strcasecmp(ext,"pgm") ||
!cimg::strcasecmp(ext,"pnm") ||
!cimg::strcasecmp(ext,"pbm") ||
!cimg::strcasecmp(ext,"pnk")) load_pnm(filename);
else if (!cimg::strcasecmp(ext,"pfm")) load_pfm(filename);
else if (!cimg::strcasecmp(ext,"tif") ||
!cimg::strcasecmp(ext,"tiff")) load_tiff(filename);
else if (!cimg::strcasecmp(ext,"exr")) load_exr(filename);
else if (!cimg::strcasecmp(ext,"cr2") ||
!cimg::strcasecmp(ext,"crw") ||
!cimg::strcasecmp(ext,"dcr") ||
!cimg::strcasecmp(ext,"mrw") ||
!cimg::strcasecmp(ext,"nef") ||
!cimg::strcasecmp(ext,"orf") ||
!cimg::strcasecmp(ext,"pix") ||
!cimg::strcasecmp(ext,"ptx") ||
!cimg::strcasecmp(ext,"raf") ||
!cimg::strcasecmp(ext,"srf")) load_dcraw_external(filename);
else if (!cimg::strcasecmp(ext,"gif")) load_gif_external(filename);
// 3D binary formats
else if (!cimg::strcasecmp(ext,"dcm") ||
!cimg::strcasecmp(ext,"dicom")) load_medcon_external(filename);
else if (!cimg::strcasecmp(ext,"hdr") ||
!cimg::strcasecmp(ext,"nii")) load_analyze(filename);
else if (!cimg::strcasecmp(ext,"par") ||
!cimg::strcasecmp(ext,"rec")) load_parrec(filename);
else if (!cimg::strcasecmp(ext,"mnc")) load_minc2(filename);
else if (!cimg::strcasecmp(ext,"inr")) load_inr(filename);
else if (!cimg::strcasecmp(ext,"pan")) load_pandore(filename);
else if (!cimg::strcasecmp(ext,"cimg") ||
!cimg::strcasecmp(ext,"cimgz") ||
!*ext) return load_cimg(filename);
// Archive files
else if (!cimg::strcasecmp(ext,"gz")) load_gzip_external(filename);
// Image sequences
else if (!cimg::strcasecmp(ext,"avi") ||
!cimg::strcasecmp(ext,"mov") ||
!cimg::strcasecmp(ext,"asf") ||
!cimg::strcasecmp(ext,"divx") ||
!cimg::strcasecmp(ext,"flv") ||
!cimg::strcasecmp(ext,"mpg") ||
!cimg::strcasecmp(ext,"m1v") ||
!cimg::strcasecmp(ext,"m2v") ||
!cimg::strcasecmp(ext,"m4v") ||
!cimg::strcasecmp(ext,"mjp") ||
!cimg::strcasecmp(ext,"mp4") ||
!cimg::strcasecmp(ext,"mkv") ||
!cimg::strcasecmp(ext,"mpe") ||
!cimg::strcasecmp(ext,"movie") ||
!cimg::strcasecmp(ext,"ogm") ||
!cimg::strcasecmp(ext,"ogg") ||
!cimg::strcasecmp(ext,"ogv") ||
!cimg::strcasecmp(ext,"qt") ||
!cimg::strcasecmp(ext,"rm") ||
!cimg::strcasecmp(ext,"vob") ||
!cimg::strcasecmp(ext,"wmv") ||
!cimg::strcasecmp(ext,"xvid") ||
!cimg::strcasecmp(ext,"mpeg")) load_video(filename);
else is_loaded = false;
} catch (CImgIOException&) { is_loaded = false; }
// If nothing loaded, try to guess file format from magic number in file.
if (!is_loaded) {
std::FILE *file = cimg::std_fopen(filename,"rb");
if (!file) {
cimg::exception_mode(omode);
throw CImgIOException(_cimg_instance
"load(): Failed to open file '%s'.",
cimg_instance,
filename);
}
const char *const f_type = cimg::ftype(file,filename);
cimg::fclose(file);
is_loaded = true;
try {
if (!cimg::strcasecmp(f_type,"pnm")) load_pnm(filename);
else if (!cimg::strcasecmp(f_type,"pfm")) load_pfm(filename);
else if (!cimg::strcasecmp(f_type,"bmp")) load_bmp(filename);
else if (!cimg::strcasecmp(f_type,"inr")) load_inr(filename);
else if (!cimg::strcasecmp(f_type,"jpg")) load_jpeg(filename);
else if (!cimg::strcasecmp(f_type,"pan")) load_pandore(filename);
else if (!cimg::strcasecmp(f_type,"png")) load_png(filename);
else if (!cimg::strcasecmp(f_type,"tif")) load_tiff(filename);
else if (!cimg::strcasecmp(f_type,"gif")) load_gif_external(filename);
else if (!cimg::strcasecmp(f_type,"dcm")) load_medcon_external(filename);
else is_loaded = false;
} catch (CImgIOException&) { is_loaded = false; }
}
// If nothing loaded, try to load file with other means.
if (!is_loaded) {
try {
load_other(filename);
} catch (CImgIOException&) {
cimg::exception_mode(omode);
throw CImgIOException(_cimg_instance
"load(): Failed to recognize format of file '%s'.",
cimg_instance,
filename);
}
}
cimg::exception_mode(omode);
return *this;
| 0 |
[
"CWE-119",
"CWE-787"
] |
CImg
|
ac8003393569aba51048c9d67e1491559877b1d1
| 338,725,264,108,635,340,000,000,000,000,000,000,000 | 167 |
.
|
get_xdg_user_dir_from_string (const char *filesystem,
const char **config_key,
const char **suffix,
const char **dir)
{
char *slash;
const char *rest;
g_autofree char *prefix;
gsize len;
slash = strchr (filesystem, '/');
if (slash)
len = slash - filesystem;
else
len = strlen (filesystem);
rest = filesystem + len;
while (*rest == '/')
rest++;
if (suffix)
*suffix = rest;
prefix = g_strndup (filesystem, len);
if (strcmp (prefix, "xdg-desktop") == 0)
{
if (config_key)
*config_key = "XDG_DESKTOP_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
return TRUE;
}
if (strcmp (prefix, "xdg-documents") == 0)
{
if (config_key)
*config_key = "XDG_DOCUMENTS_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
return TRUE;
}
if (strcmp (prefix, "xdg-download") == 0)
{
if (config_key)
*config_key = "XDG_DOWNLOAD_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
return TRUE;
}
if (strcmp (prefix, "xdg-music") == 0)
{
if (config_key)
*config_key = "XDG_MUSIC_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
return TRUE;
}
if (strcmp (prefix, "xdg-pictures") == 0)
{
if (config_key)
*config_key = "XDG_PICTURES_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
return TRUE;
}
if (strcmp (prefix, "xdg-public-share") == 0)
{
if (config_key)
*config_key = "XDG_PUBLICSHARE_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE);
return TRUE;
}
if (strcmp (prefix, "xdg-templates") == 0)
{
if (config_key)
*config_key = "XDG_TEMPLATES_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
return TRUE;
}
if (strcmp (prefix, "xdg-videos") == 0)
{
if (config_key)
*config_key = "XDG_VIDEOS_DIR";
if (dir)
*dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
return TRUE;
}
if (get_xdg_dir_from_prefix (prefix, NULL, dir))
{
if (config_key)
*config_key = NULL;
return TRUE;
}
/* Don't support xdg-run without suffix, because that doesn't work */
if (strcmp (prefix, "xdg-run") == 0 &&
*rest != 0)
{
if (config_key)
*config_key = NULL;
if (dir)
*dir = g_get_user_runtime_dir ();
return TRUE;
}
return FALSE;
}
| 0 |
[
"CWE-20"
] |
flatpak
|
902fb713990a8f968ea4350c7c2a27ff46f1a6c4
| 193,526,707,782,398,100,000,000,000,000,000,000,000 | 109 |
Use seccomp to filter out TIOCSTI ioctl
This would otherwise let the sandbox add input to the controlling tty.
|
virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src,
virDomainMemballoonDefPtr dst)
{
if (src->model != dst->model) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target balloon model %s does not match source %s"),
virDomainMemballoonModelTypeToString(dst->model),
virDomainMemballoonModelTypeToString(src->model));
return false;
}
if (src->autodeflate != dst->autodeflate) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target balloon autodeflate attribute value "
"'%s' does not match source '%s'"),
virTristateSwitchTypeToString(dst->autodeflate),
virTristateSwitchTypeToString(src->autodeflate));
return false;
}
if (src->virtio && dst->virtio &&
!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
return false;
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
return false;
return true;
}
| 0 |
[
"CWE-212"
] |
libvirt
|
a5b064bf4b17a9884d7d361733737fb614ad8979
| 276,379,301,995,335,000,000,000,000,000,000,000,000 | 29 |
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used
Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410
(v6.1.0-122-g3b076391be) we support http cookies. Since they may contain
somewhat sensitive information we should not format them into the XML
unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted.
Reported-by: Han Han <[email protected]>
Signed-off-by: Peter Krempa <[email protected]>
Reviewed-by: Erik Skultety <[email protected]>
|
int dm_suspended_internally_md(struct mapped_device *md)
{
return test_bit(DMF_SUSPENDED_INTERNALLY, &md->flags);
}
| 0 |
[
"CWE-362"
] |
linux
|
b9a41d21dceadf8104812626ef85dc56ee8a60ed
| 171,077,830,366,280,000,000,000,000,000,000,000,000 | 4 |
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 tls1_set_ec_id(unsigned char *curve_id, unsigned char *comp_id,
EC_KEY *ec)
{
int id;
const EC_GROUP *grp;
if (!ec)
return 0;
/* Determine if it is a prime field */
grp = EC_KEY_get0_group(ec);
if (!grp)
return 0;
/* Determine curve ID */
id = EC_GROUP_get_curve_name(grp);
id = tls1_ec_nid2curve_id(id);
/* If no id return error: we don't support arbitrary explicit curves */
if (id == 0)
return 0;
curve_id[0] = 0;
curve_id[1] = (unsigned char)id;
if (comp_id) {
if (EC_KEY_get0_public_key(ec) == NULL)
return 0;
if (EC_KEY_get_conv_form(ec) == POINT_CONVERSION_UNCOMPRESSED) {
*comp_id = TLSEXT_ECPOINTFORMAT_uncompressed;
} else {
if ((nid_list[id - 1].flags & TLS_CURVE_TYPE) == TLS_CURVE_PRIME)
*comp_id = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime;
else
*comp_id = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2;
}
}
return 1;
}
| 0 |
[
"CWE-20"
] |
openssl
|
4ad93618d26a3ea23d36ad5498ff4f59eff3a4d2
| 306,482,414,041,367,250,000,000,000,000,000,000,000 | 33 |
Don't change the state of the ETM flags until CCS processing
Changing the ciphersuite during a renegotiation can result in a crash
leading to a DoS attack. ETM has not been implemented in 1.1.0 for DTLS
so this is TLS only.
The problem is caused by changing the flag indicating whether to use ETM
or not immediately on negotiation of ETM, rather than at CCS. Therefore,
during a renegotiation, if the ETM state is changing (usually due to a
change of ciphersuite), then an error/crash will occur.
Due to the fact that there are separate CCS messages for read and write
we actually now need two flags to determine whether to use ETM or not.
CVE-2017-3733
Reviewed-by: Richard Levitte <[email protected]>
|
TEST_P(StatsIntegrationTest, WithTagSpecifierWithRegex) {
config_helper_.addConfigModifier([&](envoy::config::bootstrap::v3::Bootstrap& bootstrap) -> void {
bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(false);
auto tag_specifier = bootstrap.mutable_stats_config()->mutable_stats_tags()->Add();
tag_specifier->set_tag_name("my.http_conn_manager_prefix");
tag_specifier->set_regex(R"(^(?:|listener(?=\.).*?\.)http\.((.*?)\.))");
});
initialize();
auto counter = test_server_->counter("http.config_test.rq_total");
EXPECT_EQ(counter->tags().size(), 1);
EXPECT_EQ(counter->tags()[0].name_, "my.http_conn_manager_prefix");
EXPECT_EQ(counter->tags()[0].value_, "config_test");
}
| 0 |
[
"CWE-400"
] |
envoy
|
dfddb529e914d794ac552e906b13d71233609bf7
| 112,988,130,756,154,070,000,000,000,000,000,000,000 | 14 |
listener: Add configurable accepted connection limits (#153)
Add support for per-listener limits on accepted connections.
Signed-off-by: Tony Allen <[email protected]>
|
static void vhost_net_busy_poll_try_queue(struct vhost_net *net,
struct vhost_virtqueue *vq)
{
if (!vhost_vq_avail_empty(&net->dev, vq)) {
vhost_poll_queue(&vq->poll);
} else if (unlikely(vhost_enable_notify(&net->dev, vq))) {
vhost_disable_notify(&net->dev, vq);
vhost_poll_queue(&vq->poll);
}
}
| 0 |
[
"CWE-787"
] |
linux
|
42d84c8490f9f0931786f1623191fcab397c3d64
| 262,922,705,719,945,000,000,000,000,000,000,000,000 | 10 |
vhost: Check docket sk_family instead of call getname
Doing so, we save one call to get data we already have in the struct.
Also, since there is no guarantee that getname use sockaddr_ll
parameter beyond its size, we add a little bit of security here.
It should do not do beyond MAX_ADDR_LEN, but syzbot found that
ax25_getname writes more (72 bytes, the size of full_sockaddr_ax25,
versus 20 + 32 bytes of sockaddr_ll + MAX_ADDR_LEN in syzbot repro).
Fixes: 3a4d5c94e9593 ("vhost_net: a kernel-level virtio server")
Reported-by: [email protected]
Signed-off-by: Eugenio Pérez <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
String *val_str(String *str)
{ return val_string_from_date(str); }
| 0 |
[
"CWE-617"
] |
server
|
2e7891080667c59ac80f788eef4d59d447595772
| 44,344,413,511,107,650,000,000,000,000,000,000,000 | 2 |
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]>
|
extra_get_record(struct isoent *isoent, int *space, int *off, int *loc)
{
struct extr_rec *rec;
isoent = isoent->parent;
if (off != NULL) {
/* Storing data into an extra record. */
rec = isoent->extr_rec_list.current;
if (DR_SAFETY > LOGICAL_BLOCK_SIZE - rec->offset)
rec = rec->next;
} else {
/* Calculating the size of an extra record. */
rec = extra_last_record(isoent);
if (rec == NULL ||
DR_SAFETY > LOGICAL_BLOCK_SIZE - rec->offset) {
rec = malloc(sizeof(*rec));
if (rec == NULL)
return (NULL);
rec->location = 0;
rec->offset = 0;
/* Insert `rec` into the tail of isoent->extr_rec_list */
rec->next = NULL;
/*
* Note: testing isoent->extr_rec_list.last == NULL
* here is really unneeded since it has been already
* initialized at isoent_new function but Clang Static
* Analyzer claims that it is dereference of null
* pointer.
*/
if (isoent->extr_rec_list.last == NULL)
isoent->extr_rec_list.last =
&(isoent->extr_rec_list.first);
*isoent->extr_rec_list.last = rec;
isoent->extr_rec_list.last = &(rec->next);
}
}
*space = LOGICAL_BLOCK_SIZE - rec->offset - DR_SAFETY;
if (*space & 0x01)
*space -= 1;/* Keep padding space. */
if (off != NULL)
*off = rec->offset;
if (loc != NULL)
*loc = rec->location;
isoent->extr_rec_list.current = rec;
return (&rec->buf[rec->offset]);
}
| 0 |
[
"CWE-190"
] |
libarchive
|
3014e19820ea53c15c90f9d447ca3e668a0b76c6
| 274,463,820,916,467,330,000,000,000,000,000,000,000 | 47 |
Issue 711: Be more careful about verifying filename lengths when writing ISO9660 archives
* Don't cast size_t to int, since this can lead to overflow
on machines where sizeof(int) < sizeof(size_t)
* Check a + b > limit by writing it as
a > limit || b > limit || a + b > limit
to avoid problems when a + b wraps around.
|
int __must_check __sta_info_destroy(struct sta_info *sta)
{
int err = __sta_info_destroy_part1(sta);
if (err)
return err;
synchronize_net();
__sta_info_destroy_part2(sta);
return 0;
}
| 0 |
[
"CWE-287"
] |
linux
|
3e493173b7841259a08c5c8e5cbe90adb349da7e
| 244,065,985,592,046,140,000,000,000,000,000,000,000 | 13 |
mac80211: Do not send Layer 2 Update frame before authorization
The Layer 2 Update frame is used to update bridges when a station roams
to another AP even if that STA does not transmit any frames after the
reassociation. This behavior was described in IEEE Std 802.11F-2003 as
something that would happen based on MLME-ASSOCIATE.indication, i.e.,
before completing 4-way handshake. However, this IEEE trial-use
recommended practice document was published before RSN (IEEE Std
802.11i-2004) and as such, did not consider RSN use cases. Furthermore,
IEEE Std 802.11F-2003 was withdrawn in 2006 and as such, has not been
maintained amd should not be used anymore.
Sending out the Layer 2 Update frame immediately after association is
fine for open networks (and also when using SAE, FT protocol, or FILS
authentication when the station is actually authenticated by the time
association completes). However, it is not appropriate for cases where
RSN is used with PSK or EAP authentication since the station is actually
fully authenticated only once the 4-way handshake completes after
authentication and attackers might be able to use the unauthenticated
triggering of Layer 2 Update frame transmission to disrupt bridge
behavior.
Fix this by postponing transmission of the Layer 2 Update frame from
station entry addition to the point when the station entry is marked
authorized. Similarly, send out the VLAN binding update only if the STA
entry has already been authorized.
Signed-off-by: Jouni Malinen <[email protected]>
Reviewed-by: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
flush_signal_handlers(struct task_struct *t, int force_default)
{
int i;
struct k_sigaction *ka = &t->sighand->action[0];
for (i = _NSIG ; i != 0 ; i--) {
if (force_default || ka->sa.sa_handler != SIG_IGN)
ka->sa.sa_handler = SIG_DFL;
ka->sa.sa_flags = 0;
#ifdef SA_RESTORER
ka->sa.sa_restorer = NULL;
#endif
sigemptyset(&ka->sa.sa_mask);
ka++;
}
}
| 0 |
[
"CWE-284",
"CWE-264"
] |
linux
|
2ca39528c01a933f6689cd6505ce65bd6d68a530
| 256,997,889,851,614,440,000,000,000,000,000,000,000 | 15 |
signal: always clear sa_restorer on execve
When the new signal handlers are set up, the location of sa_restorer is
not cleared, leaking a parent process's address space location to
children. This allows for a potential bypass of the parent's ASLR by
examining the sa_restorer value returned when calling sigaction().
Based on what should be considered "secret" about addresses, it only
matters across the exec not the fork (since the VMAs haven't changed
until the exec). But since exec sets SIG_DFL and keeps sa_restorer,
this is where it should be fixed.
Given the few uses of sa_restorer, a "set" function was not written
since this would be the only use. Instead, we use
__ARCH_HAS_SA_RESTORER, as already done in other places.
Example of the leak before applying this patch:
$ cat /proc/$$/maps
...
7fb9f3083000-7fb9f3238000 r-xp 00000000 fd:01 404469 .../libc-2.15.so
...
$ ./leak
...
7f278bc74000-7f278be29000 r-xp 00000000 fd:01 404469 .../libc-2.15.so
...
1 0 (nil) 0x7fb9f30b94a0
2 4000000 (nil) 0x7f278bcaa4a0
3 4000000 (nil) 0x7f278bcaa4a0
4 0 (nil) 0x7fb9f30b94a0
...
[[email protected]: use SA_RESTORER for backportability]
Signed-off-by: Kees Cook <[email protected]>
Reported-by: Emese Revfy <[email protected]>
Cc: Emese Revfy <[email protected]>
Cc: PaX Team <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Serge Hallyn <[email protected]>
Cc: Julien Tinnes <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
void HtmlOutputDev::drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, int /*nBytes*/, Unicode *u, int uLen)
{
if ( !showHidden && (state->getRender() & 3) == 3) {
return;
}
pages->addChar(state, x, y, dx, dy, originX, originY, u, uLen);
}
| 0 |
[
"CWE-824"
] |
poppler
|
30c731b487190c02afff3f036736a392eb60cd9a
| 43,971,818,566,522,960,000,000,000,000,000,000,000 | 10 |
Properly initialize HtmlOutputDev::page to avoid SIGSEGV upon error exit.
Closes #742
|
static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
void __user *argp)
{
struct btrfs_trans_handle *trans;
u64 transid;
int ret;
trans = btrfs_attach_transaction_barrier(root);
if (IS_ERR(trans)) {
if (PTR_ERR(trans) != -ENOENT)
return PTR_ERR(trans);
/* No running transaction, don't bother */
transid = root->fs_info->last_trans_committed;
goto out;
}
transid = trans->transid;
ret = btrfs_commit_transaction_async(trans, 0);
if (ret) {
btrfs_end_transaction(trans);
return ret;
}
out:
if (argp)
if (copy_to_user(argp, &transid, sizeof(transid)))
return -EFAULT;
return 0;
}
| 0 |
[
"CWE-476",
"CWE-284"
] |
linux
|
09ba3bc9dd150457c506e4661380a6183af651c1
| 55,503,320,196,339,280,000,000,000,000,000,000,000 | 28 |
btrfs: merge btrfs_find_device and find_device
Both btrfs_find_device() and find_device() does the same thing except
that the latter does not take the seed device onto account in the device
scanning context. We can merge them.
Signed-off-by: Anand Jain <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
|
int decode_private_key_info(const gnutls_datum_t * der,
gnutls_x509_privkey_t pkey, ASN1_TYPE * out)
{
int result, len;
opaque oid[64], *data = NULL;
gnutls_datum_t tmp;
ASN1_TYPE pkcs8_asn = ASN1_TYPE_EMPTY;
ASN1_TYPE ret_asn;
int data_size;
if ((result =
asn1_create_element(_gnutls_get_pkix(),
"PKIX1.pkcs-8-PrivateKeyInfo",
&pkcs8_asn)) != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto error;
}
result = asn1_der_decoding(&pkcs8_asn, der->data, der->size, NULL);
if (result != ASN1_SUCCESS) {
gnutls_assert();
goto error;
}
/* Check the private key algorithm OID
*/
len = sizeof(oid);
result =
asn1_read_value(pkcs8_asn, "privateKeyAlgorithm.algorithm",
oid, &len);
if (result != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto error;
}
/* we only support RSA private keys.
*/
if (strcmp(oid, PKIX1_RSA_OID) != 0) {
gnutls_assert();
_gnutls_x509_log
("PKCS #8 private key OID '%s' is unsupported.\n", oid);
result = GNUTLS_E_UNKNOWN_PK_ALGORITHM;
goto error;
}
/* Get the DER encoding of the actual private key.
*/
data_size = 0;
result = asn1_read_value(pkcs8_asn, "privateKey", NULL, &data_size);
if (result != ASN1_MEM_ERROR) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto error;
}
data = gnutls_alloca(data_size);
if (data == NULL) {
gnutls_assert();
result = GNUTLS_E_MEMORY_ERROR;
goto error;
}
result = asn1_read_value(pkcs8_asn, "privateKey", data, &data_size);
if (result != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto error;
}
asn1_delete_structure(&pkcs8_asn);
tmp.data = data;
tmp.size = data_size;
pkey->pk_algorithm = GNUTLS_PK_RSA;
ret_asn = _gnutls_privkey_decode_pkcs1_rsa_key(&tmp, pkey);
if (ret_asn == NULL) {
gnutls_assert();
}
*out = ret_asn;
return 0;
error:
asn1_delete_structure(&pkcs8_asn);
if (data != NULL) {
gnutls_afree(data);
}
return result;
}
| 0 |
[] |
gnutls
|
112d537da5f3500f14316db26d18c37d678a5e0e
| 242,174,163,965,160,520,000,000,000,000,000,000,000 | 96 |
some changes for 64bit machines.
|
static bool tcf_proto_cmp(const struct tcf_proto *tp1,
const struct tcf_proto *tp2)
{
return tp1->chain->index == tp2->chain->index &&
tp1->prio == tp2->prio &&
tp1->protocol == tp2->protocol;
}
| 0 |
[
"CWE-416"
] |
linux
|
04c2a47ffb13c29778e2a14e414ad4cb5a5db4b5
| 12,215,408,390,842,290,000,000,000,000,000,000,000 | 7 |
net: sched: fix use-after-free in tc_new_tfilter()
Whenever tc_new_tfilter() jumps back to replay: label,
we need to make sure @q and @chain local variables are cleared again,
or risk use-after-free as in [1]
For consistency, apply the same fix in tc_ctl_chain()
BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581
Write of size 8 at addr ffff8880985c4b08 by task syz-executor.4/1945
CPU: 0 PID: 1945 Comm: syz-executor.4 Not tainted 5.17.0-rc1-syzkaller-00495-gff58831fa02d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255
__kasan_report mm/kasan/report.c:442 [inline]
kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581
tcf_chain_head_change_item net/sched/cls_api.c:372 [inline]
tcf_chain0_head_change.isra.0+0xb9/0x120 net/sched/cls_api.c:386
tcf_chain_tp_insert net/sched/cls_api.c:1657 [inline]
tcf_chain_tp_insert_unique net/sched/cls_api.c:1707 [inline]
tc_new_tfilter+0x1e67/0x2350 net/sched/cls_api.c:2086
rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec net/socket.c:705 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:725
____sys_sendmsg+0x331/0x810 net/socket.c:2413
___sys_sendmsg+0xf3/0x170 net/socket.c:2467
__sys_sendmmsg+0x195/0x470 net/socket.c:2553
__do_sys_sendmmsg net/socket.c:2582 [inline]
__se_sys_sendmmsg net/socket.c:2579 [inline]
__x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f2647172059
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2645aa5168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00007f2647285100 RCX: 00007f2647172059
RDX: 040000000000009f RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 00007f26471cc08d R08: 0000000000000000 R09: 0000000000000000
R10: 9e00000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fffb3f7f02f R14: 00007f2645aa5300 R15: 0000000000022000
</TASK>
Allocated by task 1944:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:436 [inline]
____kasan_kmalloc mm/kasan/common.c:515 [inline]
____kasan_kmalloc mm/kasan/common.c:474 [inline]
__kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
kmalloc_node include/linux/slab.h:604 [inline]
kzalloc_node include/linux/slab.h:726 [inline]
qdisc_alloc+0xac/0xa10 net/sched/sch_generic.c:941
qdisc_create.constprop.0+0xce/0x10f0 net/sched/sch_api.c:1211
tc_modify_qdisc+0x4c5/0x1980 net/sched/sch_api.c:1660
rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5592
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec net/socket.c:705 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:725
____sys_sendmsg+0x331/0x810 net/socket.c:2413
___sys_sendmsg+0xf3/0x170 net/socket.c:2467
__sys_sendmmsg+0x195/0x470 net/socket.c:2553
__do_sys_sendmmsg net/socket.c:2582 [inline]
__se_sys_sendmmsg net/socket.c:2579 [inline]
__x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 3609:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track+0x21/0x30 mm/kasan/common.c:45
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
____kasan_slab_free mm/kasan/common.c:366 [inline]
____kasan_slab_free+0x130/0x160 mm/kasan/common.c:328
kasan_slab_free include/linux/kasan.h:236 [inline]
slab_free_hook mm/slub.c:1728 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
slab_free mm/slub.c:3509 [inline]
kfree+0xcb/0x280 mm/slub.c:4562
rcu_do_batch kernel/rcu/tree.c:2527 [inline]
rcu_core+0x7b8/0x1540 kernel/rcu/tree.c:2778
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
Last potentially related work creation:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
__kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
__call_rcu kernel/rcu/tree.c:3026 [inline]
call_rcu+0xb1/0x740 kernel/rcu/tree.c:3106
qdisc_put_unlocked+0x6f/0x90 net/sched/sch_generic.c:1109
tcf_block_release+0x86/0x90 net/sched/cls_api.c:1238
tc_new_tfilter+0xc0d/0x2350 net/sched/cls_api.c:2148
rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343
netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec net/socket.c:705 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:725
____sys_sendmsg+0x331/0x810 net/socket.c:2413
___sys_sendmsg+0xf3/0x170 net/socket.c:2467
__sys_sendmmsg+0x195/0x470 net/socket.c:2553
__do_sys_sendmmsg net/socket.c:2582 [inline]
__se_sys_sendmmsg net/socket.c:2579 [inline]
__x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff8880985c4800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 776 bytes inside of
1024-byte region [ffff8880985c4800, ffff8880985c4c00)
The buggy address belongs to the page:
page:ffffea0002617000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x985c0
head:ffffea0002617000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c41dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1941, ts 1038999441284, free_ts 1033444432829
prep_new_page mm/page_alloc.c:2434 [inline]
get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271
alloc_slab_page mm/slub.c:1799 [inline]
allocate_slab mm/slub.c:1944 [inline]
new_slab+0x28a/0x3b0 mm/slub.c:2004
___slab_alloc+0x87c/0xe90 mm/slub.c:3018
__slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105
slab_alloc_node mm/slub.c:3196 [inline]
slab_alloc mm/slub.c:3238 [inline]
__kmalloc+0x2fb/0x340 mm/slub.c:4420
kmalloc include/linux/slab.h:586 [inline]
kzalloc include/linux/slab.h:715 [inline]
__register_sysctl_table+0x112/0x1090 fs/proc/proc_sysctl.c:1335
neigh_sysctl_register+0x2c8/0x5e0 net/core/neighbour.c:3787
devinet_sysctl_register+0xb1/0x230 net/ipv4/devinet.c:2618
inetdev_init+0x286/0x580 net/ipv4/devinet.c:278
inetdev_event+0xa8a/0x15d0 net/ipv4/devinet.c:1532
notifier_call_chain+0xb5/0x200 kernel/notifier.c:84
call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919
call_netdevice_notifiers_extack net/core/dev.c:1931 [inline]
call_netdevice_notifiers net/core/dev.c:1945 [inline]
register_netdevice+0x1073/0x1500 net/core/dev.c:9698
veth_newlink+0x59c/0xa90 drivers/net/veth.c:1722
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1352 [inline]
free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
free_unref_page_prepare mm/page_alloc.c:3325 [inline]
free_unref_page+0x19/0x690 mm/page_alloc.c:3404
release_pages+0x748/0x1220 mm/swap.c:956
tlb_batch_pages_flush mm/mmu_gather.c:50 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:243 [inline]
tlb_flush_mmu+0xe9/0x6b0 mm/mmu_gather.c:250
zap_pte_range mm/memory.c:1441 [inline]
zap_pmd_range mm/memory.c:1490 [inline]
zap_pud_range mm/memory.c:1519 [inline]
zap_p4d_range mm/memory.c:1540 [inline]
unmap_page_range+0x1d1d/0x2a30 mm/memory.c:1561
unmap_single_vma+0x198/0x310 mm/memory.c:1606
unmap_vmas+0x16b/0x2f0 mm/memory.c:1638
exit_mmap+0x201/0x670 mm/mmap.c:3178
__mmput+0x122/0x4b0 kernel/fork.c:1114
mmput+0x56/0x60 kernel/fork.c:1135
exit_mm kernel/exit.c:507 [inline]
do_exit+0xa3c/0x2a30 kernel/exit.c:793
do_group_exit+0xd2/0x2f0 kernel/exit.c:935
__do_sys_exit_group kernel/exit.c:946 [inline]
__se_sys_exit_group kernel/exit.c:944 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Memory state around the buggy address:
ffff8880985c4a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880985c4a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880985c4b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880985c4b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880985c4c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
Fixes: 470502de5bdb ("net: sched: unlock rules update API")
Signed-off-by: Eric Dumazet <[email protected]>
Cc: Vlad Buslov <[email protected]>
Cc: Jiri Pirko <[email protected]>
Cc: Cong Wang <[email protected]>
Reported-by: syzbot <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
|
void mg_md5_update(mg_md5_ctx *ctx, const unsigned char *buf, size_t len) {
uint32_t t;
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) ctx->bits[1]++;
ctx->bits[1] += (uint32_t) len >> 29;
t = (t >> 3) & 0x3f;
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
mg_byte_reverse(ctx->in, 16);
mg_md5_transform(ctx->buf, (uint32_t *) ctx->in);
buf += t;
len -= t;
}
while (len >= 64) {
memcpy(ctx->in, buf, 64);
mg_byte_reverse(ctx->in, 16);
mg_md5_transform(ctx->buf, (uint32_t *) ctx->in);
buf += 64;
len -= 64;
}
memcpy(ctx->in, buf, len);
}
| 0 |
[
"CWE-552"
] |
mongoose
|
c65c8fdaaa257e0487ab0aaae9e8f6b439335945
| 199,351,268,503,482,470,000,000,000,000,000,000,000 | 34 |
Protect against the directory traversal in mg_upload()
|
print_string (FILE *fp, const byte *p, size_t n, int delim)
{
for ( ; n; n--, p++ )
{
if (*p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim)
{
putc('\\', fp);
if( *p == '\n' )
putc('n', fp);
else if( *p == '\r' )
putc('r', fp);
else if( *p == '\f' )
putc('f', fp);
else if( *p == '\v' )
putc('v', fp);
else if( *p == '\b' )
putc('b', fp);
else if( !*p )
putc('0', fp);
else
fprintf(fp, "x%02x", *p );
}
else
putc(*p, fp);
}
}
| 0 |
[
"CWE-20"
] |
gnupg
|
2183683bd633818dd031b090b5530951de76f392
| 333,580,609,096,973,200,000,000,000,000,000,000,000 | 26 |
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]>
|
void set_slave_thread_default_charset(THD* thd, Relay_log_info const *rli)
{
DBUG_ENTER("set_slave_thread_default_charset");
thd->variables.character_set_client=
global_system_variables.character_set_client;
thd->variables.collation_connection=
global_system_variables.collation_connection;
thd->variables.collation_server=
global_system_variables.collation_server;
thd->update_charset();
/*
We use a const cast here since the conceptual (and externally
visible) behavior of the function is to set the default charset of
the thread. That the cache has to be invalidated is a secondary
effect.
*/
const_cast<Relay_log_info*>(rli)->cached_charset_invalidate();
DBUG_VOID_RETURN;
}
| 0 |
[
"CWE-284",
"CWE-295"
] |
mysql-server
|
3bd5589e1a5a93f9c224badf983cd65c45215390
| 115,093,579,586,042,830,000,000,000,000,000,000,000 | 21 |
WL#6791 : Redefine client --ssl option to imply enforced encryption
# Changed the meaning of the --ssl=1 option of all client binaries
to mean force ssl, not try ssl and fail over to eunecrypted
# Added a new MYSQL_OPT_SSL_ENFORCE mysql_options()
option to specify that an ssl connection is required.
# Added a new macro SSL_SET_OPTIONS() to the client
SSL handling headers that sets all the relevant SSL options at
once.
# Revamped all of the current native clients to use the new macro
# Removed some Windows line endings.
# Added proper handling of the new option into the ssl helper
headers.
# If SSL is mandatory assume that the media is secure enough
for the sha256 plugin to do unencrypted password exchange even
before establishing a connection.
# Set the default ssl cipher to DHE-RSA-AES256-SHA if none is
specified.
# updated test cases that require a non-default cipher to spawn
a mysql command line tool binary since mysqltest has no support
for specifying ciphers.
# updated the replication slave connection code to always enforce
SSL if any of the SSL config options is present.
# test cases added and updated.
# added a mysql_get_option() API to return mysql_options()
values. Used the new API inside the sha256 plugin.
# Fixed compilation warnings because of unused variables.
# Fixed test failures (mysql_ssl and bug13115401)
# Fixed whitespace issues.
# Fully implemented the mysql_get_option() function.
# Added a test case for mysql_get_option()
# fixed some trailing whitespace issues
# fixed some uint/int warnings in mysql_client_test.c
# removed shared memory option from non-windows get_options
tests
# moved MYSQL_OPT_LOCAL_INFILE to the uint options
|
BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
{
if (!n)
{
return;
}
gdImageLine (im, p->x, p->y, p[n - 1].x, p[n - 1].y, c);
gdImageOpenPolygon (im, p, n, c);
}
| 0 |
[
"CWE-190"
] |
libgd
|
cfee163a5e848fc3e3fb1d05a30d7557cdd36457
| 25,177,114,650,409,730,000,000,000,000,000,000,000 | 11 |
- #18, Removed invalid gdFree call when overflow2 fails
- #17, Free im->pixels as well on error
|
njs_property_query(njs_vm_t *vm, njs_property_query_t *pq, njs_value_t *value,
njs_value_t *key)
{
double num;
uint32_t index;
njs_int_t ret;
njs_object_t *obj;
njs_value_t prop;
njs_function_t *function;
if (njs_slow_path(!njs_is_primitive(key))) {
ret = njs_value_to_string(vm, &prop, key);
if (ret != NJS_OK) {
return ret;
}
key = ∝
}
switch (value->type) {
case NJS_BOOLEAN:
case NJS_NUMBER:
case NJS_SYMBOL:
index = njs_primitive_prototype_index(value->type);
obj = &vm->prototypes[index].object;
break;
case NJS_STRING:
if (njs_fast_path(!njs_is_null_or_undefined_or_boolean(key))) {
num = njs_key_to_index(key);
if (njs_fast_path(njs_key_is_integer_index(num, key))) {
return njs_string_property_query(vm, pq, value, num);
}
}
obj = &vm->string_object;
break;
case NJS_OBJECT:
case NJS_ARRAY:
case NJS_ARRAY_BUFFER:
case NJS_DATA_VIEW:
case NJS_TYPED_ARRAY:
case NJS_REGEXP:
case NJS_DATE:
case NJS_PROMISE:
case NJS_OBJECT_VALUE:
obj = njs_object(value);
break;
case NJS_FUNCTION:
function = njs_function_value_copy(vm, value);
if (njs_slow_path(function == NULL)) {
return NJS_ERROR;
}
obj = &function->object;
break;
case NJS_UNDEFINED:
case NJS_NULL:
default:
ret = njs_primitive_value_to_string(vm, &pq->key, key);
if (njs_fast_path(ret == NJS_OK)) {
njs_string_get(&pq->key, &pq->lhq.key);
njs_type_error(vm, "cannot get property \"%V\" of undefined",
&pq->lhq.key);
return NJS_ERROR;
}
njs_type_error(vm, "cannot get property \"unknown\" of undefined");
return NJS_ERROR;
}
ret = njs_primitive_value_to_key(vm, &pq->key, key);
if (njs_fast_path(ret == NJS_OK)) {
if (njs_is_symbol(key)) {
pq->lhq.key_hash = njs_symbol_key(key);
pq->lhq.key.start = NULL;
} else {
njs_string_get(&pq->key, &pq->lhq.key);
pq->lhq.key_hash = njs_djb_hash(pq->lhq.key.start,
pq->lhq.key.length);
}
ret = njs_object_property_query(vm, pq, obj, key);
if (njs_slow_path(ret == NJS_DECLINED && obj->slots != NULL)) {
return njs_external_property_query(vm, pq, value);
}
}
return ret;
}
| 0 |
[] |
njs
|
6549d49630ce5f5ac823fd3ae0c6c8558b8716ae
| 143,039,399,183,379,370,000,000,000,000,000,000,000 | 100 |
Fixed redefinition of special props in Object.defineProperty().
Previously, when NJS_PROPERTY_HANDLER property was updated it might be
left in inconsistent state. Namely, prop->type was left unchanged, but
prop->value did not have an expected property handler. As a result
consecutive reference to the property may result in a segment violation.
The fix is to update the prop->type during redefinition.
This closes #504 issue on Github.
|
tor_tls_context_new(crypto_pk_env_t *identity, unsigned int key_lifetime)
{
crypto_pk_env_t *rsa = NULL;
EVP_PKEY *pkey = NULL;
tor_tls_context_t *result = NULL;
X509 *cert = NULL, *idcert = NULL;
char *nickname = NULL, *nn2 = NULL;
tor_tls_init();
nickname = crypto_random_hostname(8, 20, "www.", ".net");
nn2 = crypto_random_hostname(8, 20, "www.", ".net");
/* Generate short-term RSA key. */
if (!(rsa = crypto_new_pk_env()))
goto error;
if (crypto_pk_generate_key(rsa)<0)
goto error;
/* Create certificate signed by identity key. */
cert = tor_tls_create_certificate(rsa, identity, nickname, nn2,
key_lifetime);
/* Create self-signed certificate for identity key. */
idcert = tor_tls_create_certificate(identity, identity, nn2, nn2,
IDENTITY_CERT_LIFETIME);
if (!cert || !idcert) {
log(LOG_WARN, LD_CRYPTO, "Error creating certificate");
goto error;
}
result = tor_malloc_zero(sizeof(tor_tls_context_t));
result->refcnt = 1;
result->my_cert = X509_dup(cert);
result->my_id_cert = X509_dup(idcert);
result->key = crypto_pk_dup_key(rsa);
#ifdef EVERYONE_HAS_AES
/* Tell OpenSSL to only use TLS1 */
if (!(result->ctx = SSL_CTX_new(TLSv1_method())))
goto error;
#else
/* Tell OpenSSL to use SSL3 or TLS1 but not SSL2. */
if (!(result->ctx = SSL_CTX_new(SSLv23_method())))
goto error;
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv2);
#endif
SSL_CTX_set_options(result->ctx, SSL_OP_SINGLE_DH_USE);
#ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
SSL_CTX_set_options(result->ctx,
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
#endif
/* Yes, we know what we are doing here. No, we do not treat a renegotiation
* as authenticating any earlier-received data.
*/
if (use_unsafe_renegotiation_op) {
SSL_CTX_set_options(result->ctx,
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION);
}
/* Don't actually allow compression; it uses ram and time, but the data
* we transmit is all encrypted anyway. */
if (result->ctx->comp_methods)
result->ctx->comp_methods = NULL;
#ifdef SSL_MODE_RELEASE_BUFFERS
SSL_CTX_set_mode(result->ctx, SSL_MODE_RELEASE_BUFFERS);
#endif
if (cert && !SSL_CTX_use_certificate(result->ctx,cert))
goto error;
X509_free(cert); /* We just added a reference to cert. */
cert=NULL;
if (idcert) {
X509_STORE *s = SSL_CTX_get_cert_store(result->ctx);
tor_assert(s);
X509_STORE_add_cert(s, idcert);
X509_free(idcert); /* The context now owns the reference to idcert */
idcert = NULL;
}
SSL_CTX_set_session_cache_mode(result->ctx, SSL_SESS_CACHE_OFF);
tor_assert(rsa);
if (!(pkey = _crypto_pk_env_get_evp_pkey(rsa,1)))
goto error;
if (!SSL_CTX_use_PrivateKey(result->ctx, pkey))
goto error;
EVP_PKEY_free(pkey);
pkey = NULL;
if (!SSL_CTX_check_private_key(result->ctx))
goto error;
{
crypto_dh_env_t *dh = crypto_dh_new(DH_TYPE_TLS);
SSL_CTX_set_tmp_dh(result->ctx, _crypto_dh_env_get_dh(dh));
crypto_dh_free(dh);
}
SSL_CTX_set_verify(result->ctx, SSL_VERIFY_PEER,
always_accept_verify_cb);
/* let us realloc bufs that we're writing from */
SSL_CTX_set_mode(result->ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
if (rsa)
crypto_free_pk_env(rsa);
tor_free(nickname);
tor_free(nn2);
return result;
error:
tls_log_errors(NULL, LOG_WARN, "creating TLS context");
tor_free(nickname);
tor_free(nn2);
if (pkey)
EVP_PKEY_free(pkey);
if (rsa)
crypto_free_pk_env(rsa);
if (result)
tor_tls_context_decref(result);
if (cert)
X509_free(cert);
if (idcert)
X509_free(idcert);
return NULL;
}
| 1 |
[
"CWE-264"
] |
tor
|
638fdedcf16cf7d6f7c586d36f7ef335c1c9714f
| 282,346,911,233,605,650,000,000,000,000,000,000,000 | 117 |
Don't send a certificate chain on outgoing TLS connections from non-relays
|
int btrfs_clean_old_snapshots(struct btrfs_root *root)
{
LIST_HEAD(list);
struct btrfs_fs_info *fs_info = root->fs_info;
spin_lock(&fs_info->trans_lock);
list_splice_init(&fs_info->dead_roots, &list);
spin_unlock(&fs_info->trans_lock);
while (!list_empty(&list)) {
int ret;
root = list_entry(list.next, struct btrfs_root, root_list);
list_del(&root->root_list);
btrfs_kill_all_delayed_nodes(root);
if (btrfs_header_backref_rev(root->node) <
BTRFS_MIXED_BACKREF_REV)
ret = btrfs_drop_snapshot(root, NULL, 0, 0);
else
ret =btrfs_drop_snapshot(root, NULL, 1, 0);
BUG_ON(ret < 0);
}
return 0;
}
| 0 |
[
"CWE-310"
] |
linux-2.6
|
9c52057c698fb96f8f07e7a4bcf4801a092bda89
| 60,052,881,707,296,600,000,000,000,000,000,000,000 | 26 |
Btrfs: fix hash overflow handling
The handling for directory crc hash overflows was fairly obscure,
split_leaf returns EOVERFLOW when we try to extend the item and that is
supposed to bubble up to userland. For a while it did so, but along the
way we added better handling of errors and forced the FS readonly if we
hit IO errors during the directory insertion.
Along the way, we started testing only for EEXIST and the EOVERFLOW case
was dropped. The end result is that we may force the FS readonly if we
catch a directory hash bucket overflow.
This fixes a few problem spots. First I add tests for EOVERFLOW in the
places where we can safely just return the error up the chain.
btrfs_rename is harder though, because it tries to insert the new
directory item only after it has already unlinked anything the rename
was going to overwrite. Rather than adding very complex logic, I added
a helper to test for the hash overflow case early while it is still safe
to bail out.
Snapshot and subvolume creation had a similar problem, so they are using
the new helper now too.
Signed-off-by: Chris Mason <[email protected]>
Reported-by: Pascal Junod <[email protected]>
|
zonemgr_cancelio(dns_io_t *io) {
bool send_event = false;
REQUIRE(DNS_IO_VALID(io));
/*
* If we are queued to be run then dequeue.
*/
LOCK(&io->zmgr->iolock);
if (ISC_LINK_LINKED(io, link)) {
if (io->high)
ISC_LIST_UNLINK(io->zmgr->high, io, link);
else
ISC_LIST_UNLINK(io->zmgr->low, io, link);
send_event = true;
INSIST(io->event != NULL);
}
UNLOCK(&io->zmgr->iolock);
if (send_event) {
io->event->ev_attributes |= ISC_EVENTATTR_CANCELED;
isc_task_send(io->task, &io->event);
}
}
| 0 |
[
"CWE-327"
] |
bind9
|
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
| 51,965,600,273,042,265,000,000,000,000,000,000,000 | 24 |
Update keyfetch_done compute_tag check
If in keyfetch_done the compute_tag fails (because for example the
algorithm is not supported), don't crash, but instead ignore the
key.
|
func_ptr_unref(ufunc_T *fp)
{
if (fp != NULL && (--fp->uf_refcount <= 0
|| (fp->uf_refcount == 1 && fp->uf_partial != NULL
&& fp->uf_partial->pt_refcount <= 1
&& fp->uf_partial->pt_func == fp)))
{
// Only delete it when it's not being used. Otherwise it's done
// when "uf_calls" becomes zero.
if (fp->uf_calls == 0)
func_clear_free(fp, FALSE);
}
}
| 0 |
[
"CWE-416"
] |
vim
|
9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04
| 3,701,923,153,121,122,000,000,000,000,000,000,000 | 13 |
patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid.
|
void RGWGetLC_ObjStore_S3::send_response()
{
if (op_ret) {
if (op_ret == -ENOENT) {
set_req_state_err(s, ERR_NO_SUCH_LC);
} else {
set_req_state_err(s, op_ret);
}
}
dump_errno(s);
end_header(s, this, "application/xml");
dump_start(s);
if (op_ret < 0)
return;
encode_xml("LifecycleConfiguration", XMLNS_AWS_S3, config, s->formatter);
rgw_flush_formatter_and_reset(s, s->formatter);
}
| 0 |
[
"CWE-79"
] |
ceph
|
8f90658c731499722d5f4393c8ad70b971d05f77
| 310,456,283,816,878,180,000,000,000,000,000,000,000 | 19 |
rgw: reject unauthenticated response-header actions
Signed-off-by: Matt Benjamin <[email protected]>
Reviewed-by: Casey Bodley <[email protected]>
(cherry picked from commit d8dd5e513c0c62bbd7d3044d7e2eddcd897bd400)
|
PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn)
{
PCIDevice *dev;
dev = pci_create_simple(bus, devfn, "piix3-ide");
pci_ide_create_devs(dev, hd_table);
return dev;
}
| 0 |
[] |
qemu
|
6cd387833d05e8ad31829d97e474dc420625aed9
| 67,367,366,922,204,990,000,000,000,000,000,000,000 | 8 |
Fix release_drive on unplugged devices (pci_piix3_xen_ide_unplug)
pci_piix3_xen_ide_unplug should completely unhook the unplugged
IDEDevice from the corresponding BlockBackend, otherwise the next call
to release_drive will try to detach the drive again.
Suggested-by: Kevin Wolf <[email protected]>
Signed-off-by: Stefano Stabellini <[email protected]>
|
NOEXPORT int conf_init(SERVICE_OPTIONS *section) {
#if OPENSSL_VERSION_NUMBER>=0x10002000L
SSL_CONF_CTX *cctx;
NAME_LIST *curr;
char *cmd, *param;
if(!section->config)
return 0; /* OK */
cctx=SSL_CONF_CTX_new();
if(!cctx) {
sslerror("SSL_CONF_CTX_new");
return 1; /* FAILED */
}
SSL_CONF_CTX_set_ssl_ctx(cctx, section->ctx);
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_FILE);
SSL_CONF_CTX_set_flags(cctx, section->option.client ?
SSL_CONF_FLAG_CLIENT : SSL_CONF_FLAG_SERVER);
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CERTIFICATE);
for(curr=section->config; curr; curr=curr->next) {
cmd=str_dup(curr->name);
param=strchr(cmd, ':');
if(param)
*param++='\0';
switch(SSL_CONF_cmd(cctx, cmd, param)) {
case 2:
s_log(LOG_DEBUG, "OpenSSL config \"%s\" set to \"%s\"", cmd, param);
break;
case 1:
s_log(LOG_DEBUG, "OpenSSL config command \"%s\" executed", cmd);
break;
case -2:
s_log(LOG_ERR,
"OpenSSL config command \"%s\" was not recognised", cmd);
str_free(cmd);
SSL_CONF_CTX_free(cctx);
return 1; /* FAILED */
case -3:
s_log(LOG_ERR,
"OpenSSL config command \"%s\" requires a parameter", cmd);
str_free(cmd);
SSL_CONF_CTX_free(cctx);
return 1; /* FAILED */
default:
sslerror("SSL_CONF_cmd");
str_free(cmd);
SSL_CONF_CTX_free(cctx);
return 1; /* FAILED */
}
str_free(cmd);
}
if(!SSL_CONF_CTX_finish(cctx)) {
sslerror("SSL_CONF_CTX_finish");
SSL_CONF_CTX_free(cctx);
return 1; /* FAILED */
}
SSL_CONF_CTX_free(cctx);
#else /* OpenSSL earlier than 1.0.2 */
(void)section; /* squash the unused parameter warning */
#endif /* OpenSSL 1.0.2 or later */
return 0; /* OK */
}
| 0 |
[
"CWE-295"
] |
stunnel
|
ebad9ddc4efb2635f37174c9d800d06206f1edf9
| 301,038,589,650,567,550,000,000,000,000,000,000,000 | 63 |
stunnel-5.57
|
void testUri() {
UriParserStateA stateA;
UriParserStateW stateW;
UriUriA uriA;
UriUriW uriW;
stateA.uri = &uriA;
stateW.uri = &uriW;
// On/off for each
TEST_ASSERT(0 == uriParseUriA(&stateA, "//user:pass@[::1]:80/segment/index.html?query#frag"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://[::1]:80/segment/index.html?query#frag"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://user:pass@[::1]/segment/index.html?query#frag"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80?query#frag"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html#frag"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://user:pass@[::1]:80/segment/index.html?query"));
uriFreeUriMembersA(&uriA);
// Schema, port, one segment
TEST_ASSERT(0 == uriParseUriA(&stateA, "ftp://host:21/gnu/"));
uriFreeUriMembersA(&uriA);
// Relative
TEST_ASSERT(0 == uriParseUriA(&stateA, "one/two/three"));
TEST_ASSERT(!uriA.absolutePath);
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "/one/two/three"));
TEST_ASSERT(uriA.absolutePath);
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three"));
uriFreeUriMembersA(&uriA);
// ANSI and Unicode
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://www.example.com/"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriW(&stateW, L"http://www.example.com/"));
uriFreeUriMembersW(&uriW);
// Real life examples
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://sourceforge.net/projects/uriparser/"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://sourceforge.net/project/platformdownload.php?group_id=182840"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "mailto:[email protected]"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "../../"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "/"));
TEST_ASSERT(uriA.absolutePath)
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, ""));
TEST_ASSERT(!uriA.absolutePath)
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 == uriParseUriA(&stateA, "file:///bin/bash"));
uriFreeUriMembersA(&uriA);
// Percent encoding
TEST_ASSERT(0 == uriParseUriA(&stateA, "http://www.example.com/name%20with%20spaces/"));
uriFreeUriMembersA(&uriA);
TEST_ASSERT(0 != uriParseUriA(&stateA, "http://www.example.com/name with spaces/"));
uriFreeUriMembersA(&uriA);
}
| 0 |
[
"CWE-787"
] |
uriparser
|
864f5d4c127def386dd5cc926ad96934b297f04e
| 240,239,670,134,217,500,000,000,000,000,000,000,000 | 67 |
UriQuery.c: Fix out-of-bounds-write in ComposeQuery and ...Ex
Reported by Google Autofuzz team
|
void handshakeSuc(AsyncSSLSocket* /* sock */) noexcept override {
VLOG(7) << "client handshake success";
if (callback_) {
callback_->connectSuccess();
}
delete this;
}
| 0 |
[
"CWE-125"
] |
folly
|
c321eb588909646c15aefde035fd3133ba32cdee
| 293,132,383,961,739,800,000,000,000,000,000,000,000 | 7 |
Handle close_notify as standard writeErr in AsyncSSLSocket.
Summary: Fixes CVE-2019-11934
Reviewed By: mingtaoy
Differential Revision: D18020613
fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836
|
static bool ParseTextureInfo(
TextureInfo *texinfo, std::string *err, const json &o,
bool store_original_json_for_extras_and_extensions) {
if (texinfo == nullptr) {
return false;
}
if (!ParseIntegerProperty(&texinfo->index, err, o, "index",
/* required */ true, "TextureInfo")) {
return false;
}
ParseIntegerProperty(&texinfo->texCoord, err, o, "texCoord", false);
ParseExtensionsProperty(&texinfo->extensions, err, o);
ParseExtrasProperty(&texinfo->extras, o);
if (store_original_json_for_extras_and_extensions) {
{
json_const_iterator it;
if (FindMember(o, "extensions", it)) {
texinfo->extensions_json_string = JsonToString(GetValue(it));
}
}
{
json_const_iterator it;
if (FindMember(o, "extras", it)) {
texinfo->extras_json_string = JsonToString(GetValue(it));
}
}
}
return true;
}
| 0 |
[
"CWE-20"
] |
tinygltf
|
52ff00a38447f06a17eab1caa2cf0730a119c751
| 32,373,535,732,636,050,000,000,000,000,000,000,000 | 34 |
Do not expand file path since its not necessary for glTF asset path(URI) and for security reason(`wordexp`).
|
string InferenceContext::DebugString(ShapeHandle s) {
if (RankKnown(s)) {
std::vector<string> vals;
for (auto d : s->dims_) vals.push_back(DebugString(d));
return strings::StrCat("[", absl::StrJoin(vals, ","), "]");
} else {
return "?";
}
}
| 0 |
[
"CWE-190"
] |
tensorflow
|
acd56b8bcb72b163c834ae4f18469047b001fadf
| 270,986,788,436,106,400,000,000,000,000,000,000,000 | 9 |
Fix security vulnerability with SpaceToBatchNDOp.
PiperOrigin-RevId: 445527615
|
int PKCS7_add_certificate(PKCS7 *p7, X509 *x509)
{
int i;
STACK_OF(X509) **sk;
i = OBJ_obj2nid(p7->type);
switch (i) {
case NID_pkcs7_signed:
sk = &(p7->d.sign->cert);
break;
case NID_pkcs7_signedAndEnveloped:
sk = &(p7->d.signed_and_enveloped->cert);
break;
default:
PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, PKCS7_R_WRONG_CONTENT_TYPE);
return (0);
}
if (*sk == NULL)
*sk = sk_X509_new_null();
if (*sk == NULL) {
PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, ERR_R_MALLOC_FAILURE);
return 0;
}
CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
if (!sk_X509_push(*sk, x509)) {
X509_free(x509);
return 0;
}
return (1);
}
| 0 |
[] |
openssl
|
c0334c2c92dd1bc3ad8138ba6e74006c3631b0f9
| 12,475,495,036,179,764,000,000,000,000,000,000,000 | 31 |
PKCS#7: avoid NULL pointer dereferences with missing content
In PKCS#7, the ASN.1 content component is optional.
This typically applies to inner content (detached signatures),
however we must also handle unexpected missing outer content
correctly.
This patch only addresses functions reachable from parsing,
decryption and verification, and functions otherwise associated
with reading potentially untrusted data.
Correcting all low-level API calls requires further work.
CVE-2015-0289
Thanks to Michal Zalewski (Google) for reporting this issue.
Reviewed-by: Steve Henson <[email protected]>
|
find_match_text(colnr_T startcol, int regstart, char_u *match_text)
{
colnr_T col = startcol;
int c1, c2;
int len1, len2;
int match;
for (;;)
{
match = TRUE;
len2 = MB_CHAR2LEN(regstart); // skip regstart
for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1))
{
c1 = PTR2CHAR(match_text + len1);
c2 = PTR2CHAR(rex.line + col + len2);
if (c1 != c2 && (!rex.reg_ic || MB_CASEFOLD(c1) != MB_CASEFOLD(c2)))
{
match = FALSE;
break;
}
len2 += MB_CHAR2LEN(c2);
}
if (match
// check that no composing char follows
&& !(enc_utf8
&& utf_iscomposing(PTR2CHAR(rex.line + col + len2))))
{
cleanup_subexpr();
if (REG_MULTI)
{
rex.reg_startpos[0].lnum = rex.lnum;
rex.reg_startpos[0].col = col;
rex.reg_endpos[0].lnum = rex.lnum;
rex.reg_endpos[0].col = col + len2;
}
else
{
rex.reg_startp[0] = rex.line + col;
rex.reg_endp[0] = rex.line + col + len2;
}
return 1L;
}
// Try finding regstart after the current match.
col += MB_CHAR2LEN(regstart); // skip regstart
if (skip_to_start(regstart, &col) == FAIL)
break;
}
return 0L;
}
| 1 |
[
"CWE-122"
] |
vim
|
65b605665997fad54ef39a93199e305af2fe4d7f
| 110,852,340,714,559,230,000,000,000,000,000,000,000 | 50 |
patch 8.2.3409: reading beyond end of line with invalid utf-8 character
Problem: Reading beyond end of line with invalid utf-8 character.
Solution: Check for NUL when advancing.
|
pgp_compute_signature(sc_card_t *card, const u8 *data,
size_t data_len, u8 * out, size_t outlen)
{
struct pgp_priv_data *priv = DRVDATA(card);
sc_security_env_t *env = &priv->sec_env;
sc_apdu_t apdu;
u8 apdu_case = (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_4;
int r;
LOG_FUNC_CALLED(card->ctx);
if (env->operation != SC_SEC_OPERATION_SIGN)
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
"invalid operation");
switch (env->key_ref[0]) {
case 0x00: /* signature key */
/* PSO SIGNATURE */
sc_format_apdu(card, &apdu, apdu_case, 0x2A, 0x9E, 0x9A);
break;
case 0x02: /* authentication key */
/* INTERNAL AUTHENTICATE */
sc_format_apdu(card, &apdu, apdu_case, 0x88, 0, 0);
break;
case 0x01:
default:
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
"invalid key reference");
}
/* if card/reader does not support extended APDUs, but chaining, then set it */
if (((card->caps & SC_CARD_CAP_APDU_EXT) == 0) && (priv->ext_caps & EXT_CAP_CHAINING))
apdu.flags |= SC_APDU_FLAGS_CHAINING;
apdu.lc = data_len;
apdu.data = (u8 *)data;
apdu.datalen = data_len;
apdu.le = ((outlen >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : outlen;
apdu.resp = out;
apdu.resplen = outlen;
r = sc_transmit_apdu(card, &apdu);
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
LOG_TEST_RET(card->ctx, r, "Card returned error");
LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
}
| 0 |
[
"CWE-125"
] |
OpenSC
|
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
| 178,627,764,386,675,480,000,000,000,000,000,000,000 | 50 |
fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
|
ext_t_0_wv_cspc_11(tvbuff_t *tvb _U_, guint32 value, guint32 str_tbl _U_)
{
char *str = wmem_strdup_printf(wmem_packet_scope(), "Common Value: '%s'",
val_to_str_ext(value, &vals_wv_csp_11_element_value_tokens_ext,
"<Unknown WV-CSP 1.1 Common Value token 0x%X>"));
return str;
}
| 0 |
[
"CWE-399",
"CWE-119",
"CWE-787"
] |
wireshark
|
b8e0d416898bb975a02c1b55883342edc5b4c9c0
| 238,564,183,847,394,970,000,000,000,000,000,000,000 | 7 |
WBXML: add a basic sanity check for offset overflow
This is a naive approach allowing to detact that something went wrong,
without the need to replace all proto_tree_add_text() calls as what was
done in master-2.0 branch.
Bug: 12408
Change-Id: Ia14905005e17ae322c2fc639ad5e491fa08b0108
Reviewed-on: https://code.wireshark.org/review/15310
Reviewed-by: Michael Mann <[email protected]>
Reviewed-by: Pascal Quantin <[email protected]>
|
static uint32_t rtl8139_Config4_read(RTL8139State *s)
{
uint32_t ret = s->Config4;
DPRINTF("Config4 read val=0x%02x\n", ret);
return ret;
}
| 0 |
[
"CWE-835"
] |
qemu
|
5311fb805a4403bba024e83886fa0e7572265de4
| 11,986,073,336,793,334,000,000,000,000,000,000,000 | 8 |
rtl8139: switch to use qemu_receive_packet() for loopback
This patch switches to use qemu_receive_packet() which can detect
reentrancy and return early.
This is intended to address CVE-2021-3416.
Cc: Prasad J Pandit <[email protected]>
Cc: [email protected]
Buglink: https://bugs.launchpad.net/qemu/+bug/1910826
Reviewed-by: Philippe Mathieu-Daudé <[email protected]
Signed-off-by: Alexander Bulekov <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
|
static ssize_t full_scans_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%lu\n", ksm_scan.seqnr);
}
| 0 |
[
"CWE-362",
"CWE-125"
] |
linux
|
2b472611a32a72f4a118c069c2d62a1a3f087afd
| 128,393,037,210,215,050,000,000,000,000,000,000,000 | 5 |
ksm: fix NULL pointer dereference in scan_get_next_rmap_item()
Andrea Righi reported a case where an exiting task can race against
ksmd::scan_get_next_rmap_item (http://lkml.org/lkml/2011/6/1/742) easily
triggering a NULL pointer dereference in ksmd.
ksm_scan.mm_slot == &ksm_mm_head with only one registered mm
CPU 1 (__ksm_exit) CPU 2 (scan_get_next_rmap_item)
list_empty() is false
lock slot == &ksm_mm_head
list_del(slot->mm_list)
(list now empty)
unlock
lock
slot = list_entry(slot->mm_list.next)
(list is empty, so slot is still ksm_mm_head)
unlock
slot->mm == NULL ... Oops
Close this race by revalidating that the new slot is not simply the list
head again.
Andrea's test case:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#define BUFSIZE getpagesize()
int main(int argc, char **argv)
{
void *ptr;
if (posix_memalign(&ptr, getpagesize(), BUFSIZE) < 0) {
perror("posix_memalign");
exit(1);
}
if (madvise(ptr, BUFSIZE, MADV_MERGEABLE) < 0) {
perror("madvise");
exit(1);
}
*(char *)NULL = 0;
return 0;
}
Reported-by: Andrea Righi <[email protected]>
Tested-by: Andrea Righi <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
void fx_DataView_prototype_setFloat32(txMachine* the)
{
fx_DataView_prototype_set(the, 4, fxNumberCoerce, fxFloat32Setter);
}
| 0 |
[
"CWE-125"
] |
moddable
|
135aa9a4a6a9b49b60aa730ebc3bcc6247d75c45
| 89,666,125,355,520,560,000,000,000,000,000,000,000 | 4 |
XS: #896
|
static void register_stuff(AvahiServer *s) {
assert(s);
server_set_state(s, AVAHI_SERVER_REGISTERING);
s->n_host_rr_pending ++; /** Make sure that the state isn't changed tp AVAHI_SERVER_RUNNING too early */
register_hinfo(s);
register_browse_domain(s);
avahi_interface_monitor_update_rrs(s->monitor, 0);
s->n_host_rr_pending --;
if (s->n_host_rr_pending == 0)
server_set_state(s, AVAHI_SERVER_RUNNING);
}
| 0 |
[
"CWE-399"
] |
avahi
|
3093047f1aa36bed8a37fa79004bf0ee287929f4
| 317,644,118,001,998,520,000,000,000,000,000,000,000 | 15 |
Don't get confused by UDP packets with a source port that is zero
This is a fix for rhbz 475394.
Problem identified by Hugo Dias.
|
void cbprintf(vcbprintf_callback user_callback, void *user_data, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
vcbprintf(user_callback,user_data, fmt, argp);
va_end(argp);
}
| 0 |
[
"CWE-119",
"CWE-787"
] |
Espruino
|
0a7619875bf79877907205f6bee08465b89ff10b
| 155,062,973,114,087,310,000,000,000,000,000,000,000 | 6 |
Fix strncat/cpy bounding issues (fix #1425)
|
static int verify_ee(const gnutls_datum_t *raw_crt, gnutls_certificate_type_t crt_type,
dane_cert_type_t ctype, dane_match_type_t match, gnutls_datum_t * data,
unsigned int *verify)
{
gnutls_datum_t pubkey = {NULL, 0};
int ret;
if (ctype == DANE_CERT_X509 && crt_type == GNUTLS_CRT_X509) {
if (!matches(raw_crt, data, match)) {
gnutls_assert();
*verify |= DANE_VERIFY_CERT_DIFFERS;
}
} else if (ctype == DANE_CERT_PK && crt_type == GNUTLS_CRT_X509) {
ret = crt_to_pubkey(raw_crt, &pubkey);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
if (!matches(&pubkey, data, match)) {
gnutls_assert();
*verify |= DANE_VERIFY_CERT_DIFFERS;
}
} else {
ret = gnutls_assert_val(DANE_E_UNKNOWN_DANE_DATA);
goto cleanup;
}
ret = 0;
cleanup:
free(pubkey.data);
return ret;
}
| 0 |
[
"CWE-119"
] |
gnutls
|
ed51e5e53cfbab3103d6b7b85b7ba4515e4f30c3
| 261,856,615,348,128,220,000,000,000,000,000,000,000 | 36 |
Adding dane_raw_tlsa to allow initialization of dane_query_t from DANE records based on external DNS resolutions. Also fixing a buffer overflow.
Signed-off-by: Nikos Mavrogiannopoulos <[email protected]>
|
int RAND_DRBG_set_ex_data(RAND_DRBG *drbg, int idx, void *arg)
{
return CRYPTO_set_ex_data(&drbg->ex_data, idx, arg);
}
| 0 |
[
"CWE-330"
] |
openssl
|
1b0fe00e2704b5e20334a16d3c9099d1ba2ef1be
| 210,433,889,602,657,700,000,000,000,000,000,000,000 | 4 |
drbg: ensure fork-safety without using a pthread_atfork handler
When the new OpenSSL CSPRNG was introduced in version 1.1.1,
it was announced in the release notes that it would be fork-safe,
which the old CSPRNG hadn't been.
The fork-safety was implemented using a fork count, which was
incremented by a pthread_atfork handler. Initially, this handler
was enabled by default. Unfortunately, the default behaviour
had to be changed for other reasons in commit b5319bdbd095, so
the new OpenSSL CSPRNG failed to keep its promise.
This commit restores the fork-safety using a different approach.
It replaces the fork count by a fork id, which coincides with
the process id on UNIX-like operating systems and is zero on other
operating systems. It is used to detect when an automatic reseed
after a fork is necessary.
To prevent a future regression, it also adds a test to verify that
the child reseeds after fork.
CVE-2019-1549
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/9802)
|
struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
{
struct qstr this;
unsigned int c;
int err;
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
this.name = name;
this.len = len;
this.hash = full_name_hash(name, len);
if (!len)
return ERR_PTR(-EACCES);
if (unlikely(name[0] == '.')) {
if (len < 2 || (len == 2 && name[1] == '.'))
return ERR_PTR(-EACCES);
}
while (len--) {
c = *(const unsigned char *)name++;
if (c == '/' || c == '\0')
return ERR_PTR(-EACCES);
}
/*
* See if the low-level filesystem might want
* to use its own hash..
*/
if (base->d_flags & DCACHE_OP_HASH) {
int err = base->d_op->d_hash(base, &this);
if (err < 0)
return ERR_PTR(err);
}
err = inode_permission(base->d_inode, MAY_EXEC);
if (err)
return ERR_PTR(err);
return __lookup_hash(&this, base, 0);
}
| 0 |
[
"CWE-284"
] |
linux
|
9409e22acdfc9153f88d9b1ed2bd2a5b34d2d3ca
| 255,464,695,156,487,650,000,000,000,000,000,000,000 | 40 |
vfs: rename: check backing inode being equal
If a file is renamed to a hardlink of itself POSIX specifies that rename(2)
should do nothing and return success.
This condition is checked in vfs_rename(). However it won't detect hard
links on overlayfs where these are given separate inodes on the overlayfs
layer.
Overlayfs itself detects this condition and returns success without doing
anything, but then vfs_rename() will proceed as if this was a successful
rename (detach_mounts(), d_move()).
The correct thing to do is to detect this condition before even calling
into overlayfs. This patch does this by calling vfs_select_inode() to get
the underlying inodes.
Signed-off-by: Miklos Szeredi <[email protected]>
Cc: <[email protected]> # v4.2+
|
TEST_P(Security, BuiltinAuthenticationAndCryptoPlugin_besteffort_payload_ok)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
PropertyPolicy pub_part_property_policy, sub_part_property_policy,
pub_property_policy, sub_property_policy;
sub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.plugin",
"builtin.PKI-DH"));
sub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_ca",
"file://" + std::string(certs_path) + "/maincacert.pem"));
sub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_certificate",
"file://" + std::string(certs_path) + "/mainsubcert.pem"));
sub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.private_key",
"file://" + std::string(certs_path) + "/mainsubkey.pem"));
sub_part_property_policy.properties().emplace_back(Property("dds.sec.crypto.plugin",
"builtin.AES-GCM-GMAC"));
sub_property_policy.properties().emplace_back("rtps.endpoint.payload_protection_kind", "ENCRYPT");
reader.history_depth(10).
property_policy(sub_part_property_policy).
entity_property_policy(sub_property_policy).init();
ASSERT_TRUE(reader.isInitialized());
pub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.plugin",
"builtin.PKI-DH"));
pub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_ca",
"file://" + std::string(certs_path) + "/maincacert.pem"));
pub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_certificate",
"file://" + std::string(certs_path) + "/mainpubcert.pem"));
pub_part_property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.private_key",
"file://" + std::string(certs_path) + "/mainpubkey.pem"));
pub_part_property_policy.properties().emplace_back(Property("dds.sec.crypto.plugin",
"builtin.AES-GCM-GMAC"));
pub_property_policy.properties().emplace_back("rtps.endpoint.payload_protection_kind", "ENCRYPT");
writer.history_depth(10).
reliability(eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS).
property_policy(pub_part_property_policy).
entity_property_policy(pub_property_policy).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for authorization
reader.waitAuthorized();
writer.waitAuthorized();
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
reader.startReception(data);
// Send data
writer.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
// Block reader until reception finished or timeout.
reader.block_for_at_least(2);
}
| 0 |
[
"CWE-284"
] |
Fast-DDS
|
d2aeab37eb4fad4376b68ea4dfbbf285a2926384
| 112,947,958,385,272,320,000,000,000,000,000,000,000 | 64 |
check remote permissions (#1387)
* Refs 5346. Blackbox test
Signed-off-by: Iker Luengo <[email protected]>
* Refs 5346. one-way string compare
Signed-off-by: Iker Luengo <[email protected]>
* Refs 5346. Do not add partition separator on last partition
Signed-off-by: Iker Luengo <[email protected]>
* Refs 5346. Uncrustify
Signed-off-by: Iker Luengo <[email protected]>
* Refs 5346. Uncrustify
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Access control unit testing
It only covers Partition and Topic permissions
Signed-off-by: Iker Luengo <[email protected]>
* Refs #3680. Fix partition check on Permissions plugin.
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Uncrustify
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Fix tests on mac
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Fix windows tests
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Avoid memory leak on test
Signed-off-by: Iker Luengo <[email protected]>
* Refs 3680. Proxy data mocks should not return temporary objects
Signed-off-by: Iker Luengo <[email protected]>
* refs 3680. uncrustify
Signed-off-by: Iker Luengo <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
|
SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
struct timezone __user *, tz)
{
if (tv) {
struct timeval ktv;
do_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
if (tz) {
if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
return -EFAULT;
}
return 0;
}
| 0 |
[
"CWE-703",
"CWE-264",
"CWE-189"
] |
linux
|
21c5977a836e399fc710ff2c5367845ed5c2527f
| 311,496,668,897,211,060,000,000,000,000,000,000,000 | 15 |
alpha: fix several security issues
Fix several security issues in Alpha-specific syscalls. Untested, but
mostly trivial.
1. Signedness issue in osf_getdomainname allows copying out-of-bounds
kernel memory to userland.
2. Signedness issue in osf_sysinfo allows copying large amounts of
kernel memory to userland.
3. Typo (?) in osf_getsysinfo bounds minimum instead of maximum copy
size, allowing copying large amounts of kernel memory to userland.
4. Usage of user pointer in osf_wait4 while under KERNEL_DS allows
privilege escalation via writing return value of sys_wait4 to kernel
memory.
Signed-off-by: Dan Rosenberg <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
is_identity_node (GoaOAuth2Provider *provider, WebKitDOMHTMLInputElement *element)
{
gboolean ret;
gchar *element_type;
gchar *id;
gchar *name;
element_type = NULL;
id = NULL;
name = NULL;
ret = FALSE;
g_object_get (element, "type", &element_type, NULL);
if (g_strcmp0 (element_type, "email") != 0)
goto out;
id = webkit_dom_html_element_get_id (WEBKIT_DOM_HTML_ELEMENT (element));
if (g_strcmp0 (id, "Email") != 0)
goto out;
name = webkit_dom_html_input_element_get_name (element);
if (g_strcmp0 (name, "Email") != 0)
goto out;
ret = TRUE;
out:
g_free (element_type);
g_free (id);
g_free (name);
return ret;
}
| 0 |
[
"CWE-310"
] |
gnome-online-accounts
|
edde7c63326242a60a075341d3fea0be0bc4d80e
| 190,023,600,406,554,370,000,000,000,000,000,000,000 | 33 |
Guard against invalid SSL certificates
None of the branded providers (eg., Google, Facebook and Windows Live)
should ever have an invalid certificate. So set "ssl-strict" on the
SoupSession object being used by GoaWebView.
Providers like ownCloud and Exchange might have to deal with
certificates that are not up to the mark. eg., self-signed
certificates. For those, show a warning when the account is being
created, and only proceed if the user decides to ignore it. In any
case, save the status of the certificate that was used to create the
account. So an account created with a valid certificate will never
work with an invalid one, and one created with an invalid certificate
will not throw any further warnings.
Fixes: CVE-2013-0240
|
bool AuthorizationSession::isCoauthorizedWithClient(Client* opClient, WithLock opClientLock) {
auto getUserNames = [](AuthorizationSession* authSession) {
if (authSession->isImpersonating()) {
return authSession->getImpersonatedUserNames();
} else {
return authSession->getAuthenticatedUserNames();
}
};
UserNameIterator it = getUserNames(this);
while (it.more()) {
UserNameIterator opIt = getUserNames(AuthorizationSession::get(opClient));
while (opIt.more()) {
if (it.get() == opIt.get()) {
return true;
}
opIt.next();
}
it.next();
}
return false;
}
| 0 |
[
"CWE-613"
] |
mongo
|
db19e7ce84cfd702a4ba9983ee2ea5019f470f82
| 201,706,733,760,009,420,000,000,000,000,000,000,000 | 23 |
SERVER-38984 Validate unique User ID on UserCache hit
(cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
|
static struct dce_hwseq *dce100_hwseq_create(
struct dc_context *ctx)
{
struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
if (hws) {
hws->ctx = ctx;
hws->regs = &hwseq_reg;
hws->shifts = &hwseq_shift;
hws->masks = &hwseq_mask;
}
return hws;
}
| 0 |
[
"CWE-400",
"CWE-401"
] |
linux
|
104c307147ad379617472dd91a5bcb368d72bd6d
| 3,476,933,819,663,982,400,000,000,000,000,000,000 | 13 |
drm/amd/display: prevent memory leak
In dcn*_create_resource_pool the allocated memory should be released if
construct pool fails.
Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
|
process_with_aes(std::string const& key,
bool encrypt,
std::string const& data,
size_t outlength = 0,
unsigned int repetitions = 1,
unsigned char const* iv = 0,
size_t iv_length = 0)
{
Pl_Buffer buffer("buffer");
Pl_AES_PDF aes("aes", &buffer, encrypt,
QUtil::unsigned_char_pointer(key),
QIntC::to_uint(key.length()));
if (iv)
{
aes.setIV(iv, iv_length);
}
else
{
aes.useZeroIV();
}
aes.disablePadding();
for (unsigned int i = 0; i < repetitions; ++i)
{
aes.write(QUtil::unsigned_char_pointer(data), data.length());
}
aes.finish();
PointerHolder<Buffer> bufp = buffer.getBuffer();
if (outlength == 0)
{
outlength = bufp->getSize();
}
else
{
outlength = std::min(outlength, bufp->getSize());
}
return std::string(reinterpret_cast<char*>(bufp->getBuffer()), outlength);
}
| 0 |
[
"CWE-787"
] |
qpdf
|
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
| 198,037,683,406,513,600,000,000,000,000,000,000,000 | 37 |
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 int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
{
git_oid hash_final;
struct index_header header;
bool is_extended;
uint32_t index_version_number;
assert(index && file);
if (index->version <= INDEX_VERSION_NUMBER_EXT) {
is_extended = is_index_extended(index);
index_version_number = is_extended ? INDEX_VERSION_NUMBER_EXT : INDEX_VERSION_NUMBER_LB;
} else {
index_version_number = index->version;
}
header.signature = htonl(INDEX_HEADER_SIG);
header.version = htonl(index_version_number);
header.entry_count = htonl((uint32_t)index->entries.length);
if (git_filebuf_write(file, &header, sizeof(struct index_header)) < 0)
return -1;
if (write_entries(index, file) < 0)
return -1;
/* write the tree cache extension */
if (index->tree != NULL && write_tree_extension(index, file) < 0)
return -1;
/* write the rename conflict extension */
if (index->names.length > 0 && write_name_extension(index, file) < 0)
return -1;
/* write the reuc extension */
if (index->reuc.length > 0 && write_reuc_extension(index, file) < 0)
return -1;
/* get out the hash for all the contents we've appended to the file */
git_filebuf_hash(&hash_final, file);
git_oid_cpy(checksum, &hash_final);
/* write it at the end of the file */
if (git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ) < 0)
return -1;
/* file entries are no longer up to date */
clear_uptodate(index);
return 0;
}
| 0 |
[
"CWE-415",
"CWE-190"
] |
libgit2
|
3db1af1f370295ad5355b8f64b865a2a357bcac0
| 137,455,156,669,290,340,000,000,000,000,000,000,000 | 51 |
index: error out on unreasonable prefix-compressed path lengths
When computing the complete path length from the encoded
prefix-compressed path, we end up just allocating the complete path
without ever checking what the encoded path length actually is. This can
easily lead to a denial of service by just encoding an unreasonable long
path name inside of the index. Git already enforces a maximum path
length of 4096 bytes. As we also have that enforcement ready in some
places, just make sure that the resulting path is smaller than
GIT_PATH_MAX.
Reported-by: Krishna Ram Prakash R <[email protected]>
Reported-by: Vivek Parikh <[email protected]>
|
bool check_selective_cr0_intercepted(struct vcpu_svm *svm, unsigned long val)
{
unsigned long cr0 = svm->vcpu.arch.cr0;
bool ret = false;
u64 intercept;
intercept = svm->nested.intercept;
if (!is_guest_mode(&svm->vcpu) ||
(!(intercept & (1ULL << INTERCEPT_SELECTIVE_CR0))))
return false;
cr0 &= ~SVM_CR0_SELECTIVE_MASK;
val &= ~SVM_CR0_SELECTIVE_MASK;
if (cr0 ^ val) {
svm->vmcb->control.exit_code = SVM_EXIT_CR0_SEL_WRITE;
ret = (nested_svm_exit_handled(svm) == NESTED_EXIT_DONE);
}
return ret;
}
| 0 |
[] |
kvm
|
854e8bb1aa06c578c2c9145fa6bfe3680ef63b23
| 304,270,419,313,634,700,000,000,000,000,000,000,000 | 22 |
KVM: x86: Check non-canonical addresses upon WRMSR
Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is
written to certain MSRs. The behavior is "almost" identical for AMD and Intel
(ignoring MSRs that are not implemented in either architecture since they would
anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if
non-canonical address is written on Intel but not on AMD (which ignores the top
32-bits).
Accordingly, this patch injects a #GP on the MSRs which behave identically on
Intel and AMD. To eliminate the differences between the architecutres, the
value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to
canonical value before writing instead of injecting a #GP.
Some references from Intel and AMD manuals:
According to Intel SDM description of WRMSR instruction #GP is expected on
WRMSR "If the source register contains a non-canonical address and ECX
specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE,
IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP."
According to AMD manual instruction manual:
LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the
LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical
form, a general-protection exception (#GP) occurs."
IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the
base field must be in canonical form or a #GP fault will occur."
IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must
be in canonical form."
This patch fixes CVE-2014-3610.
Cc: [email protected]
Signed-off-by: Nadav Amit <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
|
static struct db_arg_chain_tree *_db_node_get(struct db_arg_chain_tree *node)
{
node->refcnt++;
return node;
}
| 1 |
[] |
libseccomp
|
c5bf78de480b32b324e0f511c88ce533ed280b37
| 112,643,454,597,684,500,000,000,000,000,000,000,000 | 5 |
db: fix 64-bit argument comparisons
Our approach to doing 64-bit comparisons using 32-bit operators was
just plain wrong, leading to a number of potential problems with
filters that used the LT, GT, LE, or GE operators. This patch fixes
this problem and a few other related issues that came to light in
the course of fixing the core problem.
A special thanks to Jann Horn for bringing this problem to our
attention.
Signed-off-by: Paul Moore <[email protected]>
|
int cil_resolve_catorder(struct cil_tree_node *current, void *extra_args)
{
struct cil_args_resolve *args = extra_args;
struct cil_list *catorder_list = args->catorder_lists;
struct cil_catorder *catorder = current->data;
struct cil_list *new = NULL;
struct cil_list_item *curr = NULL;
struct cil_symtab_datum *cat_datum;
struct cil_cat *cat = NULL;
struct cil_ordered_list *ordered = NULL;
int rc = SEPOL_ERR;
cil_list_init(&new, CIL_CATORDER);
cil_list_for_each(curr, catorder->cat_list_str) {
struct cil_tree_node *node = NULL;
rc = cil_resolve_name(current, (char *)curr->data, CIL_SYM_CATS, extra_args, &cat_datum);
if (rc != SEPOL_OK) {
cil_log(CIL_ERR, "Failed to resolve category %s in categoryorder\n", (char *)curr->data);
goto exit;
}
node = NODE(cat_datum);
if (node->flavor != CIL_CAT) {
cil_log(CIL_ERR, "%s is not a category. Only categories are allowed in categoryorder statements\n", cat_datum->name);
rc = SEPOL_ERR;
goto exit;
}
cat = (struct cil_cat *)cat_datum;
cil_list_append(new, CIL_CAT, cat);
}
__cil_ordered_list_init(&ordered);
ordered->list = new;
ordered->node = current;
cil_list_append(catorder_list, CIL_CATORDER, ordered);
return SEPOL_OK;
exit:
cil_list_destroy(&new, CIL_FALSE);
return rc;
}
| 0 |
[
"CWE-125"
] |
selinux
|
340f0eb7f3673e8aacaf0a96cbfcd4d12a405521
| 246,510,214,555,912,750,000,000,000,000,000,000,000 | 42 |
libsepol/cil: Check for statements not allowed in optional blocks
While there are some checks for invalid statements in an optional
block when resolving the AST, there are no checks when building the
AST.
OSS-Fuzz found the following policy which caused a null dereference
in cil_tree_get_next_path().
(blockinherit b3)
(sid SID)
(sidorder(SID))
(optional o
(ibpkeycon :(1 0)s)
(block b3
(filecon""block())
(filecon""block())))
The problem is that the blockinherit copies block b3 before
the optional block is disabled. When the optional is disabled,
block b3 is deleted along with everything else in the optional.
Later, when filecon statements with the same path are found an
error message is produced and in trying to find out where the block
was copied from, the reference to the deleted block is used. The
error handling code assumes (rightly) that if something was copied
from a block then that block should still exist.
It is clear that in-statements, blocks, and macros cannot be in an
optional, because that allows nodes to be copied from the optional
block to somewhere outside even though the optional could be disabled
later. When optionals are disabled the AST is reset and the
resolution is restarted at the point of resolving macro calls, so
anything resolved before macro calls will never be re-resolved.
This includes tunableifs, in-statements, blockinherits,
blockabstracts, and macro definitions. Tunable declarations also
cannot be in an optional block because they are needed to resolve
tunableifs. It should be fine to allow blockinherit statements in
an optional, because that is copying nodes from outside the optional
to the optional and if the optional is later disabled, everything
will be deleted anyway.
Check and quit with an error if a tunable declaration, in-statement,
block, blockabstract, or macro definition is found within an
optional when either building or resolving the AST.
Signed-off-by: James Carter <[email protected]>
|
static int ZEND_FASTCALL ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
zend_free_op free_op1;
zval **var_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
if (IS_VAR == IS_VAR && !var_ptr) {
zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets");
}
if (IS_VAR == IS_VAR && *var_ptr == EG(error_zval_ptr)) {
if (!RETURN_VALUE_UNUSED(&opline->result)) {
EX_T(opline->result.u.var).tmp_var = *EG(uninitialized_zval_ptr);
}
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
ZEND_VM_NEXT_OPCODE();
}
EX_T(opline->result.u.var).tmp_var = **var_ptr;
zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var);
SEPARATE_ZVAL_IF_NOT_REF(var_ptr);
if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get)
&& Z_OBJ_HANDLER_PP(var_ptr, set)) {
/* proxy object */
zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC);
Z_ADDREF_P(val);
increment_function(val);
Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);
zval_ptr_dtor(&val);
} else {
increment_function(*var_ptr);
}
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
ZEND_VM_NEXT_OPCODE();
}
| 0 |
[] |
php-src
|
ce96fd6b0761d98353761bf78d5bfb55291179fd
| 85,661,406,434,494,620,000,000,000,000,000,000,000 | 37 |
- fix #39863, do not accept paths with NULL in them. See http://news.php.net/php.internals/50191, trunk will have the patch later (adding a macro and/or changing (some) APIs. Patch by Rasmus
|
TEST_F(QueryPlannerTest, TagAccordingToCacheFailsOnBadInput) {
const NamespaceString nss("test.collection");
auto qr = stdx::make_unique<QueryRequest>(nss);
qr->setFilter(BSON("a" << 3));
auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(qr));
ASSERT_OK(statusWithCQ.getStatus());
std::unique_ptr<CanonicalQuery> scopedCq = std::move(statusWithCQ.getValue());
std::unique_ptr<PlanCacheIndexTree> indexTree(new PlanCacheIndexTree());
indexTree->setIndexEntry(IndexEntry(BSON("a" << 1), "a_1"));
std::map<StringData, size_t> indexMap;
// Null filter.
Status s = QueryPlanner::tagAccordingToCache(NULL, indexTree.get(), indexMap);
ASSERT_NOT_OK(s);
// Null indexTree.
s = QueryPlanner::tagAccordingToCache(scopedCq->root(), NULL, indexMap);
ASSERT_NOT_OK(s);
// Index not found.
s = QueryPlanner::tagAccordingToCache(scopedCq->root(), indexTree.get(), indexMap);
ASSERT_NOT_OK(s);
// Index found once added to the map.
indexMap["a_1"_sd] = 0;
s = QueryPlanner::tagAccordingToCache(scopedCq->root(), indexTree.get(), indexMap);
ASSERT_OK(s);
// Regenerate canonical query in order to clear tags.
auto newQR = stdx::make_unique<QueryRequest>(nss);
newQR->setFilter(BSON("a" << 3));
statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(newQR));
ASSERT_OK(statusWithCQ.getStatus());
scopedCq = std::move(statusWithCQ.getValue());
// Mismatched tree topology.
PlanCacheIndexTree* child = new PlanCacheIndexTree();
child->setIndexEntry(IndexEntry(BSON("a" << 1)));
indexTree->children.push_back(child);
s = QueryPlanner::tagAccordingToCache(scopedCq->root(), indexTree.get(), indexMap);
ASSERT_NOT_OK(s);
}
| 0 |
[] |
mongo
|
64095239f41e9f3841d8be9088347db56d35c891
| 189,765,592,686,950,800,000,000,000,000,000,000,000 | 45 |
SERVER-51083 Reject invalid UTF-8 from $regex match expressions
|
subtlvs_print(netdissect_options *ndo,
const u_char *cp, const u_char *ep, const uint8_t tlv_type)
{
uint8_t subtype, sublen;
const char *sep;
uint32_t t1, t2;
while (cp < ep) {
subtype = *cp++;
if(subtype == MESSAGE_SUB_PAD1) {
ND_PRINT((ndo, " sub-pad1"));
continue;
}
if(cp == ep)
goto invalid;
sublen = *cp++;
if(cp + sublen > ep)
goto invalid;
switch(subtype) {
case MESSAGE_SUB_PADN:
ND_PRINT((ndo, " sub-padn"));
cp += sublen;
break;
case MESSAGE_SUB_DIVERSITY:
ND_PRINT((ndo, " sub-diversity"));
if (sublen == 0) {
ND_PRINT((ndo, " empty"));
break;
}
sep = " ";
while(sublen--) {
ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
sep = "-";
}
if(tlv_type != MESSAGE_UPDATE &&
tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
ND_PRINT((ndo, " (bogus)"));
break;
case MESSAGE_SUB_TIMESTAMP:
ND_PRINT((ndo, " sub-timestamp"));
if(tlv_type == MESSAGE_HELLO) {
if(sublen < 4)
goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
} else if(tlv_type == MESSAGE_IHU) {
if(sublen < 8)
goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
t2 = EXTRACT_32BITS(cp + 4);
ND_PRINT((ndo, "|%s", format_timestamp(t2)));
} else
ND_PRINT((ndo, " (bogus)"));
cp += sublen;
break;
default:
ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
cp += sublen;
} /* switch */
} /* while */
return;
invalid:
ND_PRINT((ndo, "%s", istr));
}
| 0 |
[
"CWE-125"
] |
tcpdump
|
12f66f69f7bf1ec1266ddbee90a7616cbf33696b
| 39,121,518,526,482,126,000,000,000,000,000,000,000 | 67 |
(for 4.9.3) CVE-2018-14470/Babel: fix an existing length check
In babel_print_v2() the non-verbose branch for an Update TLV compared
the TLV Length against 1 instead of 10 (probably a typo), put it right.
This fixes a buffer over-read discovered by Henri Salo from Nixu
Corporation.
Add a test using the capture file supplied by the reporter(s).
|
static void ZSTD_initCCtx(ZSTD_CCtx* cctx, ZSTD_customMem memManager)
{
assert(cctx != NULL);
memset(cctx, 0, sizeof(*cctx));
cctx->customMem = memManager;
cctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
{ size_t const err = ZSTD_CCtx_resetParameters(cctx);
assert(!ZSTD_isError(err));
(void)err;
}
}
| 0 |
[
"CWE-362"
] |
zstd
|
3e5cdf1b6a85843e991d7d10f6a2567c15580da0
| 224,314,857,581,006,800,000,000,000,000,000,000,000 | 11 |
fixed T36302429
|
EXPORTED void allow_hdr(const char *hdr, unsigned allow)
{
const char *meths[] = {
"OPTIONS, GET, HEAD", "POST", "PUT", "DELETE", "TRACE", NULL
};
comma_list_hdr(hdr, meths, allow);
if (allow & ALLOW_DAV) {
prot_printf(httpd_out, "%s: PROPFIND, REPORT", hdr);
if (allow & ALLOW_WRITE) {
prot_puts(httpd_out, ", COPY, MOVE, LOCK, UNLOCK");
}
if (allow & ALLOW_WRITECOL) {
prot_puts(httpd_out, ", PROPPATCH, MKCOL, ACL");
if (allow & ALLOW_CAL) {
prot_printf(httpd_out, "\r\n%s: MKCALENDAR", hdr);
}
}
prot_puts(httpd_out, "\r\n");
}
}
| 0 |
[
"CWE-787"
] |
cyrus-imapd
|
a5779db8163b99463e25e7c476f9cbba438b65f3
| 91,096,702,260,248,450,000,000,000,000,000,000,000 | 22 |
HTTP: don't overrun buffer when parsing strings with sscanf()
|
inline static void _slurm_rpc_suspend(slurm_msg_t * msg)
{
int error_code = SLURM_SUCCESS;
DEF_TIMERS;
suspend_msg_t *sus_ptr = (suspend_msg_t *) msg->data;
/* Locks: write job and node */
slurmctld_lock_t job_write_lock = {
NO_LOCK, WRITE_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK };
uid_t uid = g_slurm_auth_get_uid(msg->auth_cred,
slurmctld_config.auth_info);
struct job_record *job_ptr;
char *op;
START_TIMER;
switch (sus_ptr->op) {
case SUSPEND_JOB:
op = "suspend";
break;
case RESUME_JOB:
op = "resume";
break;
default:
op = "unknown";
}
info("Processing RPC: REQUEST_SUSPEND(%s) from uid=%u",
op, (unsigned int) uid);
/* Get the job id part of the jobid. It could be an array id. Currently
* in a federation, job arrays only run on the origin cluster so we just
* want to find if the array, not a specific task, is on the origin
* cluster. */
if ((sus_ptr->job_id == NO_VAL) && sus_ptr->job_id_str)
sus_ptr->job_id = strtol(sus_ptr->job_id_str, NULL, 10);
lock_slurmctld(job_write_lock);
job_ptr = find_job_record(sus_ptr->job_id);
/* If job is found on the cluster, it could be pending, the origin
* cluster, or running on the sibling cluster. If it's not there then
* route it to the origin, otherwise try to suspend the job. If it's
* pending an error should be returned. If it's running then it should
* suspend the job. */
if (!job_ptr &&
!_route_msg_to_origin(msg, NULL, sus_ptr->job_id, uid)) {
unlock_slurmctld(job_write_lock);
return;
}
if (!job_ptr)
error_code = ESLURM_INVALID_JOB_ID;
else if (fed_mgr_cluster_rec && job_ptr->fed_details &&
fed_mgr_is_origin_job(job_ptr) &&
IS_JOB_REVOKED(job_ptr) &&
job_ptr->fed_details->cluster_lock &&
(job_ptr->fed_details->cluster_lock !=
fed_mgr_cluster_rec->fed.id)) {
/* Route to the cluster that is running the job. */
slurmdb_cluster_rec_t *dst =
fed_mgr_get_cluster_by_id(
job_ptr->fed_details->cluster_lock);
if (dst) {
slurm_send_reroute_msg(msg, dst);
info("%s: %s job %d uid %d routed to %s",
__func__, rpc_num2string(msg->msg_type),
job_ptr->job_id, uid, dst->name);
unlock_slurmctld(job_write_lock);
END_TIMER2("_slurm_rpc_suspend");
return;
}
error("couldn't find cluster by cluster id %d",
job_ptr->fed_details->cluster_lock);
error_code = ESLURM_INVALID_CLUSTER_NAME;
} else if (sus_ptr->job_id_str) {
error_code = job_suspend2(sus_ptr, uid, msg->conn_fd, true,
msg->protocol_version);
} else {
error_code = job_suspend(sus_ptr, uid, msg->conn_fd, true,
msg->protocol_version);
}
unlock_slurmctld(job_write_lock);
END_TIMER2("_slurm_rpc_suspend");
if (!sus_ptr->job_id_str)
xstrfmtcat(sus_ptr->job_id_str, "%u", sus_ptr->job_id);
if (error_code) {
info("_slurm_rpc_suspend(%s) for %s %s", op,
sus_ptr->job_id_str, slurm_strerror(error_code));
} else {
info("_slurm_rpc_suspend(%s) for %s %s", op,
sus_ptr->job_id_str, TIME_STR);
schedule_job_save(); /* Has own locking */
if (sus_ptr->op == SUSPEND_JOB)
queue_job_scheduler();
}
}
| 0 |
[
"CWE-20"
] |
slurm
|
033dc0d1d28b8d2ba1a5187f564a01c15187eb4e
| 61,726,485,367,016,440,000,000,000,000,000,000,000 | 99 |
Fix insecure handling of job requested gid.
Only trust MUNGE signed values, unless the RPC was signed by
SlurmUser or root.
CVE-2018-10995.
|
bool MYSQL_LOG::open(
#ifdef HAVE_PSI_INTERFACE
PSI_file_key log_file_key,
#endif
const char *log_name, enum_log_type log_type_arg,
const char *new_name, enum cache_type io_cache_type_arg)
{
char buff[FN_REFLEN];
MY_STAT f_stat;
File file= -1;
int open_flags= O_CREAT | O_BINARY;
DBUG_ENTER("MYSQL_LOG::open");
DBUG_PRINT("enter", ("log_type: %d", (int) log_type_arg));
write_error= 0;
if (!(name= my_strdup(log_name, MYF(MY_WME))))
{
name= (char *)log_name; // for the error message
goto err;
}
if (init_and_set_log_file_name(name, new_name,
log_type_arg, io_cache_type_arg))
goto err;
/* File is regular writable file */
if (my_stat(log_file_name, &f_stat, MYF(0)) && !MY_S_ISREG(f_stat.st_mode))
goto err;
if (io_cache_type == SEQ_READ_APPEND)
open_flags |= O_RDWR | O_APPEND;
else
open_flags |= O_WRONLY | (log_type == LOG_BIN ? 0 : O_APPEND);
db[0]= 0;
#ifdef HAVE_PSI_INTERFACE
/* Keep the key for reopen */
m_log_file_key= log_file_key;
#endif
if ((file= mysql_file_open(log_file_key,
log_file_name, open_flags,
MYF(MY_WME | ME_WAITTANG))) < 0 ||
init_io_cache(&log_file, file, IO_SIZE, io_cache_type,
mysql_file_tell(file, MYF(MY_WME)), 0,
MYF(MY_WME | MY_NABP |
((log_type == LOG_BIN) ? MY_WAIT_IF_FULL : 0))))
goto err;
if (log_type == LOG_NORMAL)
{
char *end;
int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s (%s). "
#ifdef EMBEDDED_LIBRARY
"embedded library\n",
my_progname, server_version, MYSQL_COMPILATION_COMMENT
#elif _WIN32
"started with:\nTCP Port: %d, Named Pipe: %s\n",
my_progname, server_version, MYSQL_COMPILATION_COMMENT,
mysqld_port, mysqld_unix_port
#else
"started with:\nTcp port: %d Unix socket: %s\n",
my_progname, server_version, MYSQL_COMPILATION_COMMENT,
mysqld_port, mysqld_unix_port
#endif
);
end= strnmov(buff + len, "Time Id Command Argument\n",
sizeof(buff) - len);
if (my_b_write(&log_file, (uchar*) buff, (uint) (end-buff)) ||
flush_io_cache(&log_file))
goto err;
}
log_state= LOG_OPENED;
DBUG_RETURN(0);
err:
sql_print_error("Could not use %s for logging (error %d). \
Turning logging off for the whole duration of the MySQL server process. \
To turn it on again: fix the cause, \
shutdown the MySQL server and restart it.", name, errno);
if (file >= 0)
mysql_file_close(file, MYF(0));
end_io_cache(&log_file);
my_free(name);
name= NULL;
log_state= LOG_CLOSED;
DBUG_RETURN(1);
}
| 1 |
[
"CWE-264"
] |
mysql-server
|
48bd8b16fe382be302c6f0b45931be5aa6f29a0e
| 251,592,727,657,982,730,000,000,000,000,000,000,000 | 91 |
Bug#24388753: PRIVILEGE ESCALATION USING MYSQLD_SAFE
[This is the 5.5/5.6 version of the bugfix].
The problem was that it was possible to write log files ending
in .ini/.cnf that later could be parsed as an options file.
This made it possible for users to specify startup options
without the permissions to do so.
This patch fixes the problem by disallowing general query log
and slow query log to be written to files ending in .ini and .cnf.
|
MagickExport unsigned char *ImageToBlob(const ImageInfo *image_info,
Image *image,size_t *length,ExceptionInfo *exception)
{
const MagickInfo
*magick_info;
ImageInfo
*blob_info;
MagickBooleanType
status;
unsigned char
*blob;
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
assert(exception != (ExceptionInfo *) NULL);
*length=0;
blob=(unsigned char *) NULL;
blob_info=CloneImageInfo(image_info);
blob_info->adjoin=MagickFalse;
(void) SetImageInfo(blob_info,1,exception);
if (*blob_info->magick != '\0')
(void) CopyMagickString(image->magick,blob_info->magick,MaxTextExtent);
magick_info=GetMagickInfo(image->magick,exception);
if (magick_info == (const MagickInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
image->magick);
blob_info=DestroyImageInfo(blob_info);
return(blob);
}
(void) CopyMagickString(blob_info->magick,image->magick,MaxTextExtent);
if (GetMagickBlobSupport(magick_info) != MagickFalse)
{
/*
Native blob support for this image format.
*/
blob_info->length=0;
blob_info->blob=AcquireQuantumMemory(MagickMaxBlobExtent,
sizeof(unsigned char));
if (blob_info->blob == (void *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
else
{
(void) CloseBlob(image);
image->blob->exempt=MagickTrue;
*image->filename='\0';
status=WriteImage(blob_info,image);
InheritException(exception,&image->exception);
*length=image->blob->length;
blob=DetachBlob(image->blob);
if (blob == (unsigned char *) NULL)
blob_info->blob=RelinquishMagickMemory(blob_info->blob);
else if (status == MagickFalse)
blob=(unsigned char *) RelinquishMagickMemory(blob);
else
blob=(unsigned char *) ResizeQuantumMemory(blob,*length+1,
sizeof(*blob));
}
}
else
{
char
unique[MaxTextExtent];
int
file;
/*
Write file to disk in blob image format.
*/
file=AcquireUniqueFileResource(unique);
if (file == -1)
{
ThrowFileException(exception,BlobError,"UnableToWriteBlob",
image_info->filename);
}
else
{
blob_info->file=fdopen(file,"wb");
if (blob_info->file != (FILE *) NULL)
{
(void) FormatLocaleString(image->filename,MaxTextExtent,"%s:%s",
image->magick,unique);
status=WriteImage(blob_info,image);
(void) CloseBlob(image);
(void) fclose(blob_info->file);
if (status == MagickFalse)
InheritException(exception,&image->exception);
else
blob=FileToBlob(unique,~0UL,length,exception);
}
(void) RelinquishUniqueFileResource(unique);
}
}
blob_info=DestroyImageInfo(blob_info);
return(blob);
}
| 0 |
[
"CWE-416"
] |
ImageMagick6
|
614a257295bdcdeda347086761062ac7658b6830
| 229,050,642,099,798,830,000,000,000,000,000,000,000 | 107 |
https://github.com/ImageMagick/ImageMagick6/issues/43
|
void t_cpp_generator::generate_cpp_struct(t_struct* tstruct, bool is_exception) {
generate_struct_declaration(f_types_, tstruct, is_exception, false, true, true, true);
generate_struct_definition(f_types_impl_, f_types_impl_, tstruct);
generate_struct_fingerprint(f_types_impl_, tstruct, true);
generate_local_reflection(f_types_, tstruct, false);
generate_local_reflection(f_types_impl_, tstruct, true);
generate_local_reflection_pointer(f_types_impl_, tstruct);
std::ofstream& out = (gen_templates_ ? f_types_tcc_ : f_types_impl_);
generate_struct_reader(out, tstruct);
generate_struct_writer(out, tstruct);
generate_struct_swap(f_types_impl_, tstruct);
generate_copy_constructor(f_types_impl_, tstruct, is_exception);
if (gen_moveable_) {
generate_move_constructor(f_types_impl_, tstruct, is_exception);
}
generate_assignment_operator(f_types_impl_, tstruct);
if (gen_moveable_) {
generate_move_assignment_operator(f_types_impl_, tstruct);
}
generate_struct_ostream_operator(f_types_impl_, tstruct);
if (is_exception) {
generate_exception_what_method(f_types_impl_, tstruct);
}
}
| 0 |
[
"CWE-20"
] |
thrift
|
cfaadcc4adcfde2a8232c62ec89870b73ef40df1
| 107,924,497,528,761,570,000,000,000,000,000,000,000 | 25 |
THRIFT-3231 CPP: Limit recursion depth to 64
Client: cpp
Patch: Ben Craig <[email protected]>
|
int ldb_msg_add_steal_value(struct ldb_message *msg,
const char *attr_name,
struct ldb_val *val)
{
int ret;
struct ldb_message_element *el;
ret = ldb_msg_add_value(msg, attr_name, val, &el);
if (ret == LDB_SUCCESS) {
talloc_steal(el->values, val->data);
}
return ret;
}
| 0 |
[
"CWE-200"
] |
samba
|
7efe8182c165fbf17d2f88c173527a7a554e214b
| 304,398,186,243,609,750,000,000,000,000,000,000,000 | 13 |
CVE-2022-32746 ldb: Add flag to mark message element values as shared
When making a shallow copy of an ldb message, mark the message elements
of the copy as sharing their values with the message elements in the
original message.
This flag value will be heeded in the next commit.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009
Signed-off-by: Joseph Sutton <[email protected]>
|
ArgParser::arg128ClearTextMetadata()
{
o.cleartext_metadata = true;
}
| 0 |
[
"CWE-787"
] |
qpdf
|
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
| 175,967,014,497,680,560,000,000,000,000,000,000,000 | 4 |
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.
|
GF_Err vwid_box_size(GF_Box *s)
{
u32 i;
GF_ViewIdentifierBox *ptr = (GF_ViewIdentifierBox *) s;
ptr->size += 3;
for (i=0; i<ptr->num_views; i++) {
ptr->size += 6 + 2 * ptr->views[i].num_ref_views;
}
return GF_OK;
}
| 0 |
[
"CWE-787"
] |
gpac
|
77510778516803b7f7402d7423c6d6bef50254c3
| 21,183,118,859,278,495,000,000,000,000,000,000,000 | 10 |
fixed #2255
|
void tcp_parse_options(const struct net *net,
const struct sk_buff *skb,
struct tcp_options_received *opt_rx, int estab,
struct tcp_fastopen_cookie *foc)
{
const unsigned char *ptr;
const struct tcphdr *th = tcp_hdr(skb);
int length = (th->doff * 4) - sizeof(struct tcphdr);
ptr = (const unsigned char *)(th + 1);
opt_rx->saw_tstamp = 0;
while (length > 0) {
int opcode = *ptr++;
int opsize;
switch (opcode) {
case TCPOPT_EOL:
return;
case TCPOPT_NOP: /* Ref: RFC 793 section 3.1 */
length--;
continue;
default:
if (length < 2)
return;
opsize = *ptr++;
if (opsize < 2) /* "silly options" */
return;
if (opsize > length)
return; /* don't parse partial options */
switch (opcode) {
case TCPOPT_MSS:
if (opsize == TCPOLEN_MSS && th->syn && !estab) {
u16 in_mss = get_unaligned_be16(ptr);
if (in_mss) {
if (opt_rx->user_mss &&
opt_rx->user_mss < in_mss)
in_mss = opt_rx->user_mss;
opt_rx->mss_clamp = in_mss;
}
}
break;
case TCPOPT_WINDOW:
if (opsize == TCPOLEN_WINDOW && th->syn &&
!estab && net->ipv4.sysctl_tcp_window_scaling) {
__u8 snd_wscale = *(__u8 *)ptr;
opt_rx->wscale_ok = 1;
if (snd_wscale > TCP_MAX_WSCALE) {
net_info_ratelimited("%s: Illegal window scaling value %d > %u received\n",
__func__,
snd_wscale,
TCP_MAX_WSCALE);
snd_wscale = TCP_MAX_WSCALE;
}
opt_rx->snd_wscale = snd_wscale;
}
break;
case TCPOPT_TIMESTAMP:
if ((opsize == TCPOLEN_TIMESTAMP) &&
((estab && opt_rx->tstamp_ok) ||
(!estab && net->ipv4.sysctl_tcp_timestamps))) {
opt_rx->saw_tstamp = 1;
opt_rx->rcv_tsval = get_unaligned_be32(ptr);
opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4);
}
break;
case TCPOPT_SACK_PERM:
if (opsize == TCPOLEN_SACK_PERM && th->syn &&
!estab && net->ipv4.sysctl_tcp_sack) {
opt_rx->sack_ok = TCP_SACK_SEEN;
tcp_sack_reset(opt_rx);
}
break;
case TCPOPT_SACK:
if ((opsize >= (TCPOLEN_SACK_BASE + TCPOLEN_SACK_PERBLOCK)) &&
!((opsize - TCPOLEN_SACK_BASE) % TCPOLEN_SACK_PERBLOCK) &&
opt_rx->sack_ok) {
TCP_SKB_CB(skb)->sacked = (ptr - 2) - (unsigned char *)th;
}
break;
#ifdef CONFIG_TCP_MD5SIG
case TCPOPT_MD5SIG:
/*
* The MD5 Hash has already been
* checked (see tcp_v{4,6}_do_rcv()).
*/
break;
#endif
case TCPOPT_FASTOPEN:
tcp_parse_fastopen_option(
opsize - TCPOLEN_FASTOPEN_BASE,
ptr, th->syn, foc, false);
break;
case TCPOPT_EXP:
/* Fast Open option shares code 254 using a
* 16 bits magic number.
*/
if (opsize >= TCPOLEN_EXP_FASTOPEN_BASE &&
get_unaligned_be16(ptr) ==
TCPOPT_FASTOPEN_MAGIC)
tcp_parse_fastopen_option(opsize -
TCPOLEN_EXP_FASTOPEN_BASE,
ptr + 2, th->syn, foc, true);
else
smc_parse_options(th, opt_rx, ptr,
opsize);
break;
}
ptr += opsize-2;
length -= opsize;
}
}
}
| 0 |
[
"CWE-190"
] |
net
|
3b4929f65b0d8249f19a50245cd88ed1a2f78cff
| 114,592,814,690,286,300,000,000,000,000,000,000,000 | 116 |
tcp: limit payload size of sacked skbs
Jonathan Looney reported that TCP can trigger the following crash
in tcp_shifted_skb() :
BUG_ON(tcp_skb_pcount(skb) < pcount);
This can happen if the remote peer has advertized the smallest
MSS that linux TCP accepts : 48
An skb can hold 17 fragments, and each fragment can hold 32KB
on x86, or 64KB on PowerPC.
This means that the 16bit witdh of TCP_SKB_CB(skb)->tcp_gso_segs
can overflow.
Note that tcp_sendmsg() builds skbs with less than 64KB
of payload, so this problem needs SACK to be enabled.
SACK blocks allow TCP to coalesce multiple skbs in the retransmit
queue, thus filling the 17 fragments to maximal capacity.
CVE-2019-11477 -- u16 overflow of TCP_SKB_CB(skb)->tcp_gso_segs
Fixes: 832d11c5cd07 ("tcp: Try to restore large SKBs while SACK processing")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Jonathan Looney <[email protected]>
Acked-by: Neal Cardwell <[email protected]>
Reviewed-by: Tyler Hicks <[email protected]>
Cc: Yuchung Cheng <[email protected]>
Cc: Bruce Curtis <[email protected]>
Cc: Jonathan Lemon <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
|
static struct dentry *proc_map_files_lookup(struct inode *dir,
struct dentry *dentry, unsigned int flags)
{
unsigned long vm_start, vm_end;
struct vm_area_struct *vma;
struct task_struct *task;
int result;
struct mm_struct *mm;
result = -ENOENT;
task = get_proc_task(dir);
if (!task)
goto out;
result = -EACCES;
if (!ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS))
goto out_put_task;
result = -ENOENT;
if (dname_to_vma_addr(dentry, &vm_start, &vm_end))
goto out_put_task;
mm = get_task_mm(task);
if (!mm)
goto out_put_task;
down_read(&mm->mmap_sem);
vma = find_exact_vma(mm, vm_start, vm_end);
if (!vma)
goto out_no_vma;
if (vma->vm_file)
result = proc_map_files_instantiate(dir, dentry, task,
(void *)(unsigned long)vma->vm_file->f_mode);
out_no_vma:
up_read(&mm->mmap_sem);
mmput(mm);
out_put_task:
put_task_struct(task);
out:
return ERR_PTR(result);
}
| 0 |
[
"CWE-362"
] |
linux
|
8148a73c9901a8794a50f950083c00ccf97d43b3
| 2,439,488,399,215,125,200,000,000,000,000,000,000 | 43 |
proc: prevent accessing /proc/<PID>/environ until it's ready
If /proc/<PID>/environ gets read before the envp[] array is fully set up
in create_{aout,elf,elf_fdpic,flat}_tables(), we might end up trying to
read more bytes than are actually written, as env_start will already be
set but env_end will still be zero, making the range calculation
underflow, allowing to read beyond the end of what has been written.
Fix this as it is done for /proc/<PID>/cmdline by testing env_end for
zero. It is, apparently, intentionally set last in create_*_tables().
This bug was found by the PaX size_overflow plugin that detected the
arithmetic underflow of 'this_len = env_end - (env_start + src)' when
env_end is still zero.
The expected consequence is that userland trying to access
/proc/<PID>/environ of a not yet fully set up process may get
inconsistent data as we're in the middle of copying in the environment
variables.
Fixes: https://forums.grsecurity.net/viewtopic.php?f=3&t=4363
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=116461
Signed-off-by: Mathias Krause <[email protected]>
Cc: Emese Revfy <[email protected]>
Cc: Pax Team <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Mateusz Guzik <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: Jarod Wilson <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
{
uint32* cp2;
int32 incr = 2*toskew+w;
(void) y;
fromskew = (fromskew / 2) * 4;
cp2 = cp+w+toskew;
while (h>=2) {
x = w;
do {
uint32 Cb = pp[2];
uint32 Cr = pp[3];
YCbCrtoRGB(cp[0], pp[0]);
YCbCrtoRGB(cp2[0], pp[1]);
cp ++;
cp2 ++;
pp += 4;
} while (--x);
cp += incr;
cp2 += incr;
pp += fromskew;
h-=2;
}
if (h==1) {
x = w;
do {
uint32 Cb = pp[2];
uint32 Cr = pp[3];
YCbCrtoRGB(cp[0], pp[0]);
cp ++;
pp += 4;
} while (--x);
}
}
| 0 |
[
"CWE-119"
] |
libtiff
|
40a5955cbf0df62b1f9e9bd7d9657b0070725d19
| 67,009,375,730,607,450,000,000,000,000,000,000,000 | 34 |
* libtiff/tif_next.c: add new tests to check that we don't read outside of
the compressed input stream buffer.
* libtiff/tif_getimage.c: in OJPEG case, fix checks on strile width/height
|
static void shmem_deswap_pagevec(struct pagevec *pvec)
{
int i, j;
for (i = 0, j = 0; i < pagevec_count(pvec); i++) {
struct page *page = pvec->pages[i];
if (!radix_tree_exceptional_entry(page))
pvec->pages[j++] = page;
}
pvec->nr = j;
}
| 0 |
[
"CWE-399"
] |
linux
|
5f00110f7273f9ff04ac69a5f85bb535a4fd0987
| 40,365,153,766,010,256,000,000,000,000,000,000,000 | 11 |
tmpfs: fix use-after-free of mempolicy object
The tmpfs remount logic preserves filesystem mempolicy if the mpol=M
option is not specified in the remount request. A new policy can be
specified if mpol=M is given.
Before this patch remounting an mpol bound tmpfs without specifying
mpol= mount option in the remount request would set the filesystem's
mempolicy object to a freed mempolicy object.
To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run:
# mkdir /tmp/x
# mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0
# mount -o remount,size=200M nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0
# note ? garbage in mpol=... output above
# dd if=/dev/zero of=/tmp/x/f count=1
# panic here
Panic:
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [< (null)>] (null)
[...]
Oops: 0010 [#1] SMP DEBUG_PAGEALLOC
Call Trace:
mpol_shared_policy_init+0xa5/0x160
shmem_get_inode+0x209/0x270
shmem_mknod+0x3e/0xf0
shmem_create+0x18/0x20
vfs_create+0xb5/0x130
do_last+0x9a1/0xea0
path_openat+0xb3/0x4d0
do_filp_open+0x42/0xa0
do_sys_open+0xfe/0x1e0
compat_sys_open+0x1b/0x20
cstar_dispatch+0x7/0x1f
Non-debug kernels will not crash immediately because referencing the
dangling mpol will not cause a fault. Instead the filesystem will
reference a freed mempolicy object, which will cause unpredictable
behavior.
The problem boils down to a dropped mpol reference below if
shmem_parse_options() does not allocate a new mpol:
config = *sbinfo
shmem_parse_options(data, &config, true)
mpol_put(sbinfo->mpol)
sbinfo->mpol = config.mpol /* BUG: saves unreferenced mpol */
This patch avoids the crash by not releasing the mempolicy if
shmem_parse_options() doesn't create a new mpol.
How far back does this issue go? I see it in both 2.6.36 and 3.3. I did
not look back further.
Signed-off-by: Greg Thelen <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
|
ex_retab(exarg_T *eap)
{
linenr_T lnum;
int got_tab = FALSE;
long num_spaces = 0;
long num_tabs;
long len;
long col;
long vcol;
long start_col = 0; // For start of white-space string
long start_vcol = 0; // For start of white-space string
long old_len;
char_u *ptr;
char_u *new_line = (char_u *)1; // init to non-NULL
int did_undo; // called u_save for current line
#ifdef FEAT_VARTABS
int *new_vts_array = NULL;
char_u *new_ts_str; // string value of tab argument
#else
int temp;
int new_ts;
#endif
int save_list;
linenr_T first_line = 0; // first changed line
linenr_T last_line = 0; // last changed line
save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here
#ifdef FEAT_VARTABS
new_ts_str = eap->arg;
if (tabstop_set(eap->arg, &new_vts_array) == FAIL)
return;
while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')
++(eap->arg);
// This ensures that either new_vts_array and new_ts_str are freshly
// allocated, or new_vts_array points to an existing array and new_ts_str
// is null.
if (new_vts_array == NULL)
{
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL;
}
else
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
#else
ptr = eap->arg;
new_ts = getdigits(&ptr);
if (new_ts < 0 && *eap->arg == '-')
{
emsg(_(e_argument_must_be_positive));
return;
}
if (new_ts < 0 || new_ts > TABSTOP_MAX)
{
semsg(_(e_invalid_argument_str), eap->arg);
return;
}
if (new_ts == 0)
new_ts = curbuf->b_p_ts;
#endif
for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)
{
ptr = ml_get(lnum);
col = 0;
vcol = 0;
did_undo = FALSE;
for (;;)
{
if (VIM_ISWHITE(ptr[col]))
{
if (!got_tab && num_spaces == 0)
{
// First consecutive white-space
start_vcol = vcol;
start_col = col;
}
if (ptr[col] == ' ')
num_spaces++;
else
got_tab = TRUE;
}
else
{
if (got_tab || (eap->forceit && num_spaces > 1))
{
// Retabulate this string of white-space
// len is virtual length of white string
len = num_spaces = vcol - start_vcol;
num_tabs = 0;
if (!curbuf->b_p_et)
{
#ifdef FEAT_VARTABS
int t, s;
tabstop_fromto(start_vcol, vcol,
curbuf->b_p_ts, new_vts_array, &t, &s);
num_tabs = t;
num_spaces = s;
#else
temp = new_ts - (start_vcol % new_ts);
if (num_spaces >= temp)
{
num_spaces -= temp;
num_tabs++;
}
num_tabs += num_spaces / new_ts;
num_spaces -= (num_spaces / new_ts) * new_ts;
#endif
}
if (curbuf->b_p_et || got_tab ||
(num_spaces + num_tabs < len))
{
if (did_undo == FALSE)
{
did_undo = TRUE;
if (u_save((linenr_T)(lnum - 1),
(linenr_T)(lnum + 1)) == FAIL)
{
new_line = NULL; // flag out-of-memory
break;
}
}
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
new_line = alloc(old_len - col + start_col + len + 1);
if (new_line == NULL)
break;
if (start_col > 0)
mch_memmove(new_line, ptr, (size_t)start_col);
mch_memmove(new_line + start_col + len,
ptr + col, (size_t)(old_len - col + 1));
ptr = new_line + start_col;
for (col = 0; col < len; col++)
ptr[col] = (col < num_tabs) ? '\t' : ' ';
if (ml_replace(lnum, new_line, FALSE) == OK)
// "new_line" may have been copied
new_line = curbuf->b_ml.ml_line_ptr;
if (first_line == 0)
first_line = lnum;
last_line = lnum;
ptr = new_line;
col = start_col + len;
}
}
got_tab = FALSE;
num_spaces = 0;
}
if (ptr[col] == NUL)
break;
vcol += chartabsize(ptr + col, (colnr_T)vcol);
if (vcol >= MAXCOL)
{
emsg(_(e_resulting_text_too_long));
break;
}
if (has_mbyte)
col += (*mb_ptr2len)(ptr + col);
else
++col;
}
if (new_line == NULL) // out of memory
break;
line_breakcheck();
}
if (got_int)
emsg(_(e_interrupted));
#ifdef FEAT_VARTABS
// If a single value was given then it can be considered equal to
// either the value of 'tabstop' or the value of 'vartabstop'.
if (tabstop_count(curbuf->b_p_vts_array) == 0
&& tabstop_count(new_vts_array) == 1
&& curbuf->b_p_ts == tabstop_first(new_vts_array))
; // not changed
else if (tabstop_count(curbuf->b_p_vts_array) > 0
&& tabstop_eq(curbuf->b_p_vts_array, new_vts_array))
; // not changed
else
redraw_curbuf_later(NOT_VALID);
#else
if (curbuf->b_p_ts != new_ts)
redraw_curbuf_later(NOT_VALID);
#endif
if (first_line != 0)
changed_lines(first_line, 0, last_line + 1, 0L);
curwin->w_p_list = save_list; // restore 'list'
#ifdef FEAT_VARTABS
if (new_ts_str != NULL) // set the new tabstop
{
// If 'vartabstop' is in use or if the value given to retab has more
// than one tabstop then update 'vartabstop'.
int *old_vts_ary = curbuf->b_p_vts_array;
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)
{
set_string_option_direct((char_u *)"vts", -1, new_ts_str,
OPT_FREE|OPT_LOCAL, 0);
curbuf->b_p_vts_array = new_vts_array;
vim_free(old_vts_ary);
}
else
{
// 'vartabstop' wasn't in use and a single value was given to
// retab then update 'tabstop'.
curbuf->b_p_ts = tabstop_first(new_vts_array);
vim_free(new_vts_array);
}
vim_free(new_ts_str);
}
#else
curbuf->b_p_ts = new_ts;
#endif
coladvance(curwin->w_curswant);
u_clearline();
}
| 0 |
[
"CWE-787"
] |
vim
|
6e28703a8e41f775f64e442c5d11ce1ff599aa3f
| 56,713,402,521,042,720,000,000,000,000,000,000,000 | 223 |
patch 8.2.4359: crash when repeatedly using :retab
Problem: crash when repeatedly using :retab.
Solution: Bail out when the line is getting too long.
|
static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
struct iocb *iocb, bool compat)
{
struct kiocb *req;
ssize_t ret;
/* enforce forwards compatibility on users */
if (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2)) {
pr_debug("EINVAL: reserve field set\n");
return -EINVAL;
}
/* prevent overflows */
if (unlikely(
(iocb->aio_buf != (unsigned long)iocb->aio_buf) ||
(iocb->aio_nbytes != (size_t)iocb->aio_nbytes) ||
((ssize_t)iocb->aio_nbytes < 0)
)) {
pr_debug("EINVAL: io_submit: overflow check\n");
return -EINVAL;
}
req = aio_get_req(ctx);
if (unlikely(!req))
return -EAGAIN;
req->ki_filp = fget(iocb->aio_fildes);
if (unlikely(!req->ki_filp)) {
ret = -EBADF;
goto out_put_req;
}
if (iocb->aio_flags & IOCB_FLAG_RESFD) {
/*
* If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
* instance of the file* now. The file descriptor must be
* an eventfd() fd, and will be signaled for each completed
* event using the eventfd_signal() function.
*/
req->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd);
if (IS_ERR(req->ki_eventfd)) {
ret = PTR_ERR(req->ki_eventfd);
req->ki_eventfd = NULL;
goto out_put_req;
}
}
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
if (unlikely(ret)) {
pr_debug("EFAULT: aio_key\n");
goto out_put_req;
}
req->ki_obj.user = user_iocb;
req->ki_user_data = iocb->aio_data;
req->ki_pos = iocb->aio_offset;
req->ki_nbytes = iocb->aio_nbytes;
ret = aio_run_iocb(req, iocb->aio_lio_opcode,
(char __user *)(unsigned long)iocb->aio_buf,
compat);
if (ret)
goto out_put_req;
return 0;
out_put_req:
put_reqs_available(ctx, 1);
percpu_ref_put(&ctx->reqs);
kiocb_free(req);
return ret;
}
| 0 |
[
"CWE-399"
] |
linux
|
d558023207e008a4476a3b7bb8706b2a2bf5d84f
| 81,297,729,706,668,290,000,000,000,000,000,000,000 | 71 |
aio: prevent double free in ioctx_alloc
ioctx_alloc() calls aio_setup_ring() to allocate a ring. If aio_setup_ring()
fails to do so it would call aio_free_ring() before returning, but
ioctx_alloc() would call aio_free_ring() again causing a double free of
the ring.
This is easily reproducible from userspace.
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Benjamin LaHaise <[email protected]>
|
static void init_settings(nghttp2_settings_storage *settings) {
settings->header_table_size = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
settings->enable_push = 1;
settings->max_concurrent_streams = NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS;
settings->initial_window_size = NGHTTP2_INITIAL_WINDOW_SIZE;
settings->max_frame_size = NGHTTP2_MAX_FRAME_SIZE_MIN;
settings->max_header_list_size = UINT32_MAX;
}
| 0 |
[] |
nghttp2
|
0a6ce87c22c69438ecbffe52a2859c3a32f1620f
| 95,073,322,561,875,800,000,000,000,000,000,000,000 | 8 |
Add nghttp2_option_set_max_outbound_ack
|
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.