idx
int64 | project
string | commit_id
string | project_url
string | commit_url
string | commit_message
string | target
int64 | func
string | func_hash
string | file_name
string | file_hash
string | cwe
string | cve
string | cve_desc
string | nvd_url
string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
201,913
|
libarchive
|
e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b
|
https://github.com/libarchive/libarchive
|
https://github.com/libarchive/libarchive/commit/e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b
|
Never follow symlinks when setting file flags on Linux
When opening a file descriptor to set file flags on linux, ensure
no symbolic links are followed. This fixes the case when an archive
contains a directory entry followed by a symlink entry with the same
path. The fixup code would modify file flags of the symlink target.
| 1
|
set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
mode_t mode, unsigned long set, unsigned long clear)
{
int ret;
int myfd = fd;
int newflags, oldflags;
/*
* Linux has no define for the flags that are only settable by
* the root user. This code may seem a little complex, but
* there seem to be some Linux systems that lack these
* defines. (?) The code below degrades reasonably gracefully
* if sf_mask is incomplete.
*/
const int sf_mask = 0
#if defined(FS_IMMUTABLE_FL)
| FS_IMMUTABLE_FL
#elif defined(EXT2_IMMUTABLE_FL)
| EXT2_IMMUTABLE_FL
#endif
#if defined(FS_APPEND_FL)
| FS_APPEND_FL
#elif defined(EXT2_APPEND_FL)
| EXT2_APPEND_FL
#endif
#if defined(FS_JOURNAL_DATA_FL)
| FS_JOURNAL_DATA_FL
#endif
;
if (set == 0 && clear == 0)
return (ARCHIVE_OK);
/* Only regular files and dirs can have flags. */
if (!S_ISREG(mode) && !S_ISDIR(mode))
return (ARCHIVE_OK);
/* If we weren't given an fd, open it ourselves. */
if (myfd < 0) {
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY | O_CLOEXEC);
__archive_ensure_cloexec_flag(myfd);
}
if (myfd < 0)
return (ARCHIVE_OK);
/*
* XXX As above, this would be way simpler if we didn't have
* to read the current flags from disk. XXX
*/
ret = ARCHIVE_OK;
/* Read the current file flags. */
if (ioctl(myfd,
#ifdef FS_IOC_GETFLAGS
FS_IOC_GETFLAGS,
#else
EXT2_IOC_GETFLAGS,
#endif
&oldflags) < 0)
goto fail;
/* Try setting the flags as given. */
newflags = (oldflags & ~clear) | set;
if (ioctl(myfd,
#ifdef FS_IOC_SETFLAGS
FS_IOC_SETFLAGS,
#else
EXT2_IOC_SETFLAGS,
#endif
&newflags) >= 0)
goto cleanup;
if (errno != EPERM)
goto fail;
/* If we couldn't set all the flags, try again with a subset. */
newflags &= ~sf_mask;
oldflags &= sf_mask;
newflags |= oldflags;
if (ioctl(myfd,
#ifdef FS_IOC_SETFLAGS
FS_IOC_SETFLAGS,
#else
EXT2_IOC_SETFLAGS,
#endif
&newflags) >= 0)
goto cleanup;
/* We couldn't set the flags, so report the failure. */
fail:
archive_set_error(&a->archive, errno,
"Failed to set file flags");
ret = ARCHIVE_WARN;
cleanup:
if (fd < 0)
close(myfd);
return (ret);
}
|
23055553245958282946404395843765567799
|
None
|
CWE-59
|
CVE-2021-31566
|
An improper link resolution flaw can occur while extracting an archive leading to changing modes, times, access control lists, and flags of a file outside of the archive. An attacker may provide a malicious archive to a victim user, who would trigger this flaw when trying to extract the archive. A local attacker may use this flaw to gain more privileges in a system.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-31566
|
|
326,629
|
libarchive
|
e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b
|
https://github.com/libarchive/libarchive
|
https://github.com/libarchive/libarchive/commit/e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b
|
Never follow symlinks when setting file flags on Linux
When opening a file descriptor to set file flags on linux, ensure
no symbolic links are followed. This fixes the case when an archive
contains a directory entry followed by a symlink entry with the same
path. The fixup code would modify file flags of the symlink target.
| 0
|
set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
mode_t mode, unsigned long set, unsigned long clear)
{
int ret;
int myfd = fd;
int newflags, oldflags;
/*
* Linux has no define for the flags that are only settable by
* the root user. This code may seem a little complex, but
* there seem to be some Linux systems that lack these
* defines. (?) The code below degrades reasonably gracefully
* if sf_mask is incomplete.
*/
const int sf_mask = 0
#if defined(FS_IMMUTABLE_FL)
| FS_IMMUTABLE_FL
#elif defined(EXT2_IMMUTABLE_FL)
| EXT2_IMMUTABLE_FL
#endif
#if defined(FS_APPEND_FL)
| FS_APPEND_FL
#elif defined(EXT2_APPEND_FL)
| EXT2_APPEND_FL
#endif
#if defined(FS_JOURNAL_DATA_FL)
| FS_JOURNAL_DATA_FL
#endif
;
if (set == 0 && clear == 0)
return (ARCHIVE_OK);
/* Only regular files and dirs can have flags. */
if (!S_ISREG(mode) && !S_ISDIR(mode))
return (ARCHIVE_OK);
/* If we weren't given an fd, open it ourselves. */
if (myfd < 0) {
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY |
O_CLOEXEC | O_NOFOLLOW);
__archive_ensure_cloexec_flag(myfd);
}
if (myfd < 0)
return (ARCHIVE_OK);
/*
* XXX As above, this would be way simpler if we didn't have
* to read the current flags from disk. XXX
*/
ret = ARCHIVE_OK;
/* Read the current file flags. */
if (ioctl(myfd,
#ifdef FS_IOC_GETFLAGS
FS_IOC_GETFLAGS,
#else
EXT2_IOC_GETFLAGS,
#endif
&oldflags) < 0)
goto fail;
/* Try setting the flags as given. */
newflags = (oldflags & ~clear) | set;
if (ioctl(myfd,
#ifdef FS_IOC_SETFLAGS
FS_IOC_SETFLAGS,
#else
EXT2_IOC_SETFLAGS,
#endif
&newflags) >= 0)
goto cleanup;
if (errno != EPERM)
goto fail;
/* If we couldn't set all the flags, try again with a subset. */
newflags &= ~sf_mask;
oldflags &= sf_mask;
newflags |= oldflags;
if (ioctl(myfd,
#ifdef FS_IOC_SETFLAGS
FS_IOC_SETFLAGS,
#else
EXT2_IOC_SETFLAGS,
#endif
&newflags) >= 0)
goto cleanup;
/* We couldn't set the flags, so report the failure. */
fail:
archive_set_error(&a->archive, errno,
"Failed to set file flags");
ret = ARCHIVE_WARN;
cleanup:
if (fd < 0)
close(myfd);
return (ret);
}
|
157089393893012994634493859286178863768
|
None
|
CWE-59
|
CVE-2021-31566
|
An improper link resolution flaw can occur while extracting an archive leading to changing modes, times, access control lists, and flags of a file outside of the archive. An attacker may provide a malicious archive to a victim user, who would trigger this flaw when trying to extract the archive. A local attacker may use this flaw to gain more privileges in a system.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-31566
|
|
201,925
|
linux
|
e6a21a14106d9718aa4f8e115b1e474888eeba44
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.19-rc2&id=e6a21a14106d9718aa4f8e115b1e474888eeba44
|
media: vidtv: Check for null return of vzalloc
As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it in order
to guarantee the success of the initialization.
If fails, we need to free not only 'e' but also 'e->name'.
Also, if the allocation for ctx fails, we need to free 'e->encoder_buf'
else.
Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
| 1
|
*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)
{
u32 priv_sz = sizeof(struct vidtv_s302m_ctx);
struct vidtv_s302m_ctx *ctx;
struct vidtv_encoder *e;
e = kzalloc(sizeof(*e), GFP_KERNEL);
if (!e)
return NULL;
e->id = S302M;
if (args.name)
e->name = kstrdup(args.name, GFP_KERNEL);
e->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);
e->encoder_buf_sz = VIDTV_S302M_BUF_SZ;
e->encoder_buf_offset = 0;
e->sample_count = 0;
e->src_buf = (args.src_buf) ? args.src_buf : NULL;
e->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0;
e->src_buf_offset = 0;
e->is_video_encoder = false;
ctx = kzalloc(priv_sz, GFP_KERNEL);
if (!ctx) {
kfree(e);
return NULL;
}
e->ctx = ctx;
ctx->last_duration = 0;
e->encode = vidtv_s302m_encode;
e->clear = vidtv_s302m_clear;
e->es_pid = cpu_to_be16(args.es_pid);
e->stream_id = cpu_to_be16(PES_PRIVATE_STREAM_1);
e->sync = args.sync;
e->sampling_rate_hz = S302M_SAMPLING_RATE_HZ;
e->last_sample_cb = args.last_sample_cb;
e->destroy = vidtv_s302m_encoder_destroy;
if (args.head) {
while (args.head->next)
args.head = args.head->next;
args.head->next = e;
}
e->next = NULL;
return e;
}
|
307197700459438224437569031592965319191
|
vidtv_s302m.c
|
175282066138932855398445510418968204882
|
CWE-476
|
CVE-2022-3078
|
An issue was discovered in the Linux kernel through 5.16-rc6. There is a lack of check after calling vzalloc() and lack of free after allocation in drivers/media/test-drivers/vidtv/vidtv_s302m.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3078
|
326,914
|
linux
|
e6a21a14106d9718aa4f8e115b1e474888eeba44
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.19-rc2&id=e6a21a14106d9718aa4f8e115b1e474888eeba44
|
media: vidtv: Check for null return of vzalloc
As the possible failure of the vzalloc(), e->encoder_buf might be NULL.
Therefore, it should be better to check it in order
to guarantee the success of the initialization.
If fails, we need to free not only 'e' but also 'e->name'.
Also, if the allocation for ctx fails, we need to free 'e->encoder_buf'
else.
Fixes: f90cf6079bf6 ("media: vidtv: add a bridge driver")
Signed-off-by: Jiasheng Jiang <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
| 0
|
*vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args)
{
u32 priv_sz = sizeof(struct vidtv_s302m_ctx);
struct vidtv_s302m_ctx *ctx;
struct vidtv_encoder *e;
e = kzalloc(sizeof(*e), GFP_KERNEL);
if (!e)
return NULL;
e->id = S302M;
if (args.name)
e->name = kstrdup(args.name, GFP_KERNEL);
e->encoder_buf = vzalloc(VIDTV_S302M_BUF_SZ);
if (!e->encoder_buf)
goto out_kfree_e;
e->encoder_buf_sz = VIDTV_S302M_BUF_SZ;
e->encoder_buf_offset = 0;
e->sample_count = 0;
e->src_buf = (args.src_buf) ? args.src_buf : NULL;
e->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0;
e->src_buf_offset = 0;
e->is_video_encoder = false;
ctx = kzalloc(priv_sz, GFP_KERNEL);
if (!ctx)
goto out_kfree_buf;
e->ctx = ctx;
ctx->last_duration = 0;
e->encode = vidtv_s302m_encode;
e->clear = vidtv_s302m_clear;
e->es_pid = cpu_to_be16(args.es_pid);
e->stream_id = cpu_to_be16(PES_PRIVATE_STREAM_1);
e->sync = args.sync;
e->sampling_rate_hz = S302M_SAMPLING_RATE_HZ;
e->last_sample_cb = args.last_sample_cb;
e->destroy = vidtv_s302m_encoder_destroy;
if (args.head) {
while (args.head->next)
args.head = args.head->next;
args.head->next = e;
}
e->next = NULL;
return e;
out_kfree_buf:
kfree(e->encoder_buf);
out_kfree_e:
kfree(e->name);
kfree(e);
return NULL;
}
|
87669194077051159663465560005531170449
|
vidtv_s302m.c
|
52146840416955452550200941985312251483
|
CWE-476
|
CVE-2022-3078
|
An issue was discovered in the Linux kernel through 5.16-rc6. There is a lack of check after calling vzalloc() and lack of free after allocation in drivers/media/test-drivers/vidtv/vidtv_s302m.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3078
|
202,081
|
vim
|
d25f003342aca9889067f2e839963dfeccf1fe05
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/d25f003342aca9889067f2e839963dfeccf1fe05
|
patch 9.0.0011: reading beyond the end of the line with put command
Problem: Reading beyond the end of the line with put command.
Solution: Adjust the end mark position.
| 1
|
do_put(
int regname,
char_u *expr_result, // result for regname "=" when compiled
int dir, // BACKWARD for 'P', FORWARD for 'p'
long count,
int flags)
{
char_u *ptr;
char_u *newp, *oldp;
int yanklen;
int totlen = 0; // init for gcc
linenr_T lnum;
colnr_T col;
long i; // index in y_array[]
int y_type;
long y_size;
int oldlen;
long y_width = 0;
colnr_T vcol;
int delcount;
int incr = 0;
long j;
struct block_def bd;
char_u **y_array = NULL;
yankreg_T *y_current_used = NULL;
long nr_lines = 0;
pos_T new_cursor;
int indent;
int orig_indent = 0; // init for gcc
int indent_diff = 0; // init for gcc
int first_indent = TRUE;
int lendiff = 0;
pos_T old_pos;
char_u *insert_string = NULL;
int allocated = FALSE;
long cnt;
pos_T orig_start = curbuf->b_op_start;
pos_T orig_end = curbuf->b_op_end;
unsigned int cur_ve_flags = get_ve_flags();
#ifdef FEAT_CLIPBOARD
// Adjust register name for "unnamed" in 'clipboard'.
adjust_clip_reg(®name);
(void)may_get_selection(regname);
#endif
if (flags & PUT_FIXINDENT)
orig_indent = get_indent();
curbuf->b_op_start = curwin->w_cursor; // default for '[ mark
curbuf->b_op_end = curwin->w_cursor; // default for '] mark
// Using inserted text works differently, because the register includes
// special characters (newlines, etc.).
if (regname == '.')
{
if (VIsual_active)
stuffcharReadbuff(VIsual_mode);
(void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') :
(count == -1 ? 'O' : 'i')), count, FALSE);
// Putting the text is done later, so can't really move the cursor to
// the next character. Use "l" to simulate it.
if ((flags & PUT_CURSEND) && gchar_cursor() != NUL)
stuffcharReadbuff('l');
return;
}
// For special registers '%' (file name), '#' (alternate file name) and
// ':' (last command line), etc. we have to create a fake yank register.
// For compiled code "expr_result" holds the expression result.
if (regname == '=' && expr_result != NULL)
insert_string = expr_result;
else if (get_spec_reg(regname, &insert_string, &allocated, TRUE)
&& insert_string == NULL)
return;
// Autocommands may be executed when saving lines for undo. This might
// make "y_array" invalid, so we start undo now to avoid that.
if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL)
goto end;
if (insert_string != NULL)
{
y_type = MCHAR;
#ifdef FEAT_EVAL
if (regname == '=')
{
// For the = register we need to split the string at NL
// characters.
// Loop twice: count the number of lines and save them.
for (;;)
{
y_size = 0;
ptr = insert_string;
while (ptr != NULL)
{
if (y_array != NULL)
y_array[y_size] = ptr;
++y_size;
ptr = vim_strchr(ptr, '\n');
if (ptr != NULL)
{
if (y_array != NULL)
*ptr = NUL;
++ptr;
// A trailing '\n' makes the register linewise.
if (*ptr == NUL)
{
y_type = MLINE;
break;
}
}
}
if (y_array != NULL)
break;
y_array = ALLOC_MULT(char_u *, y_size);
if (y_array == NULL)
goto end;
}
}
else
#endif
{
y_size = 1; // use fake one-line yank register
y_array = &insert_string;
}
}
else
{
get_yank_register(regname, FALSE);
y_type = y_current->y_type;
y_width = y_current->y_width;
y_size = y_current->y_size;
y_array = y_current->y_array;
y_current_used = y_current;
}
if (y_type == MLINE)
{
if (flags & PUT_LINE_SPLIT)
{
char_u *p;
// "p" or "P" in Visual mode: split the lines to put the text in
// between.
if (u_save_cursor() == FAIL)
goto end;
p = ml_get_cursor();
if (dir == FORWARD && *p != NUL)
MB_PTR_ADV(p);
ptr = vim_strsave(p);
if (ptr == NULL)
goto end;
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
vim_free(ptr);
oldp = ml_get_curline();
p = oldp + curwin->w_cursor.col;
if (dir == FORWARD && *p != NUL)
MB_PTR_ADV(p);
ptr = vim_strnsave(oldp, p - oldp);
if (ptr == NULL)
goto end;
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
++nr_lines;
dir = FORWARD;
}
if (flags & PUT_LINE_FORWARD)
{
// Must be "p" for a Visual block, put lines below the block.
curwin->w_cursor = curbuf->b_visual.vi_end;
dir = FORWARD;
}
curbuf->b_op_start = curwin->w_cursor; // default for '[ mark
curbuf->b_op_end = curwin->w_cursor; // default for '] mark
}
if (flags & PUT_LINE) // :put command or "p" in Visual line mode.
y_type = MLINE;
if (y_size == 0 || y_array == NULL)
{
semsg(_(e_nothing_in_register_str),
regname == 0 ? (char_u *)"\"" : transchar(regname));
goto end;
}
if (y_type == MBLOCK)
{
lnum = curwin->w_cursor.lnum + y_size + 1;
if (lnum > curbuf->b_ml.ml_line_count)
lnum = curbuf->b_ml.ml_line_count + 1;
if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)
goto end;
}
else if (y_type == MLINE)
{
lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
// Correct line number for closed fold. Don't move the cursor yet,
// u_save() uses it.
if (dir == BACKWARD)
(void)hasFolding(lnum, &lnum, NULL);
else
(void)hasFolding(lnum, NULL, &lnum);
#endif
if (dir == FORWARD)
++lnum;
// In an empty buffer the empty line is going to be replaced, include
// it in the saved lines.
if ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL)
goto end;
#ifdef FEAT_FOLDING
if (dir == FORWARD)
curwin->w_cursor.lnum = lnum - 1;
else
curwin->w_cursor.lnum = lnum;
curbuf->b_op_start = curwin->w_cursor; // for mark_adjust()
#endif
}
else if (u_save_cursor() == FAIL)
goto end;
yanklen = (int)STRLEN(y_array[0]);
if (cur_ve_flags == VE_ALL && y_type == MCHAR)
{
if (gchar_cursor() == TAB)
{
int viscol = getviscol();
int ts = curbuf->b_p_ts;
// Don't need to insert spaces when "p" on the last position of a
// tab or "P" on the first position.
if (dir == FORWARD ?
#ifdef FEAT_VARTABS
tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1
#else
ts - (viscol % ts) != 1
#endif
: curwin->w_cursor.coladd > 0)
coladvance_force(viscol);
else
curwin->w_cursor.coladd = 0;
}
else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)
coladvance_force(getviscol() + (dir == FORWARD));
}
lnum = curwin->w_cursor.lnum;
col = curwin->w_cursor.col;
// Block mode
if (y_type == MBLOCK)
{
int c = gchar_cursor();
colnr_T endcol2 = 0;
if (dir == FORWARD && c != NUL)
{
if (cur_ve_flags == VE_ALL)
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
else
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
if (has_mbyte)
// move to start of next multi-byte character
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else
if (c != TAB || cur_ve_flags != VE_ALL)
++curwin->w_cursor.col;
++col;
}
else
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
col += curwin->w_cursor.coladd;
if (cur_ve_flags == VE_ALL
&& (curwin->w_cursor.coladd > 0
|| endcol2 == curwin->w_cursor.col))
{
if (dir == FORWARD && c == NUL)
++col;
if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0)
++curwin->w_cursor.col;
if (c == TAB)
{
if (dir == BACKWARD && curwin->w_cursor.col)
curwin->w_cursor.col--;
if (dir == FORWARD && col - 1 == endcol2)
curwin->w_cursor.col++;
}
}
curwin->w_cursor.coladd = 0;
bd.textcol = 0;
for (i = 0; i < y_size; ++i)
{
int spaces = 0;
char shortline;
bd.startspaces = 0;
bd.endspaces = 0;
vcol = 0;
delcount = 0;
// add a new line
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
{
if (ml_append(curbuf->b_ml.ml_line_count, (char_u *)"",
(colnr_T)1, FALSE) == FAIL)
break;
++nr_lines;
}
// get the old line and advance to the position to insert at
oldp = ml_get_curline();
oldlen = (int)STRLEN(oldp);
for (ptr = oldp; vcol < col && *ptr; )
{
// Count a tab for what it's worth (if list mode not on)
incr = lbr_chartabsize_adv(oldp, &ptr, vcol);
vcol += incr;
}
bd.textcol = (colnr_T)(ptr - oldp);
shortline = (vcol < col) || (vcol == col && !*ptr) ;
if (vcol < col) // line too short, padd with spaces
bd.startspaces = col - vcol;
else if (vcol > col)
{
bd.endspaces = vcol - col;
bd.startspaces = incr - bd.endspaces;
--bd.textcol;
delcount = 1;
if (has_mbyte)
bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);
if (oldp[bd.textcol] != TAB)
{
// Only a Tab can be split into spaces. Other
// characters will have to be moved to after the
// block, causing misalignment.
delcount = 0;
bd.endspaces = 0;
}
}
yanklen = (int)STRLEN(y_array[i]);
if ((flags & PUT_BLOCK_INNER) == 0)
{
// calculate number of spaces required to fill right side of
// block
spaces = y_width + 1;
for (j = 0; j < yanklen; j++)
spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
if (spaces < 0)
spaces = 0;
}
// Insert the new text.
// First check for multiplication overflow.
if (yanklen + spaces != 0
&& count > ((INT_MAX - (bd.startspaces + bd.endspaces))
/ (yanklen + spaces)))
{
emsg(_(e_resulting_text_too_long));
break;
}
totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;
newp = alloc(totlen + oldlen + 1);
if (newp == NULL)
break;
// copy part up to cursor to new line
ptr = newp;
mch_memmove(ptr, oldp, (size_t)bd.textcol);
ptr += bd.textcol;
// may insert some spaces before the new text
vim_memset(ptr, ' ', (size_t)bd.startspaces);
ptr += bd.startspaces;
// insert the new text
for (j = 0; j < count; ++j)
{
mch_memmove(ptr, y_array[i], (size_t)yanklen);
ptr += yanklen;
// insert block's trailing spaces only if there's text behind
if ((j < count - 1 || !shortline) && spaces)
{
vim_memset(ptr, ' ', (size_t)spaces);
ptr += spaces;
}
}
// may insert some spaces after the new text
vim_memset(ptr, ' ', (size_t)bd.endspaces);
ptr += bd.endspaces;
// move the text after the cursor to the end of the line.
mch_memmove(ptr, oldp + bd.textcol + delcount,
(size_t)(oldlen - bd.textcol - delcount + 1));
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
++curwin->w_cursor.lnum;
if (i == 0)
curwin->w_cursor.col += bd.startspaces;
}
changed_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines);
// Set '[ mark.
curbuf->b_op_start = curwin->w_cursor;
curbuf->b_op_start.lnum = lnum;
// adjust '] mark
curbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;
curbuf->b_op_end.col = bd.textcol + totlen - 1;
curbuf->b_op_end.coladd = 0;
if (flags & PUT_CURSEND)
{
colnr_T len;
curwin->w_cursor = curbuf->b_op_end;
curwin->w_cursor.col++;
// in Insert mode we might be after the NUL, correct for that
len = (colnr_T)STRLEN(ml_get_curline());
if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len;
}
else
curwin->w_cursor.lnum = lnum;
}
else
{
// Character or Line mode
if (y_type == MCHAR)
{
// if type is MCHAR, FORWARD is the same as BACKWARD on the next
// char
if (dir == FORWARD && gchar_cursor() != NUL)
{
if (has_mbyte)
{
int bytelen = (*mb_ptr2len)(ml_get_cursor());
// put it on the next of the multi-byte character.
col += bytelen;
if (yanklen)
{
curwin->w_cursor.col += bytelen;
curbuf->b_op_end.col += bytelen;
}
}
else
{
++col;
if (yanklen)
{
++curwin->w_cursor.col;
++curbuf->b_op_end.col;
}
}
}
curbuf->b_op_start = curwin->w_cursor;
}
// Line mode: BACKWARD is the same as FORWARD on the previous line
else if (dir == BACKWARD)
--lnum;
new_cursor = curwin->w_cursor;
// simple case: insert into one line at a time
if (y_type == MCHAR && y_size == 1)
{
linenr_T end_lnum = 0; // init for gcc
linenr_T start_lnum = lnum;
int first_byte_off = 0;
if (VIsual_active)
{
end_lnum = curbuf->b_visual.vi_end.lnum;
if (end_lnum < curbuf->b_visual.vi_start.lnum)
end_lnum = curbuf->b_visual.vi_start.lnum;
if (end_lnum > start_lnum)
{
pos_T pos;
// "col" is valid for the first line, in following lines
// the virtual column needs to be used. Matters for
// multi-byte characters.
pos.lnum = lnum;
pos.col = col;
pos.coladd = 0;
getvcol(curwin, &pos, NULL, &vcol, NULL);
}
}
if (count == 0 || yanklen == 0)
{
if (VIsual_active)
lnum = end_lnum;
}
else if (count > INT_MAX / yanklen)
// multiplication overflow
emsg(_(e_resulting_text_too_long));
else
{
totlen = count * yanklen;
do {
oldp = ml_get(lnum);
oldlen = (int)STRLEN(oldp);
if (lnum > start_lnum)
{
pos_T pos;
pos.lnum = lnum;
if (getvpos(&pos, vcol) == OK)
col = pos.col;
else
col = MAXCOL;
}
if (VIsual_active && col > oldlen)
{
lnum++;
continue;
}
newp = alloc(totlen + oldlen + 1);
if (newp == NULL)
goto end; // alloc() gave an error message
mch_memmove(newp, oldp, (size_t)col);
ptr = newp + col;
for (i = 0; i < count; ++i)
{
mch_memmove(ptr, y_array[0], (size_t)yanklen);
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
ml_replace(lnum, newp, FALSE);
// compute the byte offset for the last character
first_byte_off = mb_head_off(newp, ptr - 1);
// Place cursor on last putted char.
if (lnum == curwin->w_cursor.lnum)
{
// make sure curwin->w_virtcol is updated
changed_cline_bef_curs();
curwin->w_cursor.col += (colnr_T)(totlen - 1);
}
if (VIsual_active)
lnum++;
} while (VIsual_active && lnum <= end_lnum);
if (VIsual_active) // reset lnum to the last visual line
lnum--;
}
// put '] at the first byte of the last character
curbuf->b_op_end = curwin->w_cursor;
curbuf->b_op_end.col -= first_byte_off;
// For "CTRL-O p" in Insert mode, put cursor after last char
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))
++curwin->w_cursor.col;
else
curwin->w_cursor.col -= first_byte_off;
changed_bytes(lnum, col);
}
else
{
linenr_T new_lnum = new_cursor.lnum;
size_t len;
// Insert at least one line. When y_type is MCHAR, break the first
// line in two.
for (cnt = 1; cnt <= count; ++cnt)
{
i = 0;
if (y_type == MCHAR)
{
// Split the current line in two at the insert position.
// First insert y_array[size - 1] in front of second line.
// Then append y_array[0] to first line.
lnum = new_cursor.lnum;
ptr = ml_get(lnum) + col;
totlen = (int)STRLEN(y_array[y_size - 1]);
newp = alloc(STRLEN(ptr) + totlen + 1);
if (newp == NULL)
goto error;
STRCPY(newp, y_array[y_size - 1]);
STRCAT(newp, ptr);
// insert second line
ml_append(lnum, newp, (colnr_T)0, FALSE);
++new_lnum;
vim_free(newp);
oldp = ml_get(lnum);
newp = alloc(col + yanklen + 1);
if (newp == NULL)
goto error;
// copy first part of line
mch_memmove(newp, oldp, (size_t)col);
// append to first line
mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1));
ml_replace(lnum, newp, FALSE);
curwin->w_cursor.lnum = lnum;
i = 1;
}
for (; i < y_size; ++i)
{
if (y_type != MCHAR || i < y_size - 1)
{
if (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)
== FAIL)
goto error;
new_lnum++;
}
lnum++;
++nr_lines;
if (flags & PUT_FIXINDENT)
{
old_pos = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
ptr = ml_get(lnum);
if (cnt == count && i == y_size - 1)
lendiff = (int)STRLEN(ptr);
if (*ptr == '#' && preprocs_left())
indent = 0; // Leave # lines at start
else
if (*ptr == NUL)
indent = 0; // Ignore empty lines
else if (first_indent)
{
indent_diff = orig_indent - get_indent();
indent = orig_indent;
first_indent = FALSE;
}
else if ((indent = get_indent() + indent_diff) < 0)
indent = 0;
(void)set_indent(indent, 0);
curwin->w_cursor = old_pos;
// remember how many chars were removed
if (cnt == count && i == y_size - 1)
lendiff -= (int)STRLEN(ml_get(lnum));
}
}
if (cnt == 1)
new_lnum = lnum;
}
error:
// Adjust marks.
if (y_type == MLINE)
{
curbuf->b_op_start.col = 0;
if (dir == FORWARD)
curbuf->b_op_start.lnum++;
}
// Skip mark_adjust when adding lines after the last one, there
// can't be marks there. But still needed in diff mode.
if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines
< curbuf->b_ml.ml_line_count
#ifdef FEAT_DIFF
|| curwin->w_p_diff
#endif
)
mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
(linenr_T)MAXLNUM, nr_lines, 0L);
// note changed text for displaying and folding
if (y_type == MCHAR)
changed_lines(curwin->w_cursor.lnum, col,
curwin->w_cursor.lnum + 1, nr_lines);
else
changed_lines(curbuf->b_op_start.lnum, 0,
curbuf->b_op_start.lnum, nr_lines);
if (y_current_used != NULL && (y_current_used != y_current
|| y_current->y_array != y_array))
{
// Something invoked through changed_lines() has changed the
// yank buffer, e.g. a GUI clipboard callback.
emsg(_(e_yank_register_changed_while_using_it));
goto end;
}
// Put the '] mark on the first byte of the last inserted character.
// Correct the length for change in indent.
curbuf->b_op_end.lnum = new_lnum;
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1)
{
curbuf->b_op_end.col = col - 1;
if (len > 0)
curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
}
else
curbuf->b_op_end.col = 0;
if (flags & PUT_CURSLINE)
{
// ":put": put cursor on last inserted line
curwin->w_cursor.lnum = lnum;
beginline(BL_WHITE | BL_FIX);
}
else if (flags & PUT_CURSEND)
{
// put cursor after inserted text
if (y_type == MLINE)
{
if (lnum >= curbuf->b_ml.ml_line_count)
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
else
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
}
else
{
curwin->w_cursor.lnum = new_lnum;
curwin->w_cursor.col = col;
curbuf->b_op_end = curwin->w_cursor;
if (col > 1)
curbuf->b_op_end.col = col - 1;
}
}
else if (y_type == MLINE)
{
// put cursor on first non-blank in first inserted line
curwin->w_cursor.col = 0;
if (dir == FORWARD)
++curwin->w_cursor.lnum;
beginline(BL_WHITE | BL_FIX);
}
else // put cursor on first inserted character
curwin->w_cursor = new_cursor;
}
}
msgmore(nr_lines);
curwin->w_set_curswant = TRUE;
end:
if (cmdmod.cmod_flags & CMOD_LOCKMARKS)
{
curbuf->b_op_start = orig_start;
curbuf->b_op_end = orig_end;
}
if (allocated)
vim_free(insert_string);
if (regname == '=')
vim_free(y_array);
VIsual_active = FALSE;
// If the cursor is past the end of the line put it at the end.
adjust_cursor_eol();
}
|
187254536140993008558175231359072054124
|
register.c
|
222058692998248357317124529383370719702
|
CWE-787
|
CVE-2022-2264
|
Heap-based Buffer Overflow in GitHub repository vim/vim prior to 9.0.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-2264
|
328,807
|
vim
|
d25f003342aca9889067f2e839963dfeccf1fe05
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/d25f003342aca9889067f2e839963dfeccf1fe05
|
patch 9.0.0011: reading beyond the end of the line with put command
Problem: Reading beyond the end of the line with put command.
Solution: Adjust the end mark position.
| 0
|
do_put(
int regname,
char_u *expr_result, // result for regname "=" when compiled
int dir, // BACKWARD for 'P', FORWARD for 'p'
long count,
int flags)
{
char_u *ptr;
char_u *newp, *oldp;
int yanklen;
int totlen = 0; // init for gcc
linenr_T lnum;
colnr_T col;
long i; // index in y_array[]
int y_type;
long y_size;
int oldlen;
long y_width = 0;
colnr_T vcol;
int delcount;
int incr = 0;
long j;
struct block_def bd;
char_u **y_array = NULL;
yankreg_T *y_current_used = NULL;
long nr_lines = 0;
pos_T new_cursor;
int indent;
int orig_indent = 0; // init for gcc
int indent_diff = 0; // init for gcc
int first_indent = TRUE;
int lendiff = 0;
pos_T old_pos;
char_u *insert_string = NULL;
int allocated = FALSE;
long cnt;
pos_T orig_start = curbuf->b_op_start;
pos_T orig_end = curbuf->b_op_end;
unsigned int cur_ve_flags = get_ve_flags();
#ifdef FEAT_CLIPBOARD
// Adjust register name for "unnamed" in 'clipboard'.
adjust_clip_reg(®name);
(void)may_get_selection(regname);
#endif
if (flags & PUT_FIXINDENT)
orig_indent = get_indent();
curbuf->b_op_start = curwin->w_cursor; // default for '[ mark
curbuf->b_op_end = curwin->w_cursor; // default for '] mark
// Using inserted text works differently, because the register includes
// special characters (newlines, etc.).
if (regname == '.')
{
if (VIsual_active)
stuffcharReadbuff(VIsual_mode);
(void)stuff_inserted((dir == FORWARD ? (count == -1 ? 'o' : 'a') :
(count == -1 ? 'O' : 'i')), count, FALSE);
// Putting the text is done later, so can't really move the cursor to
// the next character. Use "l" to simulate it.
if ((flags & PUT_CURSEND) && gchar_cursor() != NUL)
stuffcharReadbuff('l');
return;
}
// For special registers '%' (file name), '#' (alternate file name) and
// ':' (last command line), etc. we have to create a fake yank register.
// For compiled code "expr_result" holds the expression result.
if (regname == '=' && expr_result != NULL)
insert_string = expr_result;
else if (get_spec_reg(regname, &insert_string, &allocated, TRUE)
&& insert_string == NULL)
return;
// Autocommands may be executed when saving lines for undo. This might
// make "y_array" invalid, so we start undo now to avoid that.
if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL)
goto end;
if (insert_string != NULL)
{
y_type = MCHAR;
#ifdef FEAT_EVAL
if (regname == '=')
{
// For the = register we need to split the string at NL
// characters.
// Loop twice: count the number of lines and save them.
for (;;)
{
y_size = 0;
ptr = insert_string;
while (ptr != NULL)
{
if (y_array != NULL)
y_array[y_size] = ptr;
++y_size;
ptr = vim_strchr(ptr, '\n');
if (ptr != NULL)
{
if (y_array != NULL)
*ptr = NUL;
++ptr;
// A trailing '\n' makes the register linewise.
if (*ptr == NUL)
{
y_type = MLINE;
break;
}
}
}
if (y_array != NULL)
break;
y_array = ALLOC_MULT(char_u *, y_size);
if (y_array == NULL)
goto end;
}
}
else
#endif
{
y_size = 1; // use fake one-line yank register
y_array = &insert_string;
}
}
else
{
get_yank_register(regname, FALSE);
y_type = y_current->y_type;
y_width = y_current->y_width;
y_size = y_current->y_size;
y_array = y_current->y_array;
y_current_used = y_current;
}
if (y_type == MLINE)
{
if (flags & PUT_LINE_SPLIT)
{
char_u *p;
// "p" or "P" in Visual mode: split the lines to put the text in
// between.
if (u_save_cursor() == FAIL)
goto end;
p = ml_get_cursor();
if (dir == FORWARD && *p != NUL)
MB_PTR_ADV(p);
ptr = vim_strsave(p);
if (ptr == NULL)
goto end;
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
vim_free(ptr);
oldp = ml_get_curline();
p = oldp + curwin->w_cursor.col;
if (dir == FORWARD && *p != NUL)
MB_PTR_ADV(p);
ptr = vim_strnsave(oldp, p - oldp);
if (ptr == NULL)
goto end;
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
++nr_lines;
dir = FORWARD;
}
if (flags & PUT_LINE_FORWARD)
{
// Must be "p" for a Visual block, put lines below the block.
curwin->w_cursor = curbuf->b_visual.vi_end;
dir = FORWARD;
}
curbuf->b_op_start = curwin->w_cursor; // default for '[ mark
curbuf->b_op_end = curwin->w_cursor; // default for '] mark
}
if (flags & PUT_LINE) // :put command or "p" in Visual line mode.
y_type = MLINE;
if (y_size == 0 || y_array == NULL)
{
semsg(_(e_nothing_in_register_str),
regname == 0 ? (char_u *)"\"" : transchar(regname));
goto end;
}
if (y_type == MBLOCK)
{
lnum = curwin->w_cursor.lnum + y_size + 1;
if (lnum > curbuf->b_ml.ml_line_count)
lnum = curbuf->b_ml.ml_line_count + 1;
if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)
goto end;
}
else if (y_type == MLINE)
{
lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
// Correct line number for closed fold. Don't move the cursor yet,
// u_save() uses it.
if (dir == BACKWARD)
(void)hasFolding(lnum, &lnum, NULL);
else
(void)hasFolding(lnum, NULL, &lnum);
#endif
if (dir == FORWARD)
++lnum;
// In an empty buffer the empty line is going to be replaced, include
// it in the saved lines.
if ((BUFEMPTY() ? u_save(0, 2) : u_save(lnum - 1, lnum)) == FAIL)
goto end;
#ifdef FEAT_FOLDING
if (dir == FORWARD)
curwin->w_cursor.lnum = lnum - 1;
else
curwin->w_cursor.lnum = lnum;
curbuf->b_op_start = curwin->w_cursor; // for mark_adjust()
#endif
}
else if (u_save_cursor() == FAIL)
goto end;
yanklen = (int)STRLEN(y_array[0]);
if (cur_ve_flags == VE_ALL && y_type == MCHAR)
{
if (gchar_cursor() == TAB)
{
int viscol = getviscol();
int ts = curbuf->b_p_ts;
// Don't need to insert spaces when "p" on the last position of a
// tab or "P" on the first position.
if (dir == FORWARD ?
#ifdef FEAT_VARTABS
tabstop_padding(viscol, ts, curbuf->b_p_vts_array) != 1
#else
ts - (viscol % ts) != 1
#endif
: curwin->w_cursor.coladd > 0)
coladvance_force(viscol);
else
curwin->w_cursor.coladd = 0;
}
else if (curwin->w_cursor.coladd > 0 || gchar_cursor() == NUL)
coladvance_force(getviscol() + (dir == FORWARD));
}
lnum = curwin->w_cursor.lnum;
col = curwin->w_cursor.col;
// Block mode
if (y_type == MBLOCK)
{
int c = gchar_cursor();
colnr_T endcol2 = 0;
if (dir == FORWARD && c != NUL)
{
if (cur_ve_flags == VE_ALL)
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
else
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
if (has_mbyte)
// move to start of next multi-byte character
curwin->w_cursor.col += (*mb_ptr2len)(ml_get_cursor());
else
if (c != TAB || cur_ve_flags != VE_ALL)
++curwin->w_cursor.col;
++col;
}
else
getvcol(curwin, &curwin->w_cursor, &col, NULL, &endcol2);
col += curwin->w_cursor.coladd;
if (cur_ve_flags == VE_ALL
&& (curwin->w_cursor.coladd > 0
|| endcol2 == curwin->w_cursor.col))
{
if (dir == FORWARD && c == NUL)
++col;
if (dir != FORWARD && c != NUL && curwin->w_cursor.coladd > 0)
++curwin->w_cursor.col;
if (c == TAB)
{
if (dir == BACKWARD && curwin->w_cursor.col)
curwin->w_cursor.col--;
if (dir == FORWARD && col - 1 == endcol2)
curwin->w_cursor.col++;
}
}
curwin->w_cursor.coladd = 0;
bd.textcol = 0;
for (i = 0; i < y_size; ++i)
{
int spaces = 0;
char shortline;
bd.startspaces = 0;
bd.endspaces = 0;
vcol = 0;
delcount = 0;
// add a new line
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
{
if (ml_append(curbuf->b_ml.ml_line_count, (char_u *)"",
(colnr_T)1, FALSE) == FAIL)
break;
++nr_lines;
}
// get the old line and advance to the position to insert at
oldp = ml_get_curline();
oldlen = (int)STRLEN(oldp);
for (ptr = oldp; vcol < col && *ptr; )
{
// Count a tab for what it's worth (if list mode not on)
incr = lbr_chartabsize_adv(oldp, &ptr, vcol);
vcol += incr;
}
bd.textcol = (colnr_T)(ptr - oldp);
shortline = (vcol < col) || (vcol == col && !*ptr) ;
if (vcol < col) // line too short, padd with spaces
bd.startspaces = col - vcol;
else if (vcol > col)
{
bd.endspaces = vcol - col;
bd.startspaces = incr - bd.endspaces;
--bd.textcol;
delcount = 1;
if (has_mbyte)
bd.textcol -= (*mb_head_off)(oldp, oldp + bd.textcol);
if (oldp[bd.textcol] != TAB)
{
// Only a Tab can be split into spaces. Other
// characters will have to be moved to after the
// block, causing misalignment.
delcount = 0;
bd.endspaces = 0;
}
}
yanklen = (int)STRLEN(y_array[i]);
if ((flags & PUT_BLOCK_INNER) == 0)
{
// calculate number of spaces required to fill right side of
// block
spaces = y_width + 1;
for (j = 0; j < yanklen; j++)
spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
if (spaces < 0)
spaces = 0;
}
// Insert the new text.
// First check for multiplication overflow.
if (yanklen + spaces != 0
&& count > ((INT_MAX - (bd.startspaces + bd.endspaces))
/ (yanklen + spaces)))
{
emsg(_(e_resulting_text_too_long));
break;
}
totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;
newp = alloc(totlen + oldlen + 1);
if (newp == NULL)
break;
// copy part up to cursor to new line
ptr = newp;
mch_memmove(ptr, oldp, (size_t)bd.textcol);
ptr += bd.textcol;
// may insert some spaces before the new text
vim_memset(ptr, ' ', (size_t)bd.startspaces);
ptr += bd.startspaces;
// insert the new text
for (j = 0; j < count; ++j)
{
mch_memmove(ptr, y_array[i], (size_t)yanklen);
ptr += yanklen;
// insert block's trailing spaces only if there's text behind
if ((j < count - 1 || !shortline) && spaces)
{
vim_memset(ptr, ' ', (size_t)spaces);
ptr += spaces;
}
else
totlen -= spaces; // didn't use these spaces
}
// may insert some spaces after the new text
vim_memset(ptr, ' ', (size_t)bd.endspaces);
ptr += bd.endspaces;
// move the text after the cursor to the end of the line.
mch_memmove(ptr, oldp + bd.textcol + delcount,
(size_t)(oldlen - bd.textcol - delcount + 1));
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
++curwin->w_cursor.lnum;
if (i == 0)
curwin->w_cursor.col += bd.startspaces;
}
changed_lines(lnum, 0, curwin->w_cursor.lnum, nr_lines);
// Set '[ mark.
curbuf->b_op_start = curwin->w_cursor;
curbuf->b_op_start.lnum = lnum;
// adjust '] mark
curbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;
curbuf->b_op_end.col = bd.textcol + totlen - 1;
curbuf->b_op_end.coladd = 0;
if (flags & PUT_CURSEND)
{
colnr_T len;
curwin->w_cursor = curbuf->b_op_end;
curwin->w_cursor.col++;
// in Insert mode we might be after the NUL, correct for that
len = (colnr_T)STRLEN(ml_get_curline());
if (curwin->w_cursor.col > len)
curwin->w_cursor.col = len;
}
else
curwin->w_cursor.lnum = lnum;
}
else
{
// Character or Line mode
if (y_type == MCHAR)
{
// if type is MCHAR, FORWARD is the same as BACKWARD on the next
// char
if (dir == FORWARD && gchar_cursor() != NUL)
{
if (has_mbyte)
{
int bytelen = (*mb_ptr2len)(ml_get_cursor());
// put it on the next of the multi-byte character.
col += bytelen;
if (yanklen)
{
curwin->w_cursor.col += bytelen;
curbuf->b_op_end.col += bytelen;
}
}
else
{
++col;
if (yanklen)
{
++curwin->w_cursor.col;
++curbuf->b_op_end.col;
}
}
}
curbuf->b_op_start = curwin->w_cursor;
}
// Line mode: BACKWARD is the same as FORWARD on the previous line
else if (dir == BACKWARD)
--lnum;
new_cursor = curwin->w_cursor;
// simple case: insert into one line at a time
if (y_type == MCHAR && y_size == 1)
{
linenr_T end_lnum = 0; // init for gcc
linenr_T start_lnum = lnum;
int first_byte_off = 0;
if (VIsual_active)
{
end_lnum = curbuf->b_visual.vi_end.lnum;
if (end_lnum < curbuf->b_visual.vi_start.lnum)
end_lnum = curbuf->b_visual.vi_start.lnum;
if (end_lnum > start_lnum)
{
pos_T pos;
// "col" is valid for the first line, in following lines
// the virtual column needs to be used. Matters for
// multi-byte characters.
pos.lnum = lnum;
pos.col = col;
pos.coladd = 0;
getvcol(curwin, &pos, NULL, &vcol, NULL);
}
}
if (count == 0 || yanklen == 0)
{
if (VIsual_active)
lnum = end_lnum;
}
else if (count > INT_MAX / yanklen)
// multiplication overflow
emsg(_(e_resulting_text_too_long));
else
{
totlen = count * yanklen;
do {
oldp = ml_get(lnum);
oldlen = (int)STRLEN(oldp);
if (lnum > start_lnum)
{
pos_T pos;
pos.lnum = lnum;
if (getvpos(&pos, vcol) == OK)
col = pos.col;
else
col = MAXCOL;
}
if (VIsual_active && col > oldlen)
{
lnum++;
continue;
}
newp = alloc(totlen + oldlen + 1);
if (newp == NULL)
goto end; // alloc() gave an error message
mch_memmove(newp, oldp, (size_t)col);
ptr = newp + col;
for (i = 0; i < count; ++i)
{
mch_memmove(ptr, y_array[0], (size_t)yanklen);
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
ml_replace(lnum, newp, FALSE);
// compute the byte offset for the last character
first_byte_off = mb_head_off(newp, ptr - 1);
// Place cursor on last putted char.
if (lnum == curwin->w_cursor.lnum)
{
// make sure curwin->w_virtcol is updated
changed_cline_bef_curs();
curwin->w_cursor.col += (colnr_T)(totlen - 1);
}
if (VIsual_active)
lnum++;
} while (VIsual_active && lnum <= end_lnum);
if (VIsual_active) // reset lnum to the last visual line
lnum--;
}
// put '] at the first byte of the last character
curbuf->b_op_end = curwin->w_cursor;
curbuf->b_op_end.col -= first_byte_off;
// For "CTRL-O p" in Insert mode, put cursor after last char
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))
++curwin->w_cursor.col;
else
curwin->w_cursor.col -= first_byte_off;
changed_bytes(lnum, col);
}
else
{
linenr_T new_lnum = new_cursor.lnum;
size_t len;
// Insert at least one line. When y_type is MCHAR, break the first
// line in two.
for (cnt = 1; cnt <= count; ++cnt)
{
i = 0;
if (y_type == MCHAR)
{
// Split the current line in two at the insert position.
// First insert y_array[size - 1] in front of second line.
// Then append y_array[0] to first line.
lnum = new_cursor.lnum;
ptr = ml_get(lnum) + col;
totlen = (int)STRLEN(y_array[y_size - 1]);
newp = alloc(STRLEN(ptr) + totlen + 1);
if (newp == NULL)
goto error;
STRCPY(newp, y_array[y_size - 1]);
STRCAT(newp, ptr);
// insert second line
ml_append(lnum, newp, (colnr_T)0, FALSE);
++new_lnum;
vim_free(newp);
oldp = ml_get(lnum);
newp = alloc(col + yanklen + 1);
if (newp == NULL)
goto error;
// copy first part of line
mch_memmove(newp, oldp, (size_t)col);
// append to first line
mch_memmove(newp + col, y_array[0], (size_t)(yanklen + 1));
ml_replace(lnum, newp, FALSE);
curwin->w_cursor.lnum = lnum;
i = 1;
}
for (; i < y_size; ++i)
{
if (y_type != MCHAR || i < y_size - 1)
{
if (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)
== FAIL)
goto error;
new_lnum++;
}
lnum++;
++nr_lines;
if (flags & PUT_FIXINDENT)
{
old_pos = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
ptr = ml_get(lnum);
if (cnt == count && i == y_size - 1)
lendiff = (int)STRLEN(ptr);
if (*ptr == '#' && preprocs_left())
indent = 0; // Leave # lines at start
else
if (*ptr == NUL)
indent = 0; // Ignore empty lines
else if (first_indent)
{
indent_diff = orig_indent - get_indent();
indent = orig_indent;
first_indent = FALSE;
}
else if ((indent = get_indent() + indent_diff) < 0)
indent = 0;
(void)set_indent(indent, 0);
curwin->w_cursor = old_pos;
// remember how many chars were removed
if (cnt == count && i == y_size - 1)
lendiff -= (int)STRLEN(ml_get(lnum));
}
}
if (cnt == 1)
new_lnum = lnum;
}
error:
// Adjust marks.
if (y_type == MLINE)
{
curbuf->b_op_start.col = 0;
if (dir == FORWARD)
curbuf->b_op_start.lnum++;
}
// Skip mark_adjust when adding lines after the last one, there
// can't be marks there. But still needed in diff mode.
if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines
< curbuf->b_ml.ml_line_count
#ifdef FEAT_DIFF
|| curwin->w_p_diff
#endif
)
mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
(linenr_T)MAXLNUM, nr_lines, 0L);
// note changed text for displaying and folding
if (y_type == MCHAR)
changed_lines(curwin->w_cursor.lnum, col,
curwin->w_cursor.lnum + 1, nr_lines);
else
changed_lines(curbuf->b_op_start.lnum, 0,
curbuf->b_op_start.lnum, nr_lines);
if (y_current_used != NULL && (y_current_used != y_current
|| y_current->y_array != y_array))
{
// Something invoked through changed_lines() has changed the
// yank buffer, e.g. a GUI clipboard callback.
emsg(_(e_yank_register_changed_while_using_it));
goto end;
}
// Put the '] mark on the first byte of the last inserted character.
// Correct the length for change in indent.
curbuf->b_op_end.lnum = new_lnum;
len = STRLEN(y_array[y_size - 1]);
col = (colnr_T)len - lendiff;
if (col > 1)
{
curbuf->b_op_end.col = col - 1;
if (len > 0)
curbuf->b_op_end.col -= mb_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
}
else
curbuf->b_op_end.col = 0;
if (flags & PUT_CURSLINE)
{
// ":put": put cursor on last inserted line
curwin->w_cursor.lnum = lnum;
beginline(BL_WHITE | BL_FIX);
}
else if (flags & PUT_CURSEND)
{
// put cursor after inserted text
if (y_type == MLINE)
{
if (lnum >= curbuf->b_ml.ml_line_count)
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
else
curwin->w_cursor.lnum = lnum + 1;
curwin->w_cursor.col = 0;
}
else
{
curwin->w_cursor.lnum = new_lnum;
curwin->w_cursor.col = col;
curbuf->b_op_end = curwin->w_cursor;
if (col > 1)
curbuf->b_op_end.col = col - 1;
}
}
else if (y_type == MLINE)
{
// put cursor on first non-blank in first inserted line
curwin->w_cursor.col = 0;
if (dir == FORWARD)
++curwin->w_cursor.lnum;
beginline(BL_WHITE | BL_FIX);
}
else // put cursor on first inserted character
curwin->w_cursor = new_cursor;
}
}
msgmore(nr_lines);
curwin->w_set_curswant = TRUE;
end:
if (cmdmod.cmod_flags & CMOD_LOCKMARKS)
{
curbuf->b_op_start = orig_start;
curbuf->b_op_end = orig_end;
}
if (allocated)
vim_free(insert_string);
if (regname == '=')
vim_free(y_array);
VIsual_active = FALSE;
// If the cursor is past the end of the line put it at the end.
adjust_cursor_eol();
}
|
133908805751953919427107952660215245985
|
register.c
|
165298981279959476687221469555741136053
|
CWE-787
|
CVE-2022-2264
|
Heap-based Buffer Overflow in GitHub repository vim/vim prior to 9.0.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-2264
|
202,082
|
radare2
|
ecc44b6a2f18ee70ac133365de0e509d26d5e168
|
https://github.com/radare/radare2
|
https://github.com/radareorg/radare2/commit/ecc44b6a2f18ee70ac133365de0e509d26d5e168
|
Fix oobread in java parser ##crash
* Reported by @bet4it via @huntrdev
* BountyID c8f4c2de-7d96-4ad4-857a-c099effca2d6
* Reproducer: bootstrap.class
| 1
|
R_API RBinJavaAttrInfo *r_bin_java_bootstrap_methods_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaBootStrapMethod *bsm = NULL;
ut64 offset = 0;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR;
attr->info.bootstrap_methods_attr.num_bootstrap_methods = R_BIN_JAVA_USHORT (buffer, offset);
offset += 2;
attr->info.bootstrap_methods_attr.bootstrap_methods = r_list_newf (r_bin_java_bootstrap_method_free);
for (i = 0; i < attr->info.bootstrap_methods_attr.num_bootstrap_methods; i++) {
// bsm = r_bin_java_bootstrap_method_new (bin, bin->b->cur);
if (offset >= sz) {
break;
}
bsm = r_bin_java_bootstrap_method_new (buffer + offset, sz - offset, buf_offset + offset);
if (bsm) {
offset += bsm->size;
r_list_append (attr->info.bootstrap_methods_attr.bootstrap_methods, (void *) bsm);
} else {
// TODO eprintf Failed to read the %d boot strap method.
}
}
attr->size = offset;
}
return attr;
}
|
121022317607075696066263684863636152093
|
class.c
|
47177688403428674570419012647523968387
|
CWE-125
|
CVE-2022-1452
|
Out-of-bounds Read in r_bin_java_bootstrap_methods_attr_new function in GitHub repository radareorg/radare2 prior to 5.7.0. The bug causes the program reads data past the end 2f the intented buffer. Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. More details see [CWE-125: Out-of-bounds read](https://cwe.mitre.org/data/definitions/125.html).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1452
|
328,836
|
radare2
|
ecc44b6a2f18ee70ac133365de0e509d26d5e168
|
https://github.com/radare/radare2
|
https://github.com/radareorg/radare2/commit/ecc44b6a2f18ee70ac133365de0e509d26d5e168
|
Fix oobread in java parser ##crash
* Reported by @bet4it via @huntrdev
* BountyID c8f4c2de-7d96-4ad4-857a-c099effca2d6
* Reproducer: bootstrap.class
| 0
|
R_API RBinJavaAttrInfo *r_bin_java_bootstrap_methods_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaBootStrapMethod *bsm = NULL;
ut64 offset = 0;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR;
if (offset + 8 > sz) {
free (attr);
return NULL;
}
attr->info.bootstrap_methods_attr.num_bootstrap_methods = R_BIN_JAVA_USHORT (buffer, offset);
offset += 2;
attr->info.bootstrap_methods_attr.bootstrap_methods = r_list_newf (r_bin_java_bootstrap_method_free);
for (i = 0; i < attr->info.bootstrap_methods_attr.num_bootstrap_methods; i++) {
// bsm = r_bin_java_bootstrap_method_new (bin, bin->b->cur);
if (offset >= sz) {
break;
}
bsm = r_bin_java_bootstrap_method_new (buffer + offset, sz - offset, buf_offset + offset);
if (bsm) {
offset += bsm->size;
r_list_append (attr->info.bootstrap_methods_attr.bootstrap_methods, (void *) bsm);
} else {
// TODO eprintf Failed to read the %d boot strap method.
}
}
attr->size = offset;
}
return attr;
}
|
161704709334478835269694958839919177798
|
class.c
|
14172744137787125285025549785651095579
|
CWE-125
|
CVE-2022-1452
|
Out-of-bounds Read in r_bin_java_bootstrap_methods_attr_new function in GitHub repository radareorg/radare2 prior to 5.7.0. The bug causes the program reads data past the end 2f the intented buffer. Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. More details see [CWE-125: Out-of-bounds read](https://cwe.mitre.org/data/definitions/125.html).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1452
|
202,125
|
cairo
|
03a820b173ed1fdef6ff14b4468f5dbc02ff59be
|
https://gitlab.freedesktop.org/cairo/cairo
|
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/85/diffs?commit_id=03a820b173ed1fdef6ff14b4468f5dbc02ff59be
|
Fix mask usage in image-compositor
| 1
|
_inplace_src_spans (void *abstract_renderer, int y, int h,
const cairo_half_open_span_t *spans,
unsigned num_spans)
{
cairo_image_span_renderer_t *r = abstract_renderer;
uint8_t *m;
int x0;
if (num_spans == 0)
return CAIRO_STATUS_SUCCESS;
x0 = spans[0].x;
m = r->_buf;
do {
int len = spans[1].x - spans[0].x;
if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
pixman_image_composite32 (PIXMAN_OP_SRC,
r->src, NULL, r->u.composite.dst,
spans[0].x + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
spans[0].x, y,
spans[1].x - spans[0].x, h);
m = r->_buf;
x0 = spans[1].x;
} else if (spans[0].coverage == 0x0) {
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
m = r->_buf;
x0 = spans[1].x;
} else {
*m++ = spans[0].coverage;
if (len > 1) {
memset (m, spans[0].coverage, --len);
m += len;
}
}
spans++;
} while (--num_spans > 1);
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
return CAIRO_STATUS_SUCCESS;
}
|
284944114374640076378159892516757654917
|
None
|
CWE-787
|
CVE-2020-35492
|
A flaw was found in cairo's image-compositor.c in all versions prior to 1.17.4. This flaw allows an attacker who can provide a crafted input file to cairo's image-compositor (for example, by convincing a user to open a file in an application using cairo, or if an application uses cairo on untrusted input) to cause a stack buffer overflow -> out-of-bounds WRITE. The highest impact from this vulnerability is to confidentiality, integrity, as well as system availability.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-35492
|
|
329,925
|
cairo
|
03a820b173ed1fdef6ff14b4468f5dbc02ff59be
|
https://gitlab.freedesktop.org/cairo/cairo
|
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/85/diffs?commit_id=03a820b173ed1fdef6ff14b4468f5dbc02ff59be
|
Fix mask usage in image-compositor
| 0
|
_inplace_src_spans (void *abstract_renderer, int y, int h,
const cairo_half_open_span_t *spans,
unsigned num_spans)
{
cairo_image_span_renderer_t *r = abstract_renderer;
uint8_t *m, *base = (uint8_t*)pixman_image_get_data(r->mask);
int x0;
if (num_spans == 0)
return CAIRO_STATUS_SUCCESS;
x0 = spans[0].x;
m = base;
do {
int len = spans[1].x - spans[0].x;
if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
pixman_image_composite32 (PIXMAN_OP_SRC,
r->src, NULL, r->u.composite.dst,
spans[0].x + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
spans[0].x, y,
spans[1].x - spans[0].x, h);
m = base;
x0 = spans[1].x;
} else if (spans[0].coverage == 0x0) {
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
m = base;
x0 = spans[1].x;
} else {
*m++ = spans[0].coverage;
if (len > 1) {
memset (m, spans[0].coverage, --len);
m += len;
}
}
spans++;
} while (--num_spans > 1);
if (spans[0].x != x0) {
#if PIXMAN_HAS_OP_LERP
pixman_image_composite32 (PIXMAN_OP_LERP_SRC,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#else
pixman_image_composite32 (PIXMAN_OP_OUT_REVERSE,
r->mask, NULL, r->u.composite.dst,
0, 0,
0, 0,
x0, y,
spans[0].x - x0, h);
pixman_image_composite32 (PIXMAN_OP_ADD,
r->src, r->mask, r->u.composite.dst,
x0 + r->u.composite.src_x,
y + r->u.composite.src_y,
0, 0,
x0, y,
spans[0].x - x0, h);
#endif
}
return CAIRO_STATUS_SUCCESS;
}
|
297166780528255828865202210898036623430
|
None
|
CWE-787
|
CVE-2020-35492
|
A flaw was found in cairo's image-compositor.c in all versions prior to 1.17.4. This flaw allows an attacker who can provide a crafted input file to cairo's image-compositor (for example, by convincing a user to open a file in an application using cairo, or if an application uses cairo on untrusted input) to cause a stack buffer overflow -> out-of-bounds WRITE. The highest impact from this vulnerability is to confidentiality, integrity, as well as system availability.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-35492
|
|
202,256
|
qtbase
|
6b400e3147dcfd8cc3a393ace1bd118c93762e0c
|
https://github.com/qt/qtbase
|
https://github.com/qt/qtbase/commit/6b400e3147dcfd8cc3a393ace1bd118c93762e0c
|
Improve fix for avoiding huge number of tiny dashes
Some pathological cases were not caught by the previous fix.
Fixes: QTBUG-95239
Pick-to: 6.2 6.1 5.15
Change-Id: I0337ee3923ff93ccb36c4d7b810a9c0667354cc5
Reviewed-by: Robert Löhning <[email protected]>
| 1
|
void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen)
{
#ifdef QT_DEBUG_DRAW
qDebug() << "QPaintEngineEx::stroke()" << pen;
#endif
Q_D(QPaintEngineEx);
if (path.isEmpty())
return;
if (!d->strokeHandler) {
d->strokeHandler = new StrokeHandler(path.elementCount()+4);
d->stroker.setMoveToHook(qpaintengineex_moveTo);
d->stroker.setLineToHook(qpaintengineex_lineTo);
d->stroker.setCubicToHook(qpaintengineex_cubicTo);
}
QRectF clipRect;
QPen pen = inPen;
if (pen.style() > Qt::SolidLine) {
QRectF cpRect = path.controlPointRect();
const QTransform &xf = state()->matrix;
if (pen.isCosmetic()) {
clipRect = d->exDeviceRect;
cpRect.translate(xf.dx(), xf.dy());
} else {
clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect));
}
// Check to avoid generating unwieldy amount of dashes that will not be visible anyway
QRectF extentRect = cpRect & clipRect;
qreal extent = qMax(extentRect.width(), extentRect.height());
qreal patternLength = 0;
const QList<qreal> pattern = pen.dashPattern();
const int patternSize = qMin(pattern.size(), 32);
for (int i = 0; i < patternSize; i++)
patternLength += qMax(pattern.at(i), qreal(0));
if (pen.widthF())
patternLength *= pen.widthF();
if (qFuzzyIsNull(patternLength)) {
pen.setStyle(Qt::NoPen);
} else if (extent / patternLength > 10000) {
// approximate stream of tiny dashes with semi-transparent solid line
pen.setStyle(Qt::SolidLine);
QColor color(pen.color());
color.setAlpha(color.alpha() / 2);
pen.setColor(color);
}
}
if (!qpen_fast_equals(pen, d->strokerPen)) {
d->strokerPen = pen;
d->stroker.setJoinStyle(pen.joinStyle());
d->stroker.setCapStyle(pen.capStyle());
d->stroker.setMiterLimit(pen.miterLimit());
qreal penWidth = pen.widthF();
if (penWidth == 0)
d->stroker.setStrokeWidth(1);
else
d->stroker.setStrokeWidth(penWidth);
Qt::PenStyle style = pen.style();
if (style == Qt::SolidLine) {
d->activeStroker = &d->stroker;
} else if (style == Qt::NoPen) {
d->activeStroker = nullptr;
} else {
d->dasher.setDashPattern(pen.dashPattern());
d->dasher.setDashOffset(pen.dashOffset());
d->activeStroker = &d->dasher;
}
}
if (!d->activeStroker) {
return;
}
if (!clipRect.isNull())
d->activeStroker->setClipRect(clipRect);
if (d->activeStroker == &d->stroker)
d->stroker.setForceOpen(path.hasExplicitOpen());
const QPainterPath::ElementType *types = path.elements();
const qreal *points = path.points();
int pointCount = path.elementCount();
const qreal *lastPoint = points + (pointCount<<1);
d->strokeHandler->types.reset();
d->strokeHandler->pts.reset();
// Some engines might decide to optimize for the non-shape hint later on...
uint flags = QVectorPath::WindingFill;
if (path.elementCount() > 2)
flags |= QVectorPath::NonConvexShapeMask;
if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)
flags |= QVectorPath::CurvedShapeMask;
// ### Perspective Xforms are currently not supported...
if (!pen.isCosmetic()) {
// We include cosmetic pens in this case to avoid having to
// change the current transform. Normal transformed,
// non-cosmetic pens will be transformed as part of fill
// later, so they are also covered here..
d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
case QPainterPath::MoveToElement:
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::LineToElement:
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::CurveToElement:
d->activeStroker->cubicTo(points[0], points[1],
points[2], points[3],
points[4], points[5]);
points += 6;
types += 3;
flags |= QVectorPath::CurvedShapeMask;
break;
default:
break;
}
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
} else {
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
while (points < lastPoint) {
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
}
d->activeStroker->end();
if (!d->strokeHandler->types.size()) // an empty path...
return;
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
d->strokeHandler->types.data(),
flags);
fill(strokePath, pen.brush());
} else {
// For cosmetic pens we need a bit of trickery... We to process xform the input points
if (state()->matrix.type() >= QTransform::TxProject) {
QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
} else {
d->activeStroker->setCurveThresholdFromTransform(QTransform());
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
case QPainterPath::MoveToElement: {
QPointF pt = (*(const QPointF *) points) * state()->matrix;
d->activeStroker->moveTo(pt.x(), pt.y());
points += 2;
++types;
break;
}
case QPainterPath::LineToElement: {
QPointF pt = (*(const QPointF *) points) * state()->matrix;
d->activeStroker->lineTo(pt.x(), pt.y());
points += 2;
++types;
break;
}
case QPainterPath::CurveToElement: {
QPointF c1 = ((const QPointF *) points)[0] * state()->matrix;
QPointF c2 = ((const QPointF *) points)[1] * state()->matrix;
QPointF e = ((const QPointF *) points)[2] * state()->matrix;
d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
points += 6;
types += 3;
flags |= QVectorPath::CurvedShapeMask;
break;
}
default:
break;
}
}
if (path.hasImplicitClose()) {
QPointF pt = * ((const QPointF *) path.points()) * state()->matrix;
d->activeStroker->lineTo(pt.x(), pt.y());
}
} else {
QPointF p = ((const QPointF *)points)[0] * state()->matrix;
d->activeStroker->moveTo(p.x(), p.y());
points += 2;
while (points < lastPoint) {
QPointF p = ((const QPointF *)points)[0] * state()->matrix;
d->activeStroker->lineTo(p.x(), p.y());
points += 2;
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(p.x(), p.y());
}
d->activeStroker->end();
}
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
d->strokeHandler->types.data(),
flags);
QTransform xform = state()->matrix;
state()->matrix = QTransform();
transformChanged();
QBrush brush = pen.brush();
if (qbrush_style(brush) != Qt::SolidPattern)
brush.setTransform(brush.transform() * xform);
fill(strokePath, brush);
state()->matrix = xform;
transformChanged();
}
}
|
209191742971544690982165605152005956873
|
qpaintengineex.cpp
|
121502439456016918324891600204397406142
|
CWE-787
|
CVE-2021-38593
|
Qt 5.x before 5.15.6 and 6.x through 6.1.2 has an out-of-bounds write in QOutlineMapper::convertPath (called from QRasterPaintEngine::fill and QPaintEngineEx::stroke).
|
https://nvd.nist.gov/vuln/detail/CVE-2021-38593
|
331,760
|
qtbase
|
6b400e3147dcfd8cc3a393ace1bd118c93762e0c
|
https://github.com/qt/qtbase
|
https://github.com/qt/qtbase/commit/6b400e3147dcfd8cc3a393ace1bd118c93762e0c
|
Improve fix for avoiding huge number of tiny dashes
Some pathological cases were not caught by the previous fix.
Fixes: QTBUG-95239
Pick-to: 6.2 6.1 5.15
Change-Id: I0337ee3923ff93ccb36c4d7b810a9c0667354cc5
Reviewed-by: Robert Löhning <[email protected]>
| 0
|
void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen)
{
#ifdef QT_DEBUG_DRAW
qDebug() << "QPaintEngineEx::stroke()" << pen;
#endif
Q_D(QPaintEngineEx);
if (path.isEmpty())
return;
if (!d->strokeHandler) {
d->strokeHandler = new StrokeHandler(path.elementCount()+4);
d->stroker.setMoveToHook(qpaintengineex_moveTo);
d->stroker.setLineToHook(qpaintengineex_lineTo);
d->stroker.setCubicToHook(qpaintengineex_cubicTo);
}
QRectF clipRect;
QPen pen = inPen;
if (pen.style() > Qt::SolidLine) {
QRectF cpRect = path.controlPointRect();
const QTransform &xf = state()->matrix;
if (pen.isCosmetic()) {
clipRect = d->exDeviceRect;
cpRect.translate(xf.dx(), xf.dy());
} else {
clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect));
}
// Check to avoid generating unwieldy amount of dashes that will not be visible anyway
QRectF extentRect = cpRect & clipRect;
qreal extent = qMax(extentRect.width(), extentRect.height());
qreal patternLength = 0;
const QList<qreal> pattern = pen.dashPattern();
const int patternSize = qMin(pattern.size(), 32);
for (int i = 0; i < patternSize; i++)
patternLength += qMax(pattern.at(i), qreal(0));
if (pen.widthF())
patternLength *= pen.widthF();
if (qFuzzyIsNull(patternLength)) {
pen.setStyle(Qt::NoPen);
} else if (qFuzzyIsNull(extent) || extent / patternLength > 10000) {
// approximate stream of tiny dashes with semi-transparent solid line
pen.setStyle(Qt::SolidLine);
QColor color(pen.color());
color.setAlpha(color.alpha() / 2);
pen.setColor(color);
}
}
if (!qpen_fast_equals(pen, d->strokerPen)) {
d->strokerPen = pen;
d->stroker.setJoinStyle(pen.joinStyle());
d->stroker.setCapStyle(pen.capStyle());
d->stroker.setMiterLimit(pen.miterLimit());
qreal penWidth = pen.widthF();
if (penWidth == 0)
d->stroker.setStrokeWidth(1);
else
d->stroker.setStrokeWidth(penWidth);
Qt::PenStyle style = pen.style();
if (style == Qt::SolidLine) {
d->activeStroker = &d->stroker;
} else if (style == Qt::NoPen) {
d->activeStroker = nullptr;
} else {
d->dasher.setDashPattern(pen.dashPattern());
d->dasher.setDashOffset(pen.dashOffset());
d->activeStroker = &d->dasher;
}
}
if (!d->activeStroker) {
return;
}
if (!clipRect.isNull())
d->activeStroker->setClipRect(clipRect);
if (d->activeStroker == &d->stroker)
d->stroker.setForceOpen(path.hasExplicitOpen());
const QPainterPath::ElementType *types = path.elements();
const qreal *points = path.points();
int pointCount = path.elementCount();
const qreal *lastPoint = points + (pointCount<<1);
d->strokeHandler->types.reset();
d->strokeHandler->pts.reset();
// Some engines might decide to optimize for the non-shape hint later on...
uint flags = QVectorPath::WindingFill;
if (path.elementCount() > 2)
flags |= QVectorPath::NonConvexShapeMask;
if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)
flags |= QVectorPath::CurvedShapeMask;
// ### Perspective Xforms are currently not supported...
if (!pen.isCosmetic()) {
// We include cosmetic pens in this case to avoid having to
// change the current transform. Normal transformed,
// non-cosmetic pens will be transformed as part of fill
// later, so they are also covered here..
d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
case QPainterPath::MoveToElement:
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::LineToElement:
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::CurveToElement:
d->activeStroker->cubicTo(points[0], points[1],
points[2], points[3],
points[4], points[5]);
points += 6;
types += 3;
flags |= QVectorPath::CurvedShapeMask;
break;
default:
break;
}
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
} else {
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
while (points < lastPoint) {
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
}
d->activeStroker->end();
if (!d->strokeHandler->types.size()) // an empty path...
return;
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
d->strokeHandler->types.data(),
flags);
fill(strokePath, pen.brush());
} else {
// For cosmetic pens we need a bit of trickery... We to process xform the input points
if (state()->matrix.type() >= QTransform::TxProject) {
QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
} else {
d->activeStroker->setCurveThresholdFromTransform(QTransform());
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
case QPainterPath::MoveToElement: {
QPointF pt = (*(const QPointF *) points) * state()->matrix;
d->activeStroker->moveTo(pt.x(), pt.y());
points += 2;
++types;
break;
}
case QPainterPath::LineToElement: {
QPointF pt = (*(const QPointF *) points) * state()->matrix;
d->activeStroker->lineTo(pt.x(), pt.y());
points += 2;
++types;
break;
}
case QPainterPath::CurveToElement: {
QPointF c1 = ((const QPointF *) points)[0] * state()->matrix;
QPointF c2 = ((const QPointF *) points)[1] * state()->matrix;
QPointF e = ((const QPointF *) points)[2] * state()->matrix;
d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
points += 6;
types += 3;
flags |= QVectorPath::CurvedShapeMask;
break;
}
default:
break;
}
}
if (path.hasImplicitClose()) {
QPointF pt = * ((const QPointF *) path.points()) * state()->matrix;
d->activeStroker->lineTo(pt.x(), pt.y());
}
} else {
QPointF p = ((const QPointF *)points)[0] * state()->matrix;
d->activeStroker->moveTo(p.x(), p.y());
points += 2;
while (points < lastPoint) {
QPointF p = ((const QPointF *)points)[0] * state()->matrix;
d->activeStroker->lineTo(p.x(), p.y());
points += 2;
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(p.x(), p.y());
}
d->activeStroker->end();
}
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
d->strokeHandler->types.data(),
flags);
QTransform xform = state()->matrix;
state()->matrix = QTransform();
transformChanged();
QBrush brush = pen.brush();
if (qbrush_style(brush) != Qt::SolidPattern)
brush.setTransform(brush.transform() * xform);
fill(strokePath, brush);
state()->matrix = xform;
transformChanged();
}
}
|
262258193863623717012890974299984432074
|
qpaintengineex.cpp
|
220664880987933761772605675716001859723
|
CWE-787
|
CVE-2021-38593
|
Qt 5.x before 5.15.6 and 6.x through 6.1.2 has an out-of-bounds write in QOutlineMapper::convertPath (called from QRasterPaintEngine::fill and QPaintEngineEx::stroke).
|
https://nvd.nist.gov/vuln/detail/CVE-2021-38593
|
202,276
|
vim
|
57df9e8a9f9ae1aafdde9b86b10ad907627a87dc
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc
|
patch 8.2.4151: reading beyond the end of a line
Problem: Reading beyond the end of a line.
Solution: For block insert only use the offset for correcting the length.
| 1
|
block_insert(
oparg_T *oap,
char_u *s,
int b_insert,
struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
int spaces = 0; // non-zero if cutting a TAB
colnr_T offset; // pointer along new line
colnr_T startcol; // column where insert starts
unsigned s_len; // STRLEN(s)
char_u *newp, *oldp; // new, old lines
linenr_T lnum; // loop var
int oldstate = State;
State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
if (b_insert)
{
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
else // append
{
ts_val = bdp->end_char_vcols;
if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
else // spaces = padding to block edge
{
// if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
offset = bdp->textcol + bdp->textlen;
}
}
if (has_mbyte && spaces > 0)
{
int off;
// Avoid starting halfway a multi-byte character.
if (b_insert)
{
off = (*mb_head_off)(oldp, oldp + offset + spaces);
spaces -= off;
count -= off;
}
else
{
// spaces fill the gap, the character that's at the edge moves
// right
off = (*mb_head_off)(oldp, oldp + offset);
offset -= off;
}
}
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;
// Make sure the allocated size matches what is actually copied below.
newp = alloc(STRLEN(oldp) + spaces + s_len
+ (spaces > 0 && !bdp->is_short ? ts_val - spaces : 0)
+ count + 1);
if (newp == NULL)
continue;
// copy up to shifted part
mch_memmove(newp, oldp, (size_t)offset);
oldp += offset;
// insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
startcol = offset + spaces;
// copy the new text
mch_memmove(newp + startcol, s, (size_t)s_len);
offset += s_len;
if (spaces > 0 && !bdp->is_short)
{
if (*oldp == TAB)
{
// insert post-padding
vim_memset(newp + offset + spaces, ' ',
(size_t)(ts_val - spaces));
// we're splitting a TAB, don't copy it
oldp++;
// We allowed for that TAB, remember this now
count++;
}
else
// Not a TAB, no extra spaces
count = spaces;
}
if (spaces > 0)
offset += count;
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, FALSE);
if (b_insert)
// correct any text properties
inserted_bytes(lnum, startcol, s_len);
if (lnum == oap->end.lnum)
{
// Set "']" mark to the end of the block instead of the end of
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
}
} // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
State = oldstate;
}
|
183841044104193466999010248328275139619
|
None
|
CWE-787
|
CVE-2022-0318
|
Heap-based Buffer Overflow in vim/vim prior to 8.2.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0318
|
|
332,375
|
vim
|
57df9e8a9f9ae1aafdde9b86b10ad907627a87dc
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc
|
patch 8.2.4151: reading beyond the end of a line
Problem: Reading beyond the end of a line.
Solution: For block insert only use the offset for correcting the length.
| 0
|
block_insert(
oparg_T *oap,
char_u *s,
int b_insert,
struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
int spaces = 0; // non-zero if cutting a TAB
colnr_T offset; // pointer along new line
colnr_T startcol; // column where insert starts
unsigned s_len; // STRLEN(s)
char_u *newp, *oldp; // new, old lines
linenr_T lnum; // loop var
int oldstate = State;
State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
if (b_insert)
{
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
else // append
{
ts_val = bdp->end_char_vcols;
if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
else // spaces = padding to block edge
{
// if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
offset = bdp->textcol + bdp->textlen;
}
}
if (has_mbyte && spaces > 0)
// avoid copying part of a multi-byte character
offset -= (*mb_head_off)(oldp, oldp + offset);
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;
// Make sure the allocated size matches what is actually copied below.
newp = alloc(STRLEN(oldp) + spaces + s_len
+ (spaces > 0 && !bdp->is_short ? ts_val - spaces : 0)
+ count + 1);
if (newp == NULL)
continue;
// copy up to shifted part
mch_memmove(newp, oldp, (size_t)offset);
oldp += offset;
// insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
startcol = offset + spaces;
// copy the new text
mch_memmove(newp + startcol, s, (size_t)s_len);
offset += s_len;
if (spaces > 0 && !bdp->is_short)
{
if (*oldp == TAB)
{
// insert post-padding
vim_memset(newp + offset + spaces, ' ',
(size_t)(ts_val - spaces));
// we're splitting a TAB, don't copy it
oldp++;
// We allowed for that TAB, remember this now
count++;
}
else
// Not a TAB, no extra spaces
count = spaces;
}
if (spaces > 0)
offset += count;
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, FALSE);
if (b_insert)
// correct any text properties
inserted_bytes(lnum, startcol, s_len);
if (lnum == oap->end.lnum)
{
// Set "']" mark to the end of the block instead of the end of
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
}
} // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
State = oldstate;
}
|
7107013452158908965442250951300434750
|
None
|
CWE-787
|
CVE-2022-0318
|
Heap-based Buffer Overflow in vim/vim prior to 8.2.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0318
|
|
202,304
|
vim
|
65b605665997fad54ef39a93199e305af2fe4d7f
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/65b605665997fad54ef39a93199e305af2fe4d7f
|
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.
| 1
|
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;
}
|
167741715836576091847644361250163558580
|
None
|
CWE-122
|
CVE-2021-3778
|
vim is vulnerable to Heap-based Buffer Overflow
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3778
|
|
333,041
|
vim
|
65b605665997fad54ef39a93199e305af2fe4d7f
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/65b605665997fad54ef39a93199e305af2fe4d7f
|
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.
| 0
|
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 += enc_utf8 ? utf_ptr2len(rex.line + col + 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;
}
|
187278234885415513203260954810277689325
|
None
|
CWE-122
|
CVE-2021-3778
|
vim is vulnerable to Heap-based Buffer Overflow
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3778
|
|
202,392
|
php-src
|
8fa9d1ce28f3a894b104979df30d0b65e0f21107
|
https://github.com/php/php-src
|
https://git.php.net/?p=php-src.git;a=commit;h=8fa9d1ce28f3a894b104979df30d0b65e0f21107
|
improve fix #72558, while (u>=0) with unsigned int will always be true
| 1
|
static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)
{
unsigned int u = 0;
LineContribType *res;
int overflow_error = 0;
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
}
res->WindowSize = windows_size;
res->LineLength = line_length;
if (overflow2(line_length, sizeof(ContributionType))) {
gdFree(res);
return NULL;
}
res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));
if (res->ContribRow == NULL) {
gdFree(res);
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
if (overflow2(windows_size, sizeof(double))) {
overflow_error = 1;
} else {
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
}
if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
u--;
while (u >= 0) {
gdFree(res->ContribRow[u].Weights);
u--;
}
return NULL;
}
}
return res;
}
|
194329029953977312970767834657292140797
|
gd_interpolation.c
|
48112947254685040097740151772508640024
|
CWE-119
|
CVE-2016-6207
|
Integer overflow in the _gdContributionsAlloc function in gd_interpolation.c in GD Graphics Library (aka libgd) before 2.2.3 allows remote attackers to cause a denial of service (out-of-bounds memory write or memory consumption) via unspecified vectors.
|
https://nvd.nist.gov/vuln/detail/CVE-2016-6207
|
333,503
|
php-src
|
8fa9d1ce28f3a894b104979df30d0b65e0f21107
|
https://github.com/php/php-src
|
https://git.php.net/?p=php-src.git;a=commit;h=8fa9d1ce28f3a894b104979df30d0b65e0f21107
|
improve fix #72558, while (u>=0) with unsigned int will always be true
| 0
|
static inline LineContribType * _gdContributionsAlloc(unsigned int line_length, unsigned int windows_size)
{
unsigned int u = 0;
LineContribType *res;
int overflow_error = 0;
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
}
res->WindowSize = windows_size;
res->LineLength = line_length;
if (overflow2(line_length, sizeof(ContributionType))) {
gdFree(res);
return NULL;
}
res->ContribRow = (ContributionType *) gdMalloc(line_length * sizeof(ContributionType));
if (res->ContribRow == NULL) {
gdFree(res);
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
if (overflow2(windows_size, sizeof(double))) {
overflow_error = 1;
} else {
res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
}
if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
unsigned int i;
u--;
for (i=0;i<=u;i++) {
gdFree(res->ContribRow[i].Weights);
}
gdFree(res);
return NULL;
}
}
return res;
}
|
144028133167446566795171831954194871613
|
gd_interpolation.c
|
190827623618557315538392680975816018804
|
CWE-119
|
CVE-2016-6207
|
Integer overflow in the _gdContributionsAlloc function in gd_interpolation.c in GD Graphics Library (aka libgd) before 2.2.3 allows remote attackers to cause a denial of service (out-of-bounds memory write or memory consumption) via unspecified vectors.
|
https://nvd.nist.gov/vuln/detail/CVE-2016-6207
|
202,659
|
net
|
7892032cfe67f4bde6fc2ee967e45a8fbaf33756
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net.git/commit/?id=7892032cfe67f4bde6fc2ee967e45a8fbaf33756
|
ip6_gre: fix ip6gre_err() invalid reads
Andrey Konovalov reported out of bound accesses in ip6gre_err()
If GRE flags contains GRE_KEY, the following expression
*(((__be32 *)p) + (grehlen / 4) - 1)
accesses data ~40 bytes after the expected point, since
grehlen includes the size of IPv6 headers.
Let's use a "struct gre_base_hdr *greh" pointer to make this
code more readable.
p[1] becomes greh->protocol.
grhlen is the GRE header length.
Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Andrey Konovalov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 1
|
static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
u8 type, u8 code, int offset, __be32 info)
{
const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb->data;
__be16 *p = (__be16 *)(skb->data + offset);
int grehlen = offset + 4;
struct ip6_tnl *t;
__be16 flags;
flags = p[0];
if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
if (flags&(GRE_VERSION|GRE_ROUTING))
return;
if (flags&GRE_KEY) {
grehlen += 4;
if (flags&GRE_CSUM)
grehlen += 4;
}
}
/* If only 8 bytes returned, keyed message will be dropped here */
if (!pskb_may_pull(skb, grehlen))
return;
ipv6h = (const struct ipv6hdr *)skb->data;
p = (__be16 *)(skb->data + offset);
t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
flags & GRE_KEY ?
*(((__be32 *)p) + (grehlen / 4) - 1) : 0,
p[1]);
if (!t)
return;
switch (type) {
__u32 teli;
struct ipv6_tlv_tnl_enc_lim *tel;
__u32 mtu;
case ICMPV6_DEST_UNREACH:
net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",
t->parms.name);
break;
case ICMPV6_TIME_EXCEED:
if (code == ICMPV6_EXC_HOPLIMIT) {
net_dbg_ratelimited("%s: Too small hop limit or routing loop in tunnel!\n",
t->parms.name);
}
break;
case ICMPV6_PARAMPROB:
teli = 0;
if (code == ICMPV6_HDR_FIELD)
teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);
if (teli && teli == be32_to_cpu(info) - 2) {
tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
if (tel->encap_limit == 0) {
net_dbg_ratelimited("%s: Too small encapsulation limit or routing loop in tunnel!\n",
t->parms.name);
}
} else {
net_dbg_ratelimited("%s: Recipient unable to parse tunneled packet!\n",
t->parms.name);
}
break;
case ICMPV6_PKT_TOOBIG:
mtu = be32_to_cpu(info) - offset;
if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU;
t->dev->mtu = mtu;
break;
}
if (time_before(jiffies, t->err_time + IP6TUNNEL_ERR_TIMEO))
t->err_count++;
else
t->err_count = 1;
t->err_time = jiffies;
}
|
14483423650343594705979392035761356983
|
ip6_gre.c
|
117967096098363699106311326917896397499
|
CWE-125
|
CVE-2017-5897
|
The ip6gre_err function in net/ipv6/ip6_gre.c in the Linux kernel allows remote attackers to have unspecified impact via vectors involving GRE flags in an IPv6 packet, which trigger an out-of-bounds access.
|
https://nvd.nist.gov/vuln/detail/CVE-2017-5897
|
336,106
|
net
|
7892032cfe67f4bde6fc2ee967e45a8fbaf33756
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net.git/commit/?id=7892032cfe67f4bde6fc2ee967e45a8fbaf33756
|
ip6_gre: fix ip6gre_err() invalid reads
Andrey Konovalov reported out of bound accesses in ip6gre_err()
If GRE flags contains GRE_KEY, the following expression
*(((__be32 *)p) + (grehlen / 4) - 1)
accesses data ~40 bytes after the expected point, since
grehlen includes the size of IPv6 headers.
Let's use a "struct gre_base_hdr *greh" pointer to make this
code more readable.
p[1] becomes greh->protocol.
grhlen is the GRE header length.
Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: Andrey Konovalov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 0
|
static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
u8 type, u8 code, int offset, __be32 info)
{
const struct gre_base_hdr *greh;
const struct ipv6hdr *ipv6h;
int grehlen = sizeof(*greh);
struct ip6_tnl *t;
int key_off = 0;
__be16 flags;
__be32 key;
if (!pskb_may_pull(skb, offset + grehlen))
return;
greh = (const struct gre_base_hdr *)(skb->data + offset);
flags = greh->flags;
if (flags & (GRE_VERSION | GRE_ROUTING))
return;
if (flags & GRE_CSUM)
grehlen += 4;
if (flags & GRE_KEY) {
key_off = grehlen + offset;
grehlen += 4;
}
if (!pskb_may_pull(skb, offset + grehlen))
return;
ipv6h = (const struct ipv6hdr *)skb->data;
greh = (const struct gre_base_hdr *)(skb->data + offset);
key = key_off ? *(__be32 *)(skb->data + key_off) : 0;
t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
key, greh->protocol);
if (!t)
return;
switch (type) {
__u32 teli;
struct ipv6_tlv_tnl_enc_lim *tel;
__u32 mtu;
case ICMPV6_DEST_UNREACH:
net_dbg_ratelimited("%s: Path to destination invalid or inactive!\n",
t->parms.name);
break;
case ICMPV6_TIME_EXCEED:
if (code == ICMPV6_EXC_HOPLIMIT) {
net_dbg_ratelimited("%s: Too small hop limit or routing loop in tunnel!\n",
t->parms.name);
}
break;
case ICMPV6_PARAMPROB:
teli = 0;
if (code == ICMPV6_HDR_FIELD)
teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);
if (teli && teli == be32_to_cpu(info) - 2) {
tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
if (tel->encap_limit == 0) {
net_dbg_ratelimited("%s: Too small encapsulation limit or routing loop in tunnel!\n",
t->parms.name);
}
} else {
net_dbg_ratelimited("%s: Recipient unable to parse tunneled packet!\n",
t->parms.name);
}
break;
case ICMPV6_PKT_TOOBIG:
mtu = be32_to_cpu(info) - offset;
if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU;
t->dev->mtu = mtu;
break;
}
if (time_before(jiffies, t->err_time + IP6TUNNEL_ERR_TIMEO))
t->err_count++;
else
t->err_count = 1;
t->err_time = jiffies;
}
|
275651998275867668694727636706080952271
|
ip6_gre.c
|
12117188675970598231582084849956564114
|
CWE-125
|
CVE-2017-5897
|
The ip6gre_err function in net/ipv6/ip6_gre.c in the Linux kernel allows remote attackers to have unspecified impact via vectors involving GRE flags in an IPv6 packet, which trigger an out-of-bounds access.
|
https://nvd.nist.gov/vuln/detail/CVE-2017-5897
|
202,677
|
qemu
|
9302e863aa8baa5d932fc078967050c055fa1a7f
|
https://github.com/bonzini/qemu
|
http://git.qemu.org/?p=qemu.git;a=commit;h=9302e863aa8baa5d932fc078967050c055fa1a7f
|
parallels: Sanity check for s->tracks (CVE-2014-0142)
This avoids a possible division by zero.
Convert s->tracks to unsigned as well because it feels better than
surviving just because the results of calculations with s->tracks are
converted to unsigned anyway.
Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
| 1
|
static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVParallelsState *s = bs->opaque;
int i;
struct parallels_header ph;
int ret;
bs->read_only = 1; // no write support yet
ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));
if (ret < 0) {
goto fail;
}
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
goto fail;
}
bs->total_sectors = le32_to_cpu(ph.nb_sectors);
s->tracks = le32_to_cpu(ph.tracks);
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / 4) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
ret = bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4);
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->catalog_bitmap);
return ret;
}
|
337127974960403546779692670017681638774
|
None
|
CWE-369
|
CVE-2014-0142
|
QEMU, possibly before 2.0.0, allows local users to cause a denial of service (divide-by-zero error and crash) via a zero value in the (1) tracks field to the seek_to_sector function in block/parallels.c or (2) extent_size field in the bochs function in block/bochs.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2014-0142
|
|
336,484
|
qemu
|
9302e863aa8baa5d932fc078967050c055fa1a7f
|
https://github.com/bonzini/qemu
|
http://git.qemu.org/?p=qemu.git;a=commit;h=9302e863aa8baa5d932fc078967050c055fa1a7f
|
parallels: Sanity check for s->tracks (CVE-2014-0142)
This avoids a possible division by zero.
Convert s->tracks to unsigned as well because it feels better than
surviving just because the results of calculations with s->tracks are
converted to unsigned anyway.
Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
| 0
|
static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVParallelsState *s = bs->opaque;
int i;
struct parallels_header ph;
int ret;
bs->read_only = 1; // no write support yet
ret = bdrv_pread(bs->file, 0, &ph, sizeof(ph));
if (ret < 0) {
goto fail;
}
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
error_setg(errp, "Image not in Parallels format");
ret = -EINVAL;
goto fail;
}
bs->total_sectors = le32_to_cpu(ph.nb_sectors);
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(errp, "Invalid image: Zero sectors per track");
ret = -EINVAL;
goto fail;
}
s->catalog_size = le32_to_cpu(ph.catalog_entries);
if (s->catalog_size > INT_MAX / 4) {
error_setg(errp, "Catalog too large");
ret = -EFBIG;
goto fail;
}
s->catalog_bitmap = g_malloc(s->catalog_size * 4);
ret = bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4);
if (ret < 0) {
goto fail;
}
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->catalog_bitmap);
return ret;
}
|
85532877697804718298733270367705862714
|
None
|
CWE-369
|
CVE-2014-0142
|
QEMU, possibly before 2.0.0, allows local users to cause a denial of service (divide-by-zero error and crash) via a zero value in the (1) tracks field to the seek_to_sector function in block/parallels.c or (2) extent_size field in the bochs function in block/bochs.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2014-0142
|
|
202,688
|
ghostpdl
|
450da26a76286a8342ec0864b3d113856709f8f6
|
https://github.com/ArtifexSoftware/ghostpdl
|
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=450da26a76286a8342ec0864b3d113856709f8f6
|
Bug 701785: fixed sanitizer heap-buffer-overflow in lprn_is_black().
In contrib/lips4/gdevlprn.c:lprn_is_black(), it seems that bpl is not
necessarily a multiple of lprn->nBw, so we need to explicitly avoid straying
into the next line's data.
This also avoids accessing beyond our buffer if we are already on the last
line, and so fixes the sanitizer error.
Fixes:
./sanbin/gs -sOutputFile=tmp -sDEVICE=lips2p ../bug-701785.pdf
| 1
|
lprn_is_black(gx_device_printer * pdev, int r, int h, int bx)
{
gx_device_lprn *const lprn = (gx_device_lprn *) pdev;
int bh = lprn->nBh;
int bpl = gdev_mem_bytes_per_scan_line(pdev);
int x, y, y0;
byte *p;
int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh;
y0 = (r + h - bh) % maxY;
for (y = 0; y < bh; y++) {
p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];
for (x = 0; x < lprn->nBw; x++)
if (p[x] != 0)
return 1;
}
return 0;
}
|
276235081077601818208956388725727672709
|
gdevlprn.c
|
146789313062349427560159100335401323936
|
CWE-787
|
CVE-2020-16287
|
A buffer overflow vulnerability in lprn_is_black() in contrib/lips4/gdevlprn.c of Artifex Software GhostScript v9.50 allows a remote attacker to cause a denial of service via a crafted PDF file. This is fixed in v9.51.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-16287
|
336,807
|
ghostpdl
|
450da26a76286a8342ec0864b3d113856709f8f6
|
https://github.com/ArtifexSoftware/ghostpdl
|
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=450da26a76286a8342ec0864b3d113856709f8f6
|
Bug 701785: fixed sanitizer heap-buffer-overflow in lprn_is_black().
In contrib/lips4/gdevlprn.c:lprn_is_black(), it seems that bpl is not
necessarily a multiple of lprn->nBw, so we need to explicitly avoid straying
into the next line's data.
This also avoids accessing beyond our buffer if we are already on the last
line, and so fixes the sanitizer error.
Fixes:
./sanbin/gs -sOutputFile=tmp -sDEVICE=lips2p ../bug-701785.pdf
| 0
|
lprn_is_black(gx_device_printer * pdev, int r, int h, int bx)
{
gx_device_lprn *const lprn = (gx_device_lprn *) pdev;
int bh = lprn->nBh;
int bpl = gdev_mem_bytes_per_scan_line(pdev);
int x, y, y0;
byte *p;
int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh;
y0 = (r + h - bh) % maxY;
for (y = 0; y < bh; y++) {
p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];
for (x = 0; x < lprn->nBw; x++) {
/* bpl isn't necessarily a multiple of lprn->nBw, so
we need to explicitly stop after the last byte in this
line to avoid accessing either the next line's data or
going off the end of our buffer completely. This avoids
https://bugs.ghostscript.com/show_bug.cgi?id=701785. */
if (bx * lprn->nBw + x >= bpl) break;
if (p[x] != 0)
return 1;
}
}
return 0;
}
|
150670636989365509549221893772046699987
|
gdevlprn.c
|
90759681637200263840236208606383547324
|
CWE-787
|
CVE-2020-16287
|
A buffer overflow vulnerability in lprn_is_black() in contrib/lips4/gdevlprn.c of Artifex Software GhostScript v9.50 allows a remote attacker to cause a denial of service via a crafted PDF file. This is fixed in v9.51.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-16287
|
202,708
|
vim
|
8e4b76da1d7e987d43ca960dfbc372d1c617466f
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/8e4b76da1d7e987d43ca960dfbc372d1c617466f
|
patch 8.2.4901: NULL pointer access when using invalid pattern
Problem: NULL pointer access when using invalid pattern.
Solution: Check for failed regexp program.
| 1
|
fname_match(
regmatch_T *rmp,
char_u *name,
int ignore_case) // when TRUE ignore case, when FALSE use 'fic'
{
char_u *match = NULL;
char_u *p;
if (name != NULL)
{
// Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;
if (vim_regexec(rmp, name, (colnr_T)0))
match = name;
else
{
// Replace $(HOME) with '~' and try matching again.
p = home_replace_save(NULL, name);
if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
match = name;
vim_free(p);
}
}
return match;
}
|
10065855190174385623233460326166538906
|
buffer.c
|
293823123124136567259918164990957667329
|
CWE-476
|
CVE-2022-1620
|
NULL Pointer Dereference in function vim_regexec_string at regexp.c:2729 in GitHub repository vim/vim prior to 8.2.4901. NULL Pointer Dereference in function vim_regexec_string at regexp.c:2729 allows attackers to cause a denial of service (application crash) via a crafted input.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1620
|
337,374
|
vim
|
8e4b76da1d7e987d43ca960dfbc372d1c617466f
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/8e4b76da1d7e987d43ca960dfbc372d1c617466f
|
patch 8.2.4901: NULL pointer access when using invalid pattern
Problem: NULL pointer access when using invalid pattern.
Solution: Check for failed regexp program.
| 0
|
fname_match(
regmatch_T *rmp,
char_u *name,
int ignore_case) // when TRUE ignore case, when FALSE use 'fic'
{
char_u *match = NULL;
char_u *p;
if (name != NULL)
{
// Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;
if (vim_regexec(rmp, name, (colnr_T)0))
match = name;
else if (rmp->regprog != NULL)
{
// Replace $(HOME) with '~' and try matching again.
p = home_replace_save(NULL, name);
if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
match = name;
vim_free(p);
}
}
return match;
}
|
197882423023027832397527147027813452758
|
buffer.c
|
116246354520267882741601792511100691040
|
CWE-476
|
CVE-2022-1620
|
NULL Pointer Dereference in function vim_regexec_string at regexp.c:2729 in GitHub repository vim/vim prior to 8.2.4901. NULL Pointer Dereference in function vim_regexec_string at regexp.c:2729 allows attackers to cause a denial of service (application crash) via a crafted input.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1620
|
202,719
|
linux
|
a2d859e3fc97e79d907761550dbc03ff1b36479c
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a2d859e3fc97e79d907761550dbc03ff1b36479c
|
sctp: account stream padding length for reconf chunk
sctp_make_strreset_req() makes repeated calls to sctp_addto_chunk()
which will automatically account for padding on each call. inreq and
outreq are already 4 bytes aligned, but the payload is not and doing
SCTP_PAD4(a + b) (which _sctp_make_chunk() did implicitly here) is
different from SCTP_PAD4(a) + SCTP_PAD4(b) and not enough. It led to
possible attempt to use more buffer than it was allocated and triggered
a BUG_ON.
Cc: Vlad Yasevich <[email protected]>
Cc: Neil Horman <[email protected]>
Cc: Greg KH <[email protected]>
Fixes: cc16f00f6529 ("sctp: add support for generating stream reconf ssn reset request chunk")
Reported-by: Eiichi Tsukata <[email protected]>
Signed-off-by: Eiichi Tsukata <[email protected]>
Signed-off-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: Marcelo Ricardo Leitner <[email protected]>
Reviewed-by: Xin Long <[email protected]>
Link: https://lore.kernel.org/r/b97c1f8b0c7ff79ac4ed206fc2c49d3612e0850c.1634156849.git.mleitner@redhat.com
Signed-off-by: Jakub Kicinski <[email protected]>
| 1
|
struct sctp_chunk *sctp_make_strreset_req(
const struct sctp_association *asoc,
__u16 stream_num, __be16 *stream_list,
bool out, bool in)
{
__u16 stream_len = stream_num * sizeof(__u16);
struct sctp_strreset_outreq outreq;
struct sctp_strreset_inreq inreq;
struct sctp_chunk *retval;
__u16 outlen, inlen;
outlen = (sizeof(outreq) + stream_len) * out;
inlen = (sizeof(inreq) + stream_len) * in;
retval = sctp_make_reconf(asoc, outlen + inlen);
if (!retval)
return NULL;
if (outlen) {
outreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST;
outreq.param_hdr.length = htons(outlen);
outreq.request_seq = htonl(asoc->strreset_outseq);
outreq.response_seq = htonl(asoc->strreset_inseq - 1);
outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);
sctp_addto_chunk(retval, sizeof(outreq), &outreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
if (inlen) {
inreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST;
inreq.param_hdr.length = htons(inlen);
inreq.request_seq = htonl(asoc->strreset_outseq + out);
sctp_addto_chunk(retval, sizeof(inreq), &inreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
return retval;
}
|
215335113411495657240056321729109595636
|
sm_make_chunk.c
|
110519816461895113606911923370921219323
|
CWE-704
|
CVE-2022-0322
|
A flaw was found in the sctp_make_strreset_req function in net/sctp/sm_make_chunk.c in the SCTP network protocol in the Linux kernel with a local user privilege access. In this flaw, an attempt to use more buffer than is allocated triggers a BUG_ON issue, leading to a denial of service (DOS).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0322
|
337,848
|
linux
|
a2d859e3fc97e79d907761550dbc03ff1b36479c
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a2d859e3fc97e79d907761550dbc03ff1b36479c
|
sctp: account stream padding length for reconf chunk
sctp_make_strreset_req() makes repeated calls to sctp_addto_chunk()
which will automatically account for padding on each call. inreq and
outreq are already 4 bytes aligned, but the payload is not and doing
SCTP_PAD4(a + b) (which _sctp_make_chunk() did implicitly here) is
different from SCTP_PAD4(a) + SCTP_PAD4(b) and not enough. It led to
possible attempt to use more buffer than it was allocated and triggered
a BUG_ON.
Cc: Vlad Yasevich <[email protected]>
Cc: Neil Horman <[email protected]>
Cc: Greg KH <[email protected]>
Fixes: cc16f00f6529 ("sctp: add support for generating stream reconf ssn reset request chunk")
Reported-by: Eiichi Tsukata <[email protected]>
Signed-off-by: Eiichi Tsukata <[email protected]>
Signed-off-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: Marcelo Ricardo Leitner <[email protected]>
Reviewed-by: Xin Long <[email protected]>
Link: https://lore.kernel.org/r/b97c1f8b0c7ff79ac4ed206fc2c49d3612e0850c.1634156849.git.mleitner@redhat.com
Signed-off-by: Jakub Kicinski <[email protected]>
| 0
|
struct sctp_chunk *sctp_make_strreset_req(
const struct sctp_association *asoc,
__u16 stream_num, __be16 *stream_list,
bool out, bool in)
{
__u16 stream_len = stream_num * sizeof(__u16);
struct sctp_strreset_outreq outreq;
struct sctp_strreset_inreq inreq;
struct sctp_chunk *retval;
__u16 outlen, inlen;
outlen = (sizeof(outreq) + stream_len) * out;
inlen = (sizeof(inreq) + stream_len) * in;
retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen));
if (!retval)
return NULL;
if (outlen) {
outreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST;
outreq.param_hdr.length = htons(outlen);
outreq.request_seq = htonl(asoc->strreset_outseq);
outreq.response_seq = htonl(asoc->strreset_inseq - 1);
outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);
sctp_addto_chunk(retval, sizeof(outreq), &outreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
if (inlen) {
inreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST;
inreq.param_hdr.length = htons(inlen);
inreq.request_seq = htonl(asoc->strreset_outseq + out);
sctp_addto_chunk(retval, sizeof(inreq), &inreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
return retval;
}
|
175020260748921031996578395052444557756
|
sm_make_chunk.c
|
72489321105602052766082993841220689495
|
CWE-704
|
CVE-2022-0322
|
A flaw was found in the sctp_make_strreset_req function in net/sctp/sm_make_chunk.c in the SCTP network protocol in the Linux kernel with a local user privilege access. In this flaw, an attempt to use more buffer than is allocated triggers a BUG_ON issue, leading to a denial of service (DOS).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0322
|
202,748
|
ImageMagick
|
fbb5e1c8211c4e88ecc367e784b79d457c300d6d
|
https://github.com/ImageMagick/ImageMagick
|
https://github.com/ImageMagick/ImageMagick/commit/fbb5e1c8211c4e88ecc367e784b79d457c300d6d
|
...
| 1
|
static Image *ReadTGAImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
MagickBooleanType
status;
PixelInfo
pixel;
Quantum
index;
register Quantum
*q;
register ssize_t
i,
x;
size_t
base,
flag,
offset,
real,
skip;
ssize_t
count,
y;
TGAInfo
tga_info;
unsigned char
j,
k,
pixels[4],
runlength;
unsigned int
alpha_bits;
/*
Open image file.
*/
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(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read TGA header information.
*/
count=ReadBlob(image,1,&tga_info.id_length);
tga_info.colormap_type=(unsigned char) ReadBlobByte(image);
tga_info.image_type=(TGAImageType) ReadBlobByte(image);
if ((count != 1) ||
((tga_info.image_type != TGAColormap) &&
(tga_info.image_type != TGARGB) &&
(tga_info.image_type != TGAMonochrome) &&
(tga_info.image_type != TGARLEColormap) &&
(tga_info.image_type != TGARLERGB) &&
(tga_info.image_type != TGARLEMonochrome)) ||
(((tga_info.image_type == TGAColormap) ||
(tga_info.image_type == TGARLEColormap)) &&
(tga_info.colormap_type == 0)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
tga_info.colormap_index=ReadBlobLSBShort(image);
tga_info.colormap_length=ReadBlobLSBShort(image);
tga_info.colormap_size=(unsigned char) ReadBlobByte(image);
tga_info.x_origin=ReadBlobLSBShort(image);
tga_info.y_origin=ReadBlobLSBShort(image);
tga_info.width=(unsigned short) ReadBlobLSBShort(image);
tga_info.height=(unsigned short) ReadBlobLSBShort(image);
tga_info.bits_per_pixel=(unsigned char) ReadBlobByte(image);
tga_info.attributes=(unsigned char) ReadBlobByte(image);
if (EOFBlob(image) != MagickFalse)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
if ((((tga_info.bits_per_pixel <= 1) || (tga_info.bits_per_pixel >= 17)) &&
(tga_info.bits_per_pixel != 24) && (tga_info.bits_per_pixel != 32)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
/*
Initialize image structure.
*/
image->columns=tga_info.width;
image->rows=tga_info.height;
alpha_bits=(tga_info.attributes & 0x0FU);
image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||
(tga_info.colormap_size == 32) ? BlendPixelTrait : UndefinedPixelTrait;
if ((tga_info.image_type != TGAColormap) &&
(tga_info.image_type != TGARLEColormap))
image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :
(tga_info.bits_per_pixel <= 16) ? 5 : 8);
else
image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :
(tga_info.colormap_size <= 16) ? 5 : 8);
if ((tga_info.image_type == TGAColormap) ||
(tga_info.image_type == TGAMonochrome) ||
(tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLEMonochrome))
image->storage_class=PseudoClass;
image->compression=NoCompression;
if ((tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLEMonochrome) ||
(tga_info.image_type == TGARLERGB))
image->compression=RLECompression;
if (image->storage_class == PseudoClass)
{
if (tga_info.colormap_type != 0)
image->colors=tga_info.colormap_index+tga_info.colormap_length;
else
{
size_t
one;
one=1;
image->colors=one << tga_info.bits_per_pixel;
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
}
if (tga_info.id_length != 0)
{
char
*comment;
size_t
length;
/*
TGA image comment.
*/
length=(size_t) tga_info.id_length;
comment=(char *) NULL;
if (~length >= (MagickPathExtent-1))
comment=(char *) AcquireQuantumMemory(length+MagickPathExtent,
sizeof(*comment));
if (comment == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
count=ReadBlob(image,tga_info.id_length,(unsigned char *) comment);
comment[tga_info.id_length]='\0';
(void) SetImageProperty(image,"comment",comment,exception);
comment=DestroyString(comment);
}
if (tga_info.attributes & (1UL << 4))
{
if (tga_info.attributes & (1UL << 5))
SetImageArtifact(image,"tga:image-origin","TopRight");
else
SetImageArtifact(image,"tga:image-origin","BottomRight");
}
else
{
if (tga_info.attributes & (1UL << 5))
SetImageArtifact(image,"tga:image-origin","TopLeft");
else
SetImageArtifact(image,"tga:image-origin","BottomLeft");
}
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(image);
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
(void) ResetMagickMemory(&pixel,0,sizeof(pixel));
pixel.alpha=(MagickRealType) OpaqueAlpha;
if (tga_info.colormap_type != 0)
{
/*
Read TGA raster colormap.
*/
if (image->colors < tga_info.colormap_index)
image->colors=tga_info.colormap_index;
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
for (i=0; i < (ssize_t) tga_info.colormap_index; i++)
image->colormap[i]=pixel;
for ( ; i < (ssize_t) image->colors; i++)
{
switch (tga_info.colormap_size)
{
case 8:
default:
{
/*
Gray scale.
*/
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=pixel.red;
pixel.blue=pixel.red;
break;
}
case 15:
case 16:
{
QuantumAny
range;
/*
5 bits each of red green and blue.
*/
j=(unsigned char) ReadBlobByte(image);
k=(unsigned char) ReadBlobByte(image);
range=GetQuantumRange(5UL);
pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,
range);
pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*(k & 0x03)
<< 3)+(1UL*(j & 0xe0) >> 5),range);
pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);
break;
}
case 24:
{
/*
8 bits each of blue, green and red.
*/
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
break;
}
case 32:
{
/*
8 bits each of blue, green, red, and alpha.
*/
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.alpha=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
break;
}
}
image->colormap[i]=pixel;
}
}
/*
Convert TGA pixels to pixel packets.
*/
base=0;
flag=0;
skip=MagickFalse;
real=0;
index=0;
runlength=0;
offset=0;
for (y=0; y < (ssize_t) image->rows; y++)
{
real=offset;
if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0)
real=image->rows-real-1;
q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLERGB) ||
(tga_info.image_type == TGARLEMonochrome))
{
if (runlength != 0)
{
runlength--;
skip=flag != 0;
}
else
{
count=ReadBlob(image,1,&runlength);
if (count != 1)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
flag=runlength & 0x80;
if (flag != 0)
runlength-=128;
skip=MagickFalse;
}
}
if (skip == MagickFalse)
switch (tga_info.bits_per_pixel)
{
case 8:
default:
{
/*
Gray scale.
*/
index=(Quantum) ReadBlobByte(image);
if (tga_info.colormap_type != 0)
pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image,
(ssize_t) index,exception)];
else
{
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
}
break;
}
case 15:
case 16:
{
QuantumAny
range;
/*
5 bits each of RGB.
*/
if (ReadBlob(image,2,pixels) != 2)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
j=pixels[0];
k=pixels[1];
range=GetQuantumRange(5UL);
pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,
range);
pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*
(k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range);
pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);
if (image->alpha_trait != UndefinedPixelTrait)
pixel.alpha=(MagickRealType) ((k & 0x80) == 0 ? (Quantum)
TransparentAlpha : (Quantum) OpaqueAlpha);
if (image->storage_class == PseudoClass)
index=(Quantum) ConstrainColormapIndex(image,((ssize_t) (k << 8))+
j,exception);
break;
}
case 24:
{
/*
BGR pixels.
*/
if (ReadBlob(image,3,pixels) != 3)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);
pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);
pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);
break;
}
case 32:
{
/*
BGRA pixels.
*/
if (ReadBlob(image,4,pixels) != 4)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);
pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);
pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);
pixel.alpha=(MagickRealType) ScaleCharToQuantum(pixels[3]);
break;
}
}
if (status == MagickFalse)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
if (image->storage_class == PseudoClass)
SetPixelIndex(image,index,q);
SetPixelRed(image,ClampToQuantum(pixel.red),q);
SetPixelGreen(image,ClampToQuantum(pixel.green),q);
SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
if (image->alpha_trait != UndefinedPixelTrait)
SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
q+=GetPixelChannels(image);
}
/*
if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4)
offset+=4;
else
*/
if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2)
offset+=2;
else
offset++;
if (offset >= image->rows)
{
base++;
offset=base;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
|
95115433929731884744054008378657506459
|
tga.c
|
229955351147198147579545037524450823231
|
CWE-772
|
CVE-2017-11170
|
The ReadTGAImage function in coders\tga.c in ImageMagick 7.0.5-6 has a memory leak vulnerability that can cause memory exhaustion via invalid colors data in the header of a TGA or VST file.
|
https://nvd.nist.gov/vuln/detail/CVE-2017-11170
|
338,747
|
ImageMagick
|
fbb5e1c8211c4e88ecc367e784b79d457c300d6d
|
https://github.com/ImageMagick/ImageMagick
|
https://github.com/ImageMagick/ImageMagick/commit/fbb5e1c8211c4e88ecc367e784b79d457c300d6d
|
...
| 0
|
static Image *ReadTGAImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
MagickBooleanType
status;
PixelInfo
pixel;
Quantum
index;
register Quantum
*q;
register ssize_t
i,
x;
size_t
base,
flag,
offset,
real,
skip;
ssize_t
count,
y;
TGAInfo
tga_info;
unsigned char
j,
k,
pixels[4],
runlength;
unsigned int
alpha_bits;
/*
Open image file.
*/
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(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read TGA header information.
*/
count=ReadBlob(image,1,&tga_info.id_length);
tga_info.colormap_type=(unsigned char) ReadBlobByte(image);
tga_info.image_type=(TGAImageType) ReadBlobByte(image);
if ((count != 1) ||
((tga_info.image_type != TGAColormap) &&
(tga_info.image_type != TGARGB) &&
(tga_info.image_type != TGAMonochrome) &&
(tga_info.image_type != TGARLEColormap) &&
(tga_info.image_type != TGARLERGB) &&
(tga_info.image_type != TGARLEMonochrome)) ||
(((tga_info.image_type == TGAColormap) ||
(tga_info.image_type == TGARLEColormap)) &&
(tga_info.colormap_type == 0)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
tga_info.colormap_index=ReadBlobLSBShort(image);
tga_info.colormap_length=ReadBlobLSBShort(image);
tga_info.colormap_size=(unsigned char) ReadBlobByte(image);
tga_info.x_origin=ReadBlobLSBShort(image);
tga_info.y_origin=ReadBlobLSBShort(image);
tga_info.width=(unsigned short) ReadBlobLSBShort(image);
tga_info.height=(unsigned short) ReadBlobLSBShort(image);
tga_info.bits_per_pixel=(unsigned char) ReadBlobByte(image);
tga_info.attributes=(unsigned char) ReadBlobByte(image);
if (EOFBlob(image) != MagickFalse)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
if ((((tga_info.bits_per_pixel <= 1) || (tga_info.bits_per_pixel >= 17)) &&
(tga_info.bits_per_pixel != 24) && (tga_info.bits_per_pixel != 32)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
/*
Initialize image structure.
*/
image->columns=tga_info.width;
image->rows=tga_info.height;
alpha_bits=(tga_info.attributes & 0x0FU);
image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||
(tga_info.colormap_size == 32) ? BlendPixelTrait : UndefinedPixelTrait;
if ((tga_info.image_type != TGAColormap) &&
(tga_info.image_type != TGARLEColormap))
image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :
(tga_info.bits_per_pixel <= 16) ? 5 : 8);
else
image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :
(tga_info.colormap_size <= 16) ? 5 : 8);
if ((tga_info.image_type == TGAColormap) ||
(tga_info.image_type == TGAMonochrome) ||
(tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLEMonochrome))
image->storage_class=PseudoClass;
image->compression=NoCompression;
if ((tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLEMonochrome) ||
(tga_info.image_type == TGARLERGB))
image->compression=RLECompression;
if (image->storage_class == PseudoClass)
{
if (tga_info.colormap_type != 0)
image->colors=tga_info.colormap_index+tga_info.colormap_length;
else
{
size_t
one;
one=1;
image->colors=one << tga_info.bits_per_pixel;
if (image->colors > ((~0UL)/sizeof(*image->colormap)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
}
if (tga_info.id_length != 0)
{
char
*comment;
size_t
length;
/*
TGA image comment.
*/
length=(size_t) tga_info.id_length;
comment=(char *) NULL;
if (~length >= (MagickPathExtent-1))
comment=(char *) AcquireQuantumMemory(length+MagickPathExtent,
sizeof(*comment));
if (comment == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
count=ReadBlob(image,tga_info.id_length,(unsigned char *) comment);
comment[tga_info.id_length]='\0';
(void) SetImageProperty(image,"comment",comment,exception);
comment=DestroyString(comment);
}
if (tga_info.attributes & (1UL << 4))
{
if (tga_info.attributes & (1UL << 5))
SetImageArtifact(image,"tga:image-origin","TopRight");
else
SetImageArtifact(image,"tga:image-origin","BottomRight");
}
else
{
if (tga_info.attributes & (1UL << 5))
SetImageArtifact(image,"tga:image-origin","TopLeft");
else
SetImageArtifact(image,"tga:image-origin","BottomLeft");
}
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(image);
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
(void) ResetMagickMemory(&pixel,0,sizeof(pixel));
pixel.alpha=(MagickRealType) OpaqueAlpha;
if (tga_info.colormap_type != 0)
{
/*
Read TGA raster colormap.
*/
if (image->colors < tga_info.colormap_index)
image->colors=tga_info.colormap_index;
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
for (i=0; i < (ssize_t) tga_info.colormap_index; i++)
image->colormap[i]=pixel;
for ( ; i < (ssize_t) image->colors; i++)
{
switch (tga_info.colormap_size)
{
case 8:
default:
{
/*
Gray scale.
*/
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=pixel.red;
pixel.blue=pixel.red;
break;
}
case 15:
case 16:
{
QuantumAny
range;
/*
5 bits each of red green and blue.
*/
j=(unsigned char) ReadBlobByte(image);
k=(unsigned char) ReadBlobByte(image);
range=GetQuantumRange(5UL);
pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,
range);
pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*(k & 0x03)
<< 3)+(1UL*(j & 0xe0) >> 5),range);
pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);
break;
}
case 24:
{
/*
8 bits each of blue, green and red.
*/
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
break;
}
case 32:
{
/*
8 bits each of blue, green, red, and alpha.
*/
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
pixel.alpha=(MagickRealType) ScaleCharToQuantum((unsigned char)
ReadBlobByte(image));
break;
}
}
image->colormap[i]=pixel;
}
}
/*
Convert TGA pixels to pixel packets.
*/
base=0;
flag=0;
skip=MagickFalse;
real=0;
index=0;
runlength=0;
offset=0;
for (y=0; y < (ssize_t) image->rows; y++)
{
real=offset;
if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0)
real=image->rows-real-1;
q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((tga_info.image_type == TGARLEColormap) ||
(tga_info.image_type == TGARLERGB) ||
(tga_info.image_type == TGARLEMonochrome))
{
if (runlength != 0)
{
runlength--;
skip=flag != 0;
}
else
{
count=ReadBlob(image,1,&runlength);
if (count != 1)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
flag=runlength & 0x80;
if (flag != 0)
runlength-=128;
skip=MagickFalse;
}
}
if (skip == MagickFalse)
switch (tga_info.bits_per_pixel)
{
case 8:
default:
{
/*
Gray scale.
*/
index=(Quantum) ReadBlobByte(image);
if (tga_info.colormap_type != 0)
pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image,
(ssize_t) index,exception)];
else
{
pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char)
index);
}
break;
}
case 15:
case 16:
{
QuantumAny
range;
/*
5 bits each of RGB.
*/
if (ReadBlob(image,2,pixels) != 2)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
j=pixels[0];
k=pixels[1];
range=GetQuantumRange(5UL);
pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2,
range);
pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*
(k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range);
pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range);
if (image->alpha_trait != UndefinedPixelTrait)
pixel.alpha=(MagickRealType) ((k & 0x80) == 0 ? (Quantum)
TransparentAlpha : (Quantum) OpaqueAlpha);
if (image->storage_class == PseudoClass)
index=(Quantum) ConstrainColormapIndex(image,((ssize_t) (k << 8))+
j,exception);
break;
}
case 24:
{
/*
BGR pixels.
*/
if (ReadBlob(image,3,pixels) != 3)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);
pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);
pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);
break;
}
case 32:
{
/*
BGRA pixels.
*/
if (ReadBlob(image,4,pixels) != 4)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]);
pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]);
pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]);
pixel.alpha=(MagickRealType) ScaleCharToQuantum(pixels[3]);
break;
}
}
if (status == MagickFalse)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
if (image->storage_class == PseudoClass)
SetPixelIndex(image,index,q);
SetPixelRed(image,ClampToQuantum(pixel.red),q);
SetPixelGreen(image,ClampToQuantum(pixel.green),q);
SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
if (image->alpha_trait != UndefinedPixelTrait)
SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
q+=GetPixelChannels(image);
}
/*
if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4)
offset+=4;
else
*/
if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2)
offset+=2;
else
offset++;
if (offset >= image->rows)
{
base++;
offset=base;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
|
175791113381074585644433899536597352981
|
tga.c
|
184535518978867885654371830775021710506
|
CWE-772
|
CVE-2017-11170
|
The ReadTGAImage function in coders\tga.c in ImageMagick 7.0.5-6 has a memory leak vulnerability that can cause memory exhaustion via invalid colors data in the header of a TGA or VST file.
|
https://nvd.nist.gov/vuln/detail/CVE-2017-11170
|
202,783
|
php-src
|
37da90248deb2188e8ee50e4753ad6340679b425
|
https://github.com/php/php-src
|
http://git.php.net/?p=php-src.git;a=commitdiff;h=37da90248deb2188e8ee50e4753ad6340679b425
|
Added missing allocation checks
| 1
|
static Bigint * Balloc(int k)
{
int x;
Bigint *rv;
_THREAD_PRIVATE_MUTEX_LOCK(dtoa_mutex);
if ((rv = freelist[k])) {
freelist[k] = rv->next;
} else {
x = 1 << k;
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
rv->k = k;
rv->maxwds = x;
}
_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);
rv->sign = rv->wds = 0;
return rv;
}
|
233883423838019694196347564918158945680
|
zend_strtod.c
|
162225586697792700551271623353891886066
|
CWE-119
|
CVE-2009-0689
|
Array index error in the (1) dtoa implementation in dtoa.c (aka pdtoa.c) and the (2) gdtoa (aka new dtoa) implementation in gdtoa/misc.c in libc, as used in multiple operating systems and products including in FreeBSD 6.4 and 7.2, NetBSD 5.0, OpenBSD 4.5, Mozilla Firefox 3.0.x before 3.0.15 and 3.5.x before 3.5.4, K-Meleon 1.5.3, SeaMonkey 1.1.8, and other products, allows context-dependent attackers to cause a denial of service (application crash) and possibly execute arbitrary code via a large precision value in the format argument to a printf function, which triggers incorrect memory allocation and a heap-based buffer overflow during conversion to a floating-point number.
|
https://nvd.nist.gov/vuln/detail/CVE-2009-0689
|
339,712
|
php-src
|
37da90248deb2188e8ee50e4753ad6340679b425
|
https://github.com/php/php-src
|
http://git.php.net/?p=php-src.git;a=commitdiff;h=37da90248deb2188e8ee50e4753ad6340679b425
|
Added missing allocation checks
| 0
|
static Bigint * Balloc(int k)
{
int x;
Bigint *rv;
if (k > Kmax) {
zend_error(E_ERROR, "Balloc() allocation exceeds list boundary");
}
_THREAD_PRIVATE_MUTEX_LOCK(dtoa_mutex);
if ((rv = freelist[k])) {
freelist[k] = rv->next;
} else {
x = 1 << k;
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
if (!rv) {
_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);
zend_error(E_ERROR, "Balloc() failed to allocate memory");
}
rv->k = k;
rv->maxwds = x;
}
_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);
rv->sign = rv->wds = 0;
return rv;
}
|
126877960775748554954774287335252576908
|
zend_strtod.c
|
330178516637592595167149550690737234647
|
CWE-119
|
CVE-2009-0689
|
Array index error in the (1) dtoa implementation in dtoa.c (aka pdtoa.c) and the (2) gdtoa (aka new dtoa) implementation in gdtoa/misc.c in libc, as used in multiple operating systems and products including in FreeBSD 6.4 and 7.2, NetBSD 5.0, OpenBSD 4.5, Mozilla Firefox 3.0.x before 3.0.15 and 3.5.x before 3.5.4, K-Meleon 1.5.3, SeaMonkey 1.1.8, and other products, allows context-dependent attackers to cause a denial of service (application crash) and possibly execute arbitrary code via a large precision value in the format argument to a printf function, which triggers incorrect memory allocation and a heap-based buffer overflow during conversion to a floating-point number.
|
https://nvd.nist.gov/vuln/detail/CVE-2009-0689
|
202,822
|
ghostpdl
|
5d499272b95a6b890a1397e11d20937de000d31b
|
https://github.com/ArtifexSoftware/ghostpdl
|
https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b
|
Bug 702582, CVE 2020-15900 Memory Corruption in Ghostscript 9.52
Fix the 'rsearch' calculation for the 'post' size to give the correct
size. Previous calculation would result in a size that was too large,
and could underflow to max uint32_t. Also fix 'rsearch' to return the
correct 'pre' string with empty string match.
A future change may 'undefine' this undocumented, non-standard operator
during initialization as we do with the many other non-standard internal
PostScript operators and procedures.
| 1
|
search_impl(i_ctx_t *i_ctx_p, bool forward)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
uint size = r_size(op);
uint count;
byte *pat;
byte *ptr;
byte ch;
int incr = forward ? 1 : -1;
check_read_type(*op1, t_string);
check_read_type(*op, t_string);
if (size > r_size(op1)) { /* can't match */
make_false(op);
return 0;
}
count = r_size(op1) - size;
ptr = op1->value.bytes;
if (size == 0)
goto found;
if (!forward)
ptr += count;
pat = op->value.bytes;
ch = pat[0];
do {
if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))
goto found;
ptr += incr;
}
while (count--);
/* No match */
make_false(op);
return 0;
found:
op->tas.type_attrs = op1->tas.type_attrs;
op->value.bytes = ptr;
r_set_size(op, size);
push(2);
op[-1] = *op1;
r_set_size(op - 1, ptr - op[-1].value.bytes);
op1->value.bytes = ptr + size;
r_set_size(op1, count + (!forward ? (size - 1) : 0));
make_true(op);
return 0;
}
|
86939516891110967185620104740052162316
|
zstring.c
|
72939855407215089106002168079796587202
|
CWE-787
|
CVE-2020-15900
|
A memory corruption issue was found in Artifex Ghostscript 9.50 and 9.52. Use of a non-standard PostScript operator can allow overriding of file access controls. The 'rsearch' calculation for the 'post' size resulted in a size that was too large, and could underflow to max uint32_t. This was fixed in commit 5d499272b95a6b890a1397e11d20937de000d31b.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-15900
|
341,817
|
ghostpdl
|
5d499272b95a6b890a1397e11d20937de000d31b
|
https://github.com/ArtifexSoftware/ghostpdl
|
https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b
|
Bug 702582, CVE 2020-15900 Memory Corruption in Ghostscript 9.52
Fix the 'rsearch' calculation for the 'post' size to give the correct
size. Previous calculation would result in a size that was too large,
and could underflow to max uint32_t. Also fix 'rsearch' to return the
correct 'pre' string with empty string match.
A future change may 'undefine' this undocumented, non-standard operator
during initialization as we do with the many other non-standard internal
PostScript operators and procedures.
| 0
|
search_impl(i_ctx_t *i_ctx_p, bool forward)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
uint size = r_size(op);
uint count;
byte *pat;
byte *ptr;
byte ch;
int incr = forward ? 1 : -1;
check_read_type(*op1, t_string);
check_read_type(*op, t_string);
if (size > r_size(op1)) { /* can't match */
make_false(op);
return 0;
}
count = r_size(op1) - size;
ptr = op1->value.bytes;
if (size == 0)
goto found;
if (!forward)
ptr += count;
pat = op->value.bytes;
ch = pat[0];
do {
if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))
goto found;
ptr += incr;
}
while (count--);
/* No match */
make_false(op);
return 0;
found:
op->tas.type_attrs = op1->tas.type_attrs;
op->value.bytes = ptr; /* match */
op->tas.rsize = size; /* match */
push(2);
op[-1] = *op1; /* pre */
op[-3].value.bytes = ptr + size; /* post */
if (forward) {
op[-1].tas.rsize = ptr - op[-1].value.bytes; /* pre */
op[-3].tas.rsize = count; /* post */
} else {
op[-1].tas.rsize = count; /* pre */
op[-3].tas.rsize -= count + size; /* post */
}
make_true(op);
return 0;
}
|
122691468476432977214258761853397783174
|
zstring.c
|
242560896359670915428991047058679210834
|
CWE-787
|
CVE-2020-15900
|
A memory corruption issue was found in Artifex Ghostscript 9.50 and 9.52. Use of a non-standard PostScript operator can allow overriding of file access controls. The 'rsearch' calculation for the 'post' size resulted in a size that was too large, and could underflow to max uint32_t. This was fixed in commit 5d499272b95a6b890a1397e11d20937de000d31b.
|
https://nvd.nist.gov/vuln/detail/CVE-2020-15900
|
202,888
|
linux
|
ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
esp: Fix possible buffer overflow in ESP transformation
The maximum message size that can be send is bigger than
the maximum site that skb_page_frag_refill can allocate.
So it is possible to write beyond the allocated buffer.
Fix this by doing a fallback to COW in that case.
v2:
Avoid get get_order() costs as suggested by Linus Torvalds.
Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible")
Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible")
Reported-by: valis <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
| 1
|
int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)
{
u8 *tail;
int nfrags;
int esph_offset;
struct page *page;
struct sk_buff *trailer;
int tailen = esp->tailen;
/* this is non-NULL only with TCP/UDP Encapsulation */
if (x->encap) {
int err = esp_output_encap(x, skb, esp);
if (err < 0)
return err;
}
if (!skb_cloned(skb)) {
if (tailen <= skb_tailroom(skb)) {
nfrags = 1;
trailer = skb;
tail = skb_tail_pointer(trailer);
goto skip_cow;
} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)
&& !skb_has_frag_list(skb)) {
int allocsize;
struct sock *sk = skb->sk;
struct page_frag *pfrag = &x->xfrag;
esp->inplace = false;
allocsize = ALIGN(tailen, L1_CACHE_BYTES);
spin_lock_bh(&x->lock);
if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
spin_unlock_bh(&x->lock);
goto cow;
}
page = pfrag->page;
get_page(page);
tail = page_address(page) + pfrag->offset;
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
nfrags = skb_shinfo(skb)->nr_frags;
__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
tailen);
skb_shinfo(skb)->nr_frags = ++nfrags;
pfrag->offset = pfrag->offset + allocsize;
spin_unlock_bh(&x->lock);
nfrags++;
skb->len += tailen;
skb->data_len += tailen;
skb->truesize += tailen;
if (sk && sk_fullsock(sk))
refcount_add(tailen, &sk->sk_wmem_alloc);
goto out;
}
}
cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0)
goto out;
tail = skb_tail_pointer(trailer);
esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
pskb_put(skb, trailer, tailen);
out:
return nfrags;
}
|
111996591465481135953474754686135159337
|
esp4.c
|
169926453254442983322582759592161291384
|
CWE-787
|
CVE-2022-27666
|
A heap buffer overflow flaw was found in IPsec ESP transformation code in net/ipv4/esp4.c and net/ipv6/esp6.c. This flaw allows a local attacker with a normal user privilege to overwrite kernel heap objects and may cause a local privilege escalation threat.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-27666
|
343,175
|
linux
|
ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
esp: Fix possible buffer overflow in ESP transformation
The maximum message size that can be send is bigger than
the maximum site that skb_page_frag_refill can allocate.
So it is possible to write beyond the allocated buffer.
Fix this by doing a fallback to COW in that case.
v2:
Avoid get get_order() costs as suggested by Linus Torvalds.
Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible")
Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible")
Reported-by: valis <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
| 0
|
int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)
{
u8 *tail;
int nfrags;
int esph_offset;
struct page *page;
struct sk_buff *trailer;
int tailen = esp->tailen;
unsigned int allocsz;
/* this is non-NULL only with TCP/UDP Encapsulation */
if (x->encap) {
int err = esp_output_encap(x, skb, esp);
if (err < 0)
return err;
}
allocsz = ALIGN(skb->data_len + tailen, L1_CACHE_BYTES);
if (allocsz > ESP_SKB_FRAG_MAXSIZE)
goto cow;
if (!skb_cloned(skb)) {
if (tailen <= skb_tailroom(skb)) {
nfrags = 1;
trailer = skb;
tail = skb_tail_pointer(trailer);
goto skip_cow;
} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)
&& !skb_has_frag_list(skb)) {
int allocsize;
struct sock *sk = skb->sk;
struct page_frag *pfrag = &x->xfrag;
esp->inplace = false;
allocsize = ALIGN(tailen, L1_CACHE_BYTES);
spin_lock_bh(&x->lock);
if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
spin_unlock_bh(&x->lock);
goto cow;
}
page = pfrag->page;
get_page(page);
tail = page_address(page) + pfrag->offset;
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
nfrags = skb_shinfo(skb)->nr_frags;
__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
tailen);
skb_shinfo(skb)->nr_frags = ++nfrags;
pfrag->offset = pfrag->offset + allocsize;
spin_unlock_bh(&x->lock);
nfrags++;
skb->len += tailen;
skb->data_len += tailen;
skb->truesize += tailen;
if (sk && sk_fullsock(sk))
refcount_add(tailen, &sk->sk_wmem_alloc);
goto out;
}
}
cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0)
goto out;
tail = skb_tail_pointer(trailer);
esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
pskb_put(skb, trailer, tailen);
out:
return nfrags;
}
|
32635591870999159240037878048744247169
|
esp4.c
|
243441935638352226599130061922041332693
|
CWE-787
|
CVE-2022-27666
|
A heap buffer overflow flaw was found in IPsec ESP transformation code in net/ipv4/esp4.c and net/ipv6/esp6.c. This flaw allows a local attacker with a normal user privilege to overwrite kernel heap objects and may cause a local privilege escalation threat.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-27666
|
202,889
|
linux
|
ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
esp: Fix possible buffer overflow in ESP transformation
The maximum message size that can be send is bigger than
the maximum site that skb_page_frag_refill can allocate.
So it is possible to write beyond the allocated buffer.
Fix this by doing a fallback to COW in that case.
v2:
Avoid get get_order() costs as suggested by Linus Torvalds.
Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible")
Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible")
Reported-by: valis <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
| 1
|
int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)
{
u8 *tail;
int nfrags;
int esph_offset;
struct page *page;
struct sk_buff *trailer;
int tailen = esp->tailen;
if (x->encap) {
int err = esp6_output_encap(x, skb, esp);
if (err < 0)
return err;
}
if (!skb_cloned(skb)) {
if (tailen <= skb_tailroom(skb)) {
nfrags = 1;
trailer = skb;
tail = skb_tail_pointer(trailer);
goto skip_cow;
} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)
&& !skb_has_frag_list(skb)) {
int allocsize;
struct sock *sk = skb->sk;
struct page_frag *pfrag = &x->xfrag;
esp->inplace = false;
allocsize = ALIGN(tailen, L1_CACHE_BYTES);
spin_lock_bh(&x->lock);
if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
spin_unlock_bh(&x->lock);
goto cow;
}
page = pfrag->page;
get_page(page);
tail = page_address(page) + pfrag->offset;
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
nfrags = skb_shinfo(skb)->nr_frags;
__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
tailen);
skb_shinfo(skb)->nr_frags = ++nfrags;
pfrag->offset = pfrag->offset + allocsize;
spin_unlock_bh(&x->lock);
nfrags++;
skb->len += tailen;
skb->data_len += tailen;
skb->truesize += tailen;
if (sk && sk_fullsock(sk))
refcount_add(tailen, &sk->sk_wmem_alloc);
goto out;
}
}
cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0)
goto out;
tail = skb_tail_pointer(trailer);
esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
pskb_put(skb, trailer, tailen);
out:
return nfrags;
}
|
288301041182247062764395753908590668676
|
esp6.c
|
297879342136766332467148715516497305667
|
CWE-787
|
CVE-2022-27666
|
A heap buffer overflow flaw was found in IPsec ESP transformation code in net/ipv4/esp4.c and net/ipv6/esp6.c. This flaw allows a local attacker with a normal user privilege to overwrite kernel heap objects and may cause a local privilege escalation threat.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-27666
|
343,158
|
linux
|
ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/ebe48d368e97d007bfeb76fcb065d6cfc4c96645
|
esp: Fix possible buffer overflow in ESP transformation
The maximum message size that can be send is bigger than
the maximum site that skb_page_frag_refill can allocate.
So it is possible to write beyond the allocated buffer.
Fix this by doing a fallback to COW in that case.
v2:
Avoid get get_order() costs as suggested by Linus Torvalds.
Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible")
Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible")
Reported-by: valis <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
| 0
|
int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)
{
u8 *tail;
int nfrags;
int esph_offset;
struct page *page;
struct sk_buff *trailer;
int tailen = esp->tailen;
unsigned int allocsz;
if (x->encap) {
int err = esp6_output_encap(x, skb, esp);
if (err < 0)
return err;
}
allocsz = ALIGN(skb->data_len + tailen, L1_CACHE_BYTES);
if (allocsz > ESP_SKB_FRAG_MAXSIZE)
goto cow;
if (!skb_cloned(skb)) {
if (tailen <= skb_tailroom(skb)) {
nfrags = 1;
trailer = skb;
tail = skb_tail_pointer(trailer);
goto skip_cow;
} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)
&& !skb_has_frag_list(skb)) {
int allocsize;
struct sock *sk = skb->sk;
struct page_frag *pfrag = &x->xfrag;
esp->inplace = false;
allocsize = ALIGN(tailen, L1_CACHE_BYTES);
spin_lock_bh(&x->lock);
if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
spin_unlock_bh(&x->lock);
goto cow;
}
page = pfrag->page;
get_page(page);
tail = page_address(page) + pfrag->offset;
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
nfrags = skb_shinfo(skb)->nr_frags;
__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
tailen);
skb_shinfo(skb)->nr_frags = ++nfrags;
pfrag->offset = pfrag->offset + allocsize;
spin_unlock_bh(&x->lock);
nfrags++;
skb->len += tailen;
skb->data_len += tailen;
skb->truesize += tailen;
if (sk && sk_fullsock(sk))
refcount_add(tailen, &sk->sk_wmem_alloc);
goto out;
}
}
cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0)
goto out;
tail = skb_tail_pointer(trailer);
esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
pskb_put(skb, trailer, tailen);
out:
return nfrags;
}
|
5299017131743026733431501074283607591
|
esp6.c
|
272053559916260151312940536238291966334
|
CWE-787
|
CVE-2022-27666
|
A heap buffer overflow flaw was found in IPsec ESP transformation code in net/ipv4/esp4.c and net/ipv6/esp6.c. This flaw allows a local attacker with a normal user privilege to overwrite kernel heap objects and may cause a local privilege escalation threat.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-27666
|
202,892
|
pure-ftpd
|
37ad222868e52271905b94afea4fc780d83294b4
|
https://github.com/jedisct1/pure-ftpd
|
https://github.com/jedisct1/pure-ftpd/commit/37ad222868e52271905b94afea4fc780d83294b4
|
Initialize the max upload file size when quotas are enabled
Due to an unwanted check, files causing the quota to be exceeded
were deleted after the upload, but not during the upload.
The bug was introduced in 2009 in version 1.0.23
Spotted by @DroidTest, thanks!
| 1
|
void dostor(char *name, const int append, const int autorename)
{
ULHandler ulhandler;
int f;
const char *ul_name = NULL;
const char *atomic_file = NULL;
off_t filesize = (off_t) 0U;
struct stat st;
double started = 0.0;
signed char overwrite = 0;
int overflow = 0;
int ret = -1;
off_t max_filesize = (off_t) -1;
#ifdef QUOTAS
Quota quota;
#endif
const char *name2 = NULL;
if (type < 1 || (type == 1 && restartat > (off_t) 1)) {
addreply_noformat(503, MSG_NO_ASCII_RESUME);
goto end;
}
#ifndef ANON_CAN_RESUME
if (guest != 0 && anon_noupload != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
goto end;
}
#endif
if (ul_check_free_space(name, -1.0) == 0) {
addreply_noformat(552, MSG_NO_DISK_SPACE);
goto end;
}
if (checknamesanity(name, dot_write_ok) != 0) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (autorename != 0) {
no_truncate = 1;
}
if (restartat > (off_t) 0 || no_truncate != 0) {
if ((atomic_file = get_atomic_file(name)) == NULL) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (restartat > (off_t) 0 &&
rename(name, atomic_file) != 0 && errno != ENOENT) {
error(553, MSG_RENAME_FAILURE);
atomic_file = NULL;
goto end;
}
}
if (atomic_file != NULL) {
ul_name = atomic_file;
} else {
ul_name = name;
}
if (atomic_file == NULL &&
(f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {
overwrite++;
} else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,
(mode_t) 0777 & ~u_mask)) == -1) {
error(553, MSG_OPEN_FAILURE2);
goto end;
}
if (fstat(f, &st) < 0) {
(void) close(f);
error(553, MSG_STAT_FAILURE2);
goto end;
}
if (!S_ISREG(st.st_mode)) {
(void) close(f);
addreply_noformat(550, MSG_NOT_REGULAR_FILE);
goto end;
}
alarm(MAX_SESSION_XFER_IDLE);
/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior */
if (st.st_size > (off_t) 0) {
#ifndef ANON_CAN_RESUME
if (guest != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
(void) close(f);
goto end;
}
#endif
if (append != 0) {
restartat = st.st_size;
}
} else {
restartat = (off_t) 0;
}
if (restartat > st.st_size) {
restartat = st.st_size;
}
if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {
(void) close(f);
error(451, "seek");
goto end;
}
if (restartat < st.st_size) {
if (ftruncate(f, restartat) < 0) {
(void) close(f);
error(451, "ftruncate");
goto end;
}
#ifdef QUOTAS
if (restartat != st.st_size) {
(void) quota_update(NULL, 0LL,
(long long) (restartat - st.st_size),
&overflow);
}
#endif
}
#ifdef QUOTAS
if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&
(overflow > 0 || quota.files >= user_quota_files ||
quota.size > user_quota_size ||
(max_filesize >= (off_t) 0 &&
(max_filesize = user_quota_size - quota.size) < (off_t) 0))) {
overflow = 1;
(void) close(f);
goto afterquota;
}
#endif
opendata();
if (xferfd == -1) {
(void) close(f);
goto end;
}
doreply();
# ifdef WITH_TLS
if (data_protection_level == CPL_PRIVATE) {
tls_init_data_session(xferfd, passive);
}
# endif
state_needs_update = 1;
setprocessname("pure-ftpd (UPLOAD)");
filesize = restartat;
#ifdef FTPWHO
if (shm_data_cur != NULL) {
const size_t sl = strlen(name);
ftpwho_lock();
shm_data_cur->state = FTPWHO_STATE_UPLOAD;
shm_data_cur->download_total_size = (off_t) 0U;
shm_data_cur->download_current_size = (off_t) filesize;
shm_data_cur->restartat = restartat;
(void) time(&shm_data_cur->xfer_date);
if (sl < sizeof shm_data_cur->filename) {
memcpy(shm_data_cur->filename, name, sl);
shm_data_cur->filename[sl] = 0;
} else {
memcpy(shm_data_cur->filename,
&name[sl - sizeof shm_data_cur->filename - 1U],
sizeof shm_data_cur->filename);
}
ftpwho_unlock();
}
#endif
/* Here starts the real upload code */
started = get_usec_time();
if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,
restartat, type == 1, throttling_bandwidth_ul,
max_filesize) == 0) {
ret = ul_send(&ulhandler);
ul_exit(&ulhandler);
} else {
ret = -1;
}
(void) close(f);
closedata();
/* Here ends the real upload code */
#ifdef SHOW_REAL_DISK_SPACE
if (FSTATFS(f, &statfsbuf) == 0) {
double space;
space = (double) STATFS_BAVAIL(statfsbuf) *
(double) STATFS_FRSIZE(statfsbuf);
if (space > 524288.0) {
addreply(0, MSG_SPACE_FREE_M, space / 1048576.0);
} else {
addreply(0, MSG_SPACE_FREE_K, space / 1024.0);
}
}
#endif
uploaded += (unsigned long long) ulhandler.total_uploaded;
{
off_t atomic_file_size;
off_t original_file_size;
int files_count;
if (overwrite == 0) {
files_count = 1;
} else {
files_count = 0;
}
if (autorename != 0 && restartat == (off_t) 0) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if (tryautorename(atomic_file, name, &name2) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);
#endif
atomic_file = NULL;
}
} else if (atomic_file != NULL) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if ((original_file_size = get_file_size(name)) < (off_t) 0 ||
restartat > original_file_size) {
original_file_size = restartat;
}
if (rename(atomic_file, name) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, atomic_file_size - original_file_size);
#endif
atomic_file = NULL;
}
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, ulhandler.total_uploaded);
#endif
}
}
afterquota:
if (overflow > 0) {
addreply(552, MSG_QUOTA_EXCEEDED, name);
} else {
if (ret == 0) {
addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);
} else {
addreply_noformat(451, MSG_ABORTED);
}
displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,
name2 ? name2 : name, 1);
}
end:
restartat = (off_t) 0;
if (atomic_file != NULL) {
unlink(atomic_file);
atomic_file = NULL;
}
}
|
206214968854253605299556693579818029977
|
ftpd.c
|
235084351397611292950237183012549023004
|
CWE-434
|
CVE-2021-40524
|
In Pure-FTPd before 1.0.50, an incorrect max_filesize quota mechanism in the server allows attackers to upload files of unbounded size, which may lead to denial of service or a server hang. This occurs because a certain greater-than-zero test does not anticipate an initial -1 value. (Versions 1.0.23 through 1.0.49 are affected.)
|
https://nvd.nist.gov/vuln/detail/CVE-2021-40524
|
343,298
|
pure-ftpd
|
37ad222868e52271905b94afea4fc780d83294b4
|
https://github.com/jedisct1/pure-ftpd
|
https://github.com/jedisct1/pure-ftpd/commit/37ad222868e52271905b94afea4fc780d83294b4
|
Initialize the max upload file size when quotas are enabled
Due to an unwanted check, files causing the quota to be exceeded
were deleted after the upload, but not during the upload.
The bug was introduced in 2009 in version 1.0.23
Spotted by @DroidTest, thanks!
| 0
|
void dostor(char *name, const int append, const int autorename)
{
ULHandler ulhandler;
int f;
const char *ul_name = NULL;
const char *atomic_file = NULL;
off_t filesize = (off_t) 0U;
struct stat st;
double started = 0.0;
signed char overwrite = 0;
int overflow = 0;
int ret = -1;
off_t max_filesize = (off_t) -1;
#ifdef QUOTAS
Quota quota;
#endif
const char *name2 = NULL;
if (type < 1 || (type == 1 && restartat > (off_t) 1)) {
addreply_noformat(503, MSG_NO_ASCII_RESUME);
goto end;
}
#ifndef ANON_CAN_RESUME
if (guest != 0 && anon_noupload != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
goto end;
}
#endif
if (ul_check_free_space(name, -1.0) == 0) {
addreply_noformat(552, MSG_NO_DISK_SPACE);
goto end;
}
if (checknamesanity(name, dot_write_ok) != 0) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (autorename != 0) {
no_truncate = 1;
}
if (restartat > (off_t) 0 || no_truncate != 0) {
if ((atomic_file = get_atomic_file(name)) == NULL) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (restartat > (off_t) 0 &&
rename(name, atomic_file) != 0 && errno != ENOENT) {
error(553, MSG_RENAME_FAILURE);
atomic_file = NULL;
goto end;
}
}
if (atomic_file != NULL) {
ul_name = atomic_file;
} else {
ul_name = name;
}
if (atomic_file == NULL &&
(f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {
overwrite++;
} else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,
(mode_t) 0777 & ~u_mask)) == -1) {
error(553, MSG_OPEN_FAILURE2);
goto end;
}
if (fstat(f, &st) < 0) {
(void) close(f);
error(553, MSG_STAT_FAILURE2);
goto end;
}
if (!S_ISREG(st.st_mode)) {
(void) close(f);
addreply_noformat(550, MSG_NOT_REGULAR_FILE);
goto end;
}
alarm(MAX_SESSION_XFER_IDLE);
/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior */
if (st.st_size > (off_t) 0) {
#ifndef ANON_CAN_RESUME
if (guest != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
(void) close(f);
goto end;
}
#endif
if (append != 0) {
restartat = st.st_size;
}
} else {
restartat = (off_t) 0;
}
if (restartat > st.st_size) {
restartat = st.st_size;
}
if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {
(void) close(f);
error(451, "seek");
goto end;
}
if (restartat < st.st_size) {
if (ftruncate(f, restartat) < 0) {
(void) close(f);
error(451, "ftruncate");
goto end;
}
#ifdef QUOTAS
if (restartat != st.st_size) {
(void) quota_update(NULL, 0LL,
(long long) (restartat - st.st_size),
&overflow);
}
#endif
}
#ifdef QUOTAS
if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&
(overflow > 0 || quota.files >= user_quota_files ||
quota.size > user_quota_size ||
(max_filesize = user_quota_size - quota.size) < (off_t) 0)) {
overflow = 1;
(void) close(f);
goto afterquota;
}
#endif
opendata();
if (xferfd == -1) {
(void) close(f);
goto end;
}
doreply();
# ifdef WITH_TLS
if (data_protection_level == CPL_PRIVATE) {
tls_init_data_session(xferfd, passive);
}
# endif
state_needs_update = 1;
setprocessname("pure-ftpd (UPLOAD)");
filesize = restartat;
#ifdef FTPWHO
if (shm_data_cur != NULL) {
const size_t sl = strlen(name);
ftpwho_lock();
shm_data_cur->state = FTPWHO_STATE_UPLOAD;
shm_data_cur->download_total_size = (off_t) 0U;
shm_data_cur->download_current_size = (off_t) filesize;
shm_data_cur->restartat = restartat;
(void) time(&shm_data_cur->xfer_date);
if (sl < sizeof shm_data_cur->filename) {
memcpy(shm_data_cur->filename, name, sl);
shm_data_cur->filename[sl] = 0;
} else {
memcpy(shm_data_cur->filename,
&name[sl - sizeof shm_data_cur->filename - 1U],
sizeof shm_data_cur->filename);
}
ftpwho_unlock();
}
#endif
/* Here starts the real upload code */
started = get_usec_time();
if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,
restartat, type == 1, throttling_bandwidth_ul,
max_filesize) == 0) {
ret = ul_send(&ulhandler);
ul_exit(&ulhandler);
} else {
ret = -1;
}
(void) close(f);
closedata();
/* Here ends the real upload code */
#ifdef SHOW_REAL_DISK_SPACE
if (FSTATFS(f, &statfsbuf) == 0) {
double space;
space = (double) STATFS_BAVAIL(statfsbuf) *
(double) STATFS_FRSIZE(statfsbuf);
if (space > 524288.0) {
addreply(0, MSG_SPACE_FREE_M, space / 1048576.0);
} else {
addreply(0, MSG_SPACE_FREE_K, space / 1024.0);
}
}
#endif
uploaded += (unsigned long long) ulhandler.total_uploaded;
{
off_t atomic_file_size;
off_t original_file_size;
int files_count;
if (overwrite == 0) {
files_count = 1;
} else {
files_count = 0;
}
if (autorename != 0 && restartat == (off_t) 0) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if (tryautorename(atomic_file, name, &name2) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);
#endif
atomic_file = NULL;
}
} else if (atomic_file != NULL) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if ((original_file_size = get_file_size(name)) < (off_t) 0 ||
restartat > original_file_size) {
original_file_size = restartat;
}
if (rename(atomic_file, name) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, atomic_file_size - original_file_size);
#endif
atomic_file = NULL;
}
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, ulhandler.total_uploaded);
#endif
}
}
afterquota:
if (overflow > 0) {
addreply(552, MSG_QUOTA_EXCEEDED, name);
} else {
if (ret == 0) {
addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);
} else {
addreply_noformat(451, MSG_ABORTED);
}
displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,
name2 ? name2 : name, 1);
}
end:
restartat = (off_t) 0;
if (atomic_file != NULL) {
unlink(atomic_file);
atomic_file = NULL;
}
}
|
189507601171684383524883387321805614234
|
ftpd.c
|
102895278505023286855651896148239525136
|
CWE-434
|
CVE-2021-40524
|
In Pure-FTPd before 1.0.50, an incorrect max_filesize quota mechanism in the server allows attackers to upload files of unbounded size, which may lead to denial of service or a server hang. This occurs because a certain greater-than-zero test does not anticipate an initial -1 value. (Versions 1.0.23 through 1.0.49 are affected.)
|
https://nvd.nist.gov/vuln/detail/CVE-2021-40524
|
202,943
|
lua
|
42d40581dd919fb134c07027ca1ce0844c670daf
|
https://github.com/lua/lua
|
https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf
|
Save stack space while handling errors
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.
This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error".
| 1
|
l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
CallInfo *ci = L->ci;
const char *msg;
va_list argp;
luaC_checkGC(L); /* error message uses memory */
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
va_end(argp);
if (isLua(ci)) /* if Lua function, add source:line information */
luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
luaG_errormsg(L);
}
|
326823398637399129975364476390386969104
|
ldebug.c
|
317295124781077525458993227148135997551
|
CWE-787
|
CVE-2022-33099
|
An issue in the component luaG_runerror of Lua v5.4.4 and below leads to a heap-buffer overflow when a recursive error occurs.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-33099
|
344,242
|
lua
|
42d40581dd919fb134c07027ca1ce0844c670daf
|
https://github.com/lua/lua
|
https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf
|
Save stack space while handling errors
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.
This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error".
| 0
|
l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
CallInfo *ci = L->ci;
const char *msg;
va_list argp;
luaC_checkGC(L); /* error message uses memory */
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
va_end(argp);
if (isLua(ci)) { /* if Lua function, add source:line information */
luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */
L->top--;
}
luaG_errormsg(L);
}
|
213182302759646008213936194965010984301
|
None
|
CWE-787
|
CVE-2022-33099
|
An issue in the component luaG_runerror of Lua v5.4.4 and below leads to a heap-buffer overflow when a recursive error occurs.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-33099
|
|
203,614
|
linux
|
a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7
|
video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write
In pxa3xx_gcu_write, a count parameter of type size_t is passed to words of
type int. Then, copy_from_user() may cause a heap overflow because it is used
as the third argument of copy_from_user().
Signed-off-by: Hyunwoo Kim <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
| 1
|
pxa3xx_gcu_write(struct file *file, const char *buff,
size_t count, loff_t *offp)
{
int ret;
unsigned long flags;
struct pxa3xx_gcu_batch *buffer;
struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
int words = count / 4;
/* Does not need to be atomic. There's a lock in user space,
* but anyhow, this is just for statistics. */
priv->shared->num_writes++;
priv->shared->num_words += words;
/* Last word reserved for batch buffer end command */
if (words >= PXA3XX_GCU_BATCH_WORDS)
return -E2BIG;
/* Wait for a free buffer */
if (!priv->free) {
ret = pxa3xx_gcu_wait_free(priv);
if (ret < 0)
return ret;
}
/*
* Get buffer from free list
*/
spin_lock_irqsave(&priv->spinlock, flags);
buffer = priv->free;
priv->free = buffer->next;
spin_unlock_irqrestore(&priv->spinlock, flags);
/* Copy data from user into buffer */
ret = copy_from_user(buffer->ptr, buff, words * 4);
if (ret) {
spin_lock_irqsave(&priv->spinlock, flags);
buffer->next = priv->free;
priv->free = buffer;
spin_unlock_irqrestore(&priv->spinlock, flags);
return -EFAULT;
}
buffer->length = words;
/* Append batch buffer end command */
buffer->ptr[words] = 0x01000000;
/*
* Add buffer to ready list
*/
spin_lock_irqsave(&priv->spinlock, flags);
buffer->next = NULL;
if (priv->ready) {
BUG_ON(priv->ready_last == NULL);
priv->ready_last->next = buffer;
} else
priv->ready = buffer;
priv->ready_last = buffer;
if (!priv->shared->hw_running)
run_ready(priv);
spin_unlock_irqrestore(&priv->spinlock, flags);
return words * 4;
}
|
295091935056220827099180820590433673308
|
pxa3xx-gcu.c
|
328263488920768374085149640831046958332
|
CWE-703
|
CVE-2022-39842
|
An issue was discovered in the Linux kernel before 5.19. In pxa3xx_gcu_write in drivers/video/fbdev/pxa3xx-gcu.c, the count parameter has a type conflict of size_t versus int, causing an integer overflow and bypassing the size check. After that, because it is used as the third argument to copy_from_user(), a heap overflow may occur. NOTE: the original discoverer disputes that the overflow can actually happen.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-39842
|
345,131
|
linux
|
a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7
|
video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write
In pxa3xx_gcu_write, a count parameter of type size_t is passed to words of
type int. Then, copy_from_user() may cause a heap overflow because it is used
as the third argument of copy_from_user().
Signed-off-by: Hyunwoo Kim <[email protected]>
Signed-off-by: Helge Deller <[email protected]>
| 0
|
pxa3xx_gcu_write(struct file *file, const char *buff,
size_t count, loff_t *offp)
{
int ret;
unsigned long flags;
struct pxa3xx_gcu_batch *buffer;
struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
size_t words = count / 4;
/* Does not need to be atomic. There's a lock in user space,
* but anyhow, this is just for statistics. */
priv->shared->num_writes++;
priv->shared->num_words += words;
/* Last word reserved for batch buffer end command */
if (words >= PXA3XX_GCU_BATCH_WORDS)
return -E2BIG;
/* Wait for a free buffer */
if (!priv->free) {
ret = pxa3xx_gcu_wait_free(priv);
if (ret < 0)
return ret;
}
/*
* Get buffer from free list
*/
spin_lock_irqsave(&priv->spinlock, flags);
buffer = priv->free;
priv->free = buffer->next;
spin_unlock_irqrestore(&priv->spinlock, flags);
/* Copy data from user into buffer */
ret = copy_from_user(buffer->ptr, buff, words * 4);
if (ret) {
spin_lock_irqsave(&priv->spinlock, flags);
buffer->next = priv->free;
priv->free = buffer;
spin_unlock_irqrestore(&priv->spinlock, flags);
return -EFAULT;
}
buffer->length = words;
/* Append batch buffer end command */
buffer->ptr[words] = 0x01000000;
/*
* Add buffer to ready list
*/
spin_lock_irqsave(&priv->spinlock, flags);
buffer->next = NULL;
if (priv->ready) {
BUG_ON(priv->ready_last == NULL);
priv->ready_last->next = buffer;
} else
priv->ready = buffer;
priv->ready_last = buffer;
if (!priv->shared->hw_running)
run_ready(priv);
spin_unlock_irqrestore(&priv->spinlock, flags);
return words * 4;
}
|
130082292833953650664570449389673394925
|
pxa3xx-gcu.c
|
198658222992962284307702769824081313722
|
CWE-703
|
CVE-2022-39842
|
An issue was discovered in the Linux kernel before 5.19. In pxa3xx_gcu_write in drivers/video/fbdev/pxa3xx-gcu.c, the count parameter has a type conflict of size_t versus int, causing an integer overflow and bypassing the size check. After that, because it is used as the third argument to copy_from_user(), a heap overflow may occur. NOTE: the original discoverer disputes that the overflow can actually happen.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-39842
|
203,902
|
vim
|
4748c4bd64610cf943a431d215bb1aad51f8d0b4
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/4748c4bd64610cf943a431d215bb1aad51f8d0b4
|
patch 8.2.4974: ":so" command may read after end of buffer
Problem: ":so" command may read after end of buffer.
Solution: Compute length of text properly.
| 1
|
get_one_sourceline(source_cookie_T *sp)
{
garray_T ga;
int len;
int c;
char_u *buf;
#ifdef USE_CRNL
int has_cr; // CR-LF found
#endif
int have_read = FALSE;
// use a growarray to store the sourced line
ga_init2(&ga, 1, 250);
// Loop until there is a finished line (or end-of-file).
++sp->sourcing_lnum;
for (;;)
{
// make room to read at least 120 (more) characters
if (ga_grow(&ga, 120) == FAIL)
break;
if (sp->source_from_buf)
{
if (sp->buf_lnum >= sp->buflines.ga_len)
break; // all the lines are processed
ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);
sp->buf_lnum++;
if (ga_grow(&ga, 1) == FAIL)
break;
buf = (char_u *)ga.ga_data;
buf[ga.ga_len++] = NUL;
}
else
{
buf = (char_u *)ga.ga_data;
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL)
break;
}
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
#ifdef USE_CRNL
// Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the
// CTRL-Z by its own, or after a NL.
if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n'))
&& sp->fileformat == EOL_DOS
&& buf[len - 1] == Ctrl_Z)
{
buf[len - 1] = NUL;
break;
}
#endif
have_read = TRUE;
ga.ga_len = len;
// If the line was longer than the buffer, read more.
if (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\n')
continue;
if (len >= 1 && buf[len - 1] == '\n') // remove trailing NL
{
#ifdef USE_CRNL
has_cr = (len >= 2 && buf[len - 2] == '\r');
if (sp->fileformat == EOL_UNKNOWN)
{
if (has_cr)
sp->fileformat = EOL_DOS;
else
sp->fileformat = EOL_UNIX;
}
if (sp->fileformat == EOL_DOS)
{
if (has_cr) // replace trailing CR
{
buf[len - 2] = '\n';
--len;
--ga.ga_len;
}
else // lines like ":map xx yy^M" will have failed
{
if (!sp->error)
{
msg_source(HL_ATTR(HLF_W));
emsg(_("W15: Warning: Wrong line separator, ^M may be missing"));
}
sp->error = TRUE;
sp->fileformat = EOL_UNIX;
}
}
#endif
// The '\n' is escaped if there is an odd number of ^V's just
// before it, first set "c" just before the 'V's and then check
// len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo
for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)
;
if ((len & 1) != (c & 1)) // escaped NL, read more
{
++sp->sourcing_lnum;
continue;
}
buf[len - 1] = NUL; // remove the NL
}
// Check for ^C here now and then, so recursive :so can be broken.
line_breakcheck();
break;
}
if (have_read)
return (char_u *)ga.ga_data;
vim_free(ga.ga_data);
return NULL;
}
|
227828882376561631125996314087212654807
|
scriptfile.c
|
113985695348083727862524217442557990815
|
CWE-703
|
CVE-2022-1769
|
Buffer Over-read in GitHub repository vim/vim prior to 8.2.4974.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1769
|
346,415
|
vim
|
4748c4bd64610cf943a431d215bb1aad51f8d0b4
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/4748c4bd64610cf943a431d215bb1aad51f8d0b4
|
patch 8.2.4974: ":so" command may read after end of buffer
Problem: ":so" command may read after end of buffer.
Solution: Compute length of text properly.
| 0
|
get_one_sourceline(source_cookie_T *sp)
{
garray_T ga;
int len;
int c;
char_u *buf;
#ifdef USE_CRNL
int has_cr; // CR-LF found
#endif
int have_read = FALSE;
// use a growarray to store the sourced line
ga_init2(&ga, 1, 250);
// Loop until there is a finished line (or end-of-file).
++sp->sourcing_lnum;
for (;;)
{
// make room to read at least 120 (more) characters
if (ga_grow(&ga, 120) == FAIL)
break;
if (sp->source_from_buf)
{
if (sp->buf_lnum >= sp->buflines.ga_len)
break; // all the lines are processed
ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]);
sp->buf_lnum++;
if (ga_grow(&ga, 1) == FAIL)
break;
buf = (char_u *)ga.ga_data;
buf[ga.ga_len++] = NUL;
len = ga.ga_len;
}
else
{
buf = (char_u *)ga.ga_data;
if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len,
sp->fp) == NULL)
break;
len = ga.ga_len + (int)STRLEN(buf + ga.ga_len);
}
#ifdef USE_CRNL
// Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the
// CTRL-Z by its own, or after a NL.
if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n'))
&& sp->fileformat == EOL_DOS
&& buf[len - 1] == Ctrl_Z)
{
buf[len - 1] = NUL;
break;
}
#endif
have_read = TRUE;
ga.ga_len = len;
// If the line was longer than the buffer, read more.
if (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\n')
continue;
if (len >= 1 && buf[len - 1] == '\n') // remove trailing NL
{
#ifdef USE_CRNL
has_cr = (len >= 2 && buf[len - 2] == '\r');
if (sp->fileformat == EOL_UNKNOWN)
{
if (has_cr)
sp->fileformat = EOL_DOS;
else
sp->fileformat = EOL_UNIX;
}
if (sp->fileformat == EOL_DOS)
{
if (has_cr) // replace trailing CR
{
buf[len - 2] = '\n';
--len;
--ga.ga_len;
}
else // lines like ":map xx yy^M" will have failed
{
if (!sp->error)
{
msg_source(HL_ATTR(HLF_W));
emsg(_("W15: Warning: Wrong line separator, ^M may be missing"));
}
sp->error = TRUE;
sp->fileformat = EOL_UNIX;
}
}
#endif
// The '\n' is escaped if there is an odd number of ^V's just
// before it, first set "c" just before the 'V's and then check
// len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo
for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--)
;
if ((len & 1) != (c & 1)) // escaped NL, read more
{
++sp->sourcing_lnum;
continue;
}
buf[len - 1] = NUL; // remove the NL
}
// Check for ^C here now and then, so recursive :so can be broken.
line_breakcheck();
break;
}
if (have_read)
return (char_u *)ga.ga_data;
vim_free(ga.ga_data);
return NULL;
}
|
178235949916864624695352217723493381575
|
scriptfile.c
|
185541822912914842655555626416100401533
|
CWE-703
|
CVE-2022-1769
|
Buffer Over-read in GitHub repository vim/vim prior to 8.2.4974.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1769
|
204,016
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 1
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
squashfs_dir_header_2 dirh;
char buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
squashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer;
long long start;
int bytes = 0;
int dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 0)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes;
while(bytes < size) {
if(swap) {
squashfs_dir_header_2 sdirh;
res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));
if(res)
SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh);
} else
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
if(swap) {
squashfs_dir_entry_2 sdire;
res = read_directory_data(&sdire, &start,
&offset, sizeof(sdire));
if(res)
SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire);
} else
res = read_directory_data(dire, &start,
&offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
285801527234841078419372065290976958053
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
349,259
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 0
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
squashfs_dir_header_3 dirh;
char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;
long long start;
int bytes = 0;
int dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
if(swap) {
squashfs_dir_header_3 sdirh;
res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));
if(res)
SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);
} else
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
if(swap) {
squashfs_dir_entry_3 sdire;
res = read_directory_data(&sdire, &start,
&offset, sizeof(sdire));
if(res)
SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);
} else
res = read_directory_data(dire, &start,
&offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
/* check directory for duplicate names and sorting */
if(check_directory(dir) == FALSE) {
ERROR("File system corrupted: directory has duplicate names or is unsorted\n");
goto corrupted;
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
329567721656130311991352890320471862864
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
204,017
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 1
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
squashfs_dir_header_3 dirh;
char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;
long long start;
int bytes = 0;
int dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
if(swap) {
squashfs_dir_header_3 sdirh;
res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));
if(res)
SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);
} else
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
if(swap) {
squashfs_dir_entry_3 sdire;
res = read_directory_data(&sdire, &start,
&offset, sizeof(sdire));
if(res)
SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);
} else
res = read_directory_data(dire, &start,
&offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
255918777018822290262253660606481852296
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
349,259
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 0
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
squashfs_dir_header_3 dirh;
char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;
long long start;
int bytes = 0;
int dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
if(swap) {
squashfs_dir_header_3 sdirh;
res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));
if(res)
SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);
} else
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
if(swap) {
squashfs_dir_entry_3 sdire;
res = read_directory_data(&sdire, &start,
&offset, sizeof(sdire));
if(res)
SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);
} else
res = read_directory_data(dire, &start,
&offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
/* check directory for duplicate names and sorting */
if(check_directory(dir) == FALSE) {
ERROR("File system corrupted: directory has duplicate names or is unsorted\n");
goto corrupted;
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
329567721656130311991352890320471862864
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
204,019
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 1
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
struct squashfs_dir_header dirh;
char buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
struct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer;
long long start;
int bytes = 0, dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
SQUASHFS_INSWAP_DIR_HEADER(&dirh);
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
res = read_directory_data(dire, &start, &offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
SQUASHFS_INSWAP_DIR_ENTRY(dire);
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
201112194066190404081281072830763464085
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
349,251
|
squashfs-tools
|
e0485802ec72996c20026da320650d8362f555bd
|
https://github.com/plougher/squashfs-tools
|
https://github.com/plougher/squashfs-tools/commit/e0485802ec72996c20026da320650d8362f555bd
|
Unsquashfs: additional write outside destination directory exploit fix
An issue on github (https://github.com/plougher/squashfs-tools/issues/72)
showed how some specially crafted Squashfs filesystems containing
invalid file names (with '/' and '..') can cause Unsquashfs to write
files outside of the destination directory.
Since then it has been shown that specially crafted Squashfs filesystems
that contain a symbolic link pointing outside of the destination directory,
coupled with an identically named file within the same directory, can
cause Unsquashfs to write files outside of the destination directory.
Specifically the symbolic link produces a pathname pointing outside
of the destination directory, which is then followed when writing the
duplicate identically named file within the directory.
This commit fixes this exploit by explictly checking for duplicate
filenames within a directory. As directories in v2.1, v3.x, and v4.0
filesystems are sorted, this is achieved by checking for consecutively
identical filenames. Additionally directories are checked to
ensure they are sorted, to avoid attempts to evade the duplicate
check.
Version 1.x and 2.0 filesystems (where the directories were unsorted)
are sorted and then the above duplicate filename check is applied.
Signed-off-by: Phillip Lougher <[email protected]>
| 0
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
struct squashfs_dir_header dirh;
char buffer[sizeof(struct squashfs_dir_entry) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
struct squashfs_dir_entry *dire = (struct squashfs_dir_entry *) buffer;
long long start;
int bytes = 0, dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
SQUASHFS_INSWAP_DIR_HEADER(&dirh);
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
res = read_directory_data(dire, &start, &offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
SQUASHFS_INSWAP_DIR_ENTRY(dire);
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
/* check directory for duplicate names and sorting */
if(check_directory(dir) == FALSE) {
ERROR("File system corrupted: directory has duplicate names or is unsorted\n");
goto corrupted;
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
|
101994300630246920373110387154385179099
|
None
|
CWE-200
|
CVE-2021-41072
|
squashfs_opendir in unsquash-2.c in Squashfs-Tools 4.5 allows Directory Traversal, a different vulnerability than CVE-2021-40153. A squashfs filesystem that has been crafted to include a symbolic link and then contents under the same filename in a filesystem can cause unsquashfs to first create the symbolic link pointing outside the expected directory, and then the subsequent write operation will cause the unsquashfs process to write through the symbolic link elsewhere in the filesystem.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41072
|
|
204,032
|
linux
|
1d0688421449718c6c5f46e458a378c9b530ba18
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1d0688421449718c6c5f46e458a378c9b530ba18
|
Bluetooth: virtio_bt: fix memory leak in virtbt_rx_handle()
On the reception of packets with an invalid packet type, the memory of
the allocated socket buffers is never freed. Add a default case that frees
these to avoid a memory leak.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Signed-off-by: Soenke Huster <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
| 1
|
static void virtbt_rx_handle(struct virtio_bluetooth *vbt, struct sk_buff *skb)
{
__u8 pkt_type;
pkt_type = *((__u8 *) skb->data);
skb_pull(skb, 1);
switch (pkt_type) {
case HCI_EVENT_PKT:
case HCI_ACLDATA_PKT:
case HCI_SCODATA_PKT:
case HCI_ISODATA_PKT:
hci_skb_pkt_type(skb) = pkt_type;
hci_recv_frame(vbt->hdev, skb);
break;
}
}
|
317953678093244017346219057450366042536
|
virtio_bt.c
|
236732335469257962390870321221153262680
|
CWE-772
|
CVE-2022-26878
|
drivers/bluetooth/virtio_bt.c in the Linux kernel before 5.16.3 has a memory leak (socket buffers have memory allocated but not freed).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-26878
|
349,528
|
linux
|
1d0688421449718c6c5f46e458a378c9b530ba18
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1d0688421449718c6c5f46e458a378c9b530ba18
|
Bluetooth: virtio_bt: fix memory leak in virtbt_rx_handle()
On the reception of packets with an invalid packet type, the memory of
the allocated socket buffers is never freed. Add a default case that frees
these to avoid a memory leak.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Signed-off-by: Soenke Huster <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
| 0
|
static void virtbt_rx_handle(struct virtio_bluetooth *vbt, struct sk_buff *skb)
{
__u8 pkt_type;
pkt_type = *((__u8 *) skb->data);
skb_pull(skb, 1);
switch (pkt_type) {
case HCI_EVENT_PKT:
case HCI_ACLDATA_PKT:
case HCI_SCODATA_PKT:
case HCI_ISODATA_PKT:
hci_skb_pkt_type(skb) = pkt_type;
hci_recv_frame(vbt->hdev, skb);
break;
default:
kfree_skb(skb);
break;
}
}
|
158789804082007954716918629696286112823
|
virtio_bt.c
|
116955738040617915933180365116033475903
|
CWE-772
|
CVE-2022-26878
|
drivers/bluetooth/virtio_bt.c in the Linux kernel before 5.16.3 has a memory leak (socket buffers have memory allocated but not freed).
|
https://nvd.nist.gov/vuln/detail/CVE-2022-26878
|
204,036
|
net
|
b922f622592af76b57cbc566eaeccda0b31a3496
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net
|
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=b922f622592af76b57cbc566eaeccda0b31a3496
|
atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait
This bug report shows up when running our research tools. The
reports is SOOB read, but it seems SOOB write is also possible
a few lines below.
In details, fw.len and sw.len are inputs coming from io. A len
over the size of self->rpc triggers SOOB. The patch fixes the
bugs by adding sanity checks.
The bugs are triggerable with compromised/malfunctioning devices.
They are potentially exploitable given they first leak up to
0xffff bytes and able to overwrite the region later.
The patch is tested with QEMU emulater.
This is NOT tested with a real device.
Attached is the log we found by fuzzing.
BUG: KASAN: slab-out-of-bounds in
hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
Read of size 4 at addr ffff888016260b08 by task modprobe/213
CPU: 0 PID: 213 Comm: modprobe Not tainted 5.6.0 #1
Call Trace:
dump_stack+0x76/0xa0
print_address_description.constprop.0+0x16/0x200
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
__kasan_report.cold+0x37/0x7c
? aq_hw_read_reg_bit+0x60/0x70 [atlantic]
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
kasan_report+0xe/0x20
hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
hw_atl_utils_fw_rpc_call+0x95/0x130 [atlantic]
hw_atl_utils_fw_rpc_wait+0x176/0x210 [atlantic]
hw_atl_utils_mpi_create+0x229/0x2e0 [atlantic]
? hw_atl_utils_fw_rpc_wait+0x210/0x210 [atlantic]
? hw_atl_utils_initfw+0x9f/0x1c8 [atlantic]
hw_atl_utils_initfw+0x12a/0x1c8 [atlantic]
aq_nic_ndev_register+0x88/0x650 [atlantic]
? aq_nic_ndev_init+0x235/0x3c0 [atlantic]
aq_pci_probe+0x731/0x9b0 [atlantic]
? aq_pci_func_init+0xc0/0xc0 [atlantic]
local_pci_probe+0xd3/0x160
pci_device_probe+0x23f/0x3e0
Reported-by: Brendan Dolan-Gavitt <[email protected]>
Signed-off-by: Zekun Shen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 1
|
int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
struct hw_atl_utils_fw_rpc **rpc)
{
struct aq_hw_atl_utils_fw_rpc_tid_s sw;
struct aq_hw_atl_utils_fw_rpc_tid_s fw;
int err = 0;
do {
sw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR);
self->rpc_tid = sw.tid;
err = readx_poll_timeout_atomic(hw_atl_utils_rpc_state_get,
self, fw.val,
sw.tid == fw.tid,
1000U, 100000U);
if (err < 0)
goto err_exit;
err = aq_hw_err_from_flags(self);
if (err < 0)
goto err_exit;
if (fw.len == 0xFFFFU) {
err = hw_atl_utils_fw_rpc_call(self, sw.len);
if (err < 0)
goto err_exit;
}
} while (sw.tid != fw.tid || 0xFFFFU == fw.len);
if (rpc) {
if (fw.len) {
err =
hw_atl_utils_fw_downld_dwords(self,
self->rpc_addr,
(u32 *)(void *)
&self->rpc,
(fw.len + sizeof(u32) -
sizeof(u8)) /
sizeof(u32));
if (err < 0)
goto err_exit;
}
*rpc = &self->rpc;
}
err_exit:
return err;
}
|
172267235624297887549936176387558671779
|
hw_atl_utils.c
|
44971629265501342494525008338833784195
|
CWE-787
|
CVE-2021-43975
|
In the Linux kernel through 5.15.2, hw_atl_utils_fw_rpc_wait in drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c allows an attacker (who can introduce a crafted device) to trigger an out-of-bounds write via a crafted length value.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-43975
|
349,888
|
net
|
b922f622592af76b57cbc566eaeccda0b31a3496
|
https://git.kernel.org/cgit/linux/kernel/git/davem/net
|
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=b922f622592af76b57cbc566eaeccda0b31a3496
|
atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_wait
This bug report shows up when running our research tools. The
reports is SOOB read, but it seems SOOB write is also possible
a few lines below.
In details, fw.len and sw.len are inputs coming from io. A len
over the size of self->rpc triggers SOOB. The patch fixes the
bugs by adding sanity checks.
The bugs are triggerable with compromised/malfunctioning devices.
They are potentially exploitable given they first leak up to
0xffff bytes and able to overwrite the region later.
The patch is tested with QEMU emulater.
This is NOT tested with a real device.
Attached is the log we found by fuzzing.
BUG: KASAN: slab-out-of-bounds in
hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
Read of size 4 at addr ffff888016260b08 by task modprobe/213
CPU: 0 PID: 213 Comm: modprobe Not tainted 5.6.0 #1
Call Trace:
dump_stack+0x76/0xa0
print_address_description.constprop.0+0x16/0x200
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
__kasan_report.cold+0x37/0x7c
? aq_hw_read_reg_bit+0x60/0x70 [atlantic]
? hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
kasan_report+0xe/0x20
hw_atl_utils_fw_upload_dwords+0x393/0x3c0 [atlantic]
hw_atl_utils_fw_rpc_call+0x95/0x130 [atlantic]
hw_atl_utils_fw_rpc_wait+0x176/0x210 [atlantic]
hw_atl_utils_mpi_create+0x229/0x2e0 [atlantic]
? hw_atl_utils_fw_rpc_wait+0x210/0x210 [atlantic]
? hw_atl_utils_initfw+0x9f/0x1c8 [atlantic]
hw_atl_utils_initfw+0x12a/0x1c8 [atlantic]
aq_nic_ndev_register+0x88/0x650 [atlantic]
? aq_nic_ndev_init+0x235/0x3c0 [atlantic]
aq_pci_probe+0x731/0x9b0 [atlantic]
? aq_pci_func_init+0xc0/0xc0 [atlantic]
local_pci_probe+0xd3/0x160
pci_device_probe+0x23f/0x3e0
Reported-by: Brendan Dolan-Gavitt <[email protected]>
Signed-off-by: Zekun Shen <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 0
|
int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
struct hw_atl_utils_fw_rpc **rpc)
{
struct aq_hw_atl_utils_fw_rpc_tid_s sw;
struct aq_hw_atl_utils_fw_rpc_tid_s fw;
int err = 0;
do {
sw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR);
self->rpc_tid = sw.tid;
err = readx_poll_timeout_atomic(hw_atl_utils_rpc_state_get,
self, fw.val,
sw.tid == fw.tid,
1000U, 100000U);
if (err < 0)
goto err_exit;
err = aq_hw_err_from_flags(self);
if (err < 0)
goto err_exit;
if (fw.len == 0xFFFFU) {
if (sw.len > sizeof(self->rpc)) {
printk(KERN_INFO "Invalid sw len: %x\n", sw.len);
err = -EINVAL;
goto err_exit;
}
err = hw_atl_utils_fw_rpc_call(self, sw.len);
if (err < 0)
goto err_exit;
}
} while (sw.tid != fw.tid || 0xFFFFU == fw.len);
if (rpc) {
if (fw.len) {
if (fw.len > sizeof(self->rpc)) {
printk(KERN_INFO "Invalid fw len: %x\n", fw.len);
err = -EINVAL;
goto err_exit;
}
err =
hw_atl_utils_fw_downld_dwords(self,
self->rpc_addr,
(u32 *)(void *)
&self->rpc,
(fw.len + sizeof(u32) -
sizeof(u8)) /
sizeof(u32));
if (err < 0)
goto err_exit;
}
*rpc = &self->rpc;
}
err_exit:
return err;
}
|
78874513261411721250229563927367854833
|
hw_atl_utils.c
|
98512152350108532243910999144686301920
|
CWE-787
|
CVE-2021-43975
|
In the Linux kernel through 5.15.2, hw_atl_utils_fw_rpc_wait in drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c allows an attacker (who can introduce a crafted device) to trigger an out-of-bounds write via a crafted length value.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-43975
|
204,073
|
shapelib
|
c75b9281a5b9452d92e1682bdfe6019a13ed819f
|
https://github.com/OSGeo/shapelib
|
https://github.com/OSGeo/shapelib/commit/c75b9281a5b9452d92e1682bdfe6019a13ed819f
|
Remove double free() in contrib/shpsrt, issue #39
This fixes issue #39
| 1
|
static char ** split(const char *arg, const char *delim) {
char *copy = dupstr(arg);
char **result = NULL;
int i = 0;
for (char *cptr = strtok(copy, delim); cptr; cptr = strtok(NULL, delim)) {
char **tmp = realloc (result, sizeof *result * (i + 1));
if (!tmp && result) {
while (i > 0) {
free(result[--i]);
}
free(result);
free(copy);
return NULL;
}
result = tmp;
result[i++] = dupstr(cptr);
}
free(copy);
if (i) {
char **tmp = realloc(result, sizeof *result * (i + 1));
if (!tmp) {
while (i > 0) {
free(result[--i]);
}
free(result);
free(copy);
return NULL;
}
result = tmp;
result[i++] = NULL;
}
return result;
}
|
154440466975385336432510777562091378708
|
shpsort.c
|
43221346953143953382565106661243368341
|
CWE-415
|
CVE-2022-0699
|
A double-free condition exists in contrib/shpsort.c of shapelib 1.5.0 and older releases. This issue may allow an attacker to cause a denial of service or have other unspecified impact via control over malloc.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0699
|
351,182
|
shapelib
|
c75b9281a5b9452d92e1682bdfe6019a13ed819f
|
https://github.com/OSGeo/shapelib
|
https://github.com/OSGeo/shapelib/commit/c75b9281a5b9452d92e1682bdfe6019a13ed819f
|
Remove double free() in contrib/shpsrt, issue #39
This fixes issue #39
| 0
|
static char ** split(const char *arg, const char *delim) {
char *copy = dupstr(arg);
char **result = NULL;
int i = 0;
for (char *cptr = strtok(copy, delim); cptr; cptr = strtok(NULL, delim)) {
char **tmp = realloc (result, sizeof *result * (i + 1));
if (!tmp && result) {
while (i > 0) {
free(result[--i]);
}
free(result);
free(copy);
return NULL;
}
result = tmp;
result[i++] = dupstr(cptr);
}
free(copy);
if (i) {
char **tmp = realloc(result, sizeof *result * (i + 1));
if (!tmp) {
while (i > 0) {
free(result[--i]);
}
free(result);
return NULL;
}
result = tmp;
result[i++] = NULL;
}
return result;
}
|
106488258740944380908337679488455743324
|
shpsort.c
|
120261673171922757461559370561018380783
|
CWE-415
|
CVE-2022-0699
|
A double-free condition exists in contrib/shpsort.c of shapelib 1.5.0 and older releases. This issue may allow an attacker to cause a denial of service or have other unspecified impact via control over malloc.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0699
|
204,115
|
openldap
|
3539fc33212b528c56b716584f2c2994af7c30b0
|
https://github.com/openldap/openldap
|
https://git.openldap.org/openldap/openldap/-/commit/3539fc33212b528c56b716584f2c2994af7c30b0
|
ITS#9454 fix issuerAndThisUpdateCheck
| 1
|
issuerAndThisUpdateCheck(
struct berval *in,
struct berval *is,
struct berval *tu,
void *ctx )
{
int numdquotes = 0;
struct berval x = *in;
struct berval ni = BER_BVNULL;
/* Parse GSER format */
enum {
HAVE_NONE = 0x0,
HAVE_ISSUER = 0x1,
HAVE_THISUPDATE = 0x2,
HAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE )
} have = HAVE_NONE;
if ( in->bv_len < STRLENOF( "{issuer \"\",thisUpdate \"YYMMDDhhmmssZ\"}" ) ) return LDAP_INVALID_SYNTAX;
if ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len -= STRLENOF("{}");
do {
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* should be at issuer or thisUpdate */
if ( strncasecmp( x.bv_val, "issuer", STRLENOF("issuer") ) == 0 ) {
if ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX;
/* parse issuer */
x.bv_val += STRLENOF("issuer");
x.bv_len -= STRLENOF("issuer");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* For backward compatibility, this part is optional */
if ( strncasecmp( x.bv_val, "rdnSequence:", STRLENOF("rdnSequence:") ) != 0 ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val += STRLENOF("rdnSequence:");
x.bv_len -= STRLENOF("rdnSequence:");
if ( x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
is->bv_val = x.bv_val;
is->bv_len = 0;
for ( ; is->bv_len < x.bv_len; ) {
if ( is->bv_val[is->bv_len] != '"' ) {
is->bv_len++;
continue;
}
if ( is->bv_val[is->bv_len+1] == '"' ) {
/* double dquote */
numdquotes++;
is->bv_len += 2;
continue;
}
break;
}
x.bv_val += is->bv_len + 1;
x.bv_len -= is->bv_len + 1;
have |= HAVE_ISSUER;
} else if ( strncasecmp( x.bv_val, "thisUpdate", STRLENOF("thisUpdate") ) == 0 )
{
if ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX;
/* parse thisUpdate */
x.bv_val += STRLENOF("thisUpdate");
x.bv_len -= STRLENOF("thisUpdate");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( !x.bv_len || x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
tu->bv_val = x.bv_val;
tu->bv_len = 0;
for ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) {
if ( tu->bv_val[tu->bv_len] == '"' ) {
break;
}
}
x.bv_val += tu->bv_len + 1;
x.bv_len -= tu->bv_len + 1;
have |= HAVE_THISUPDATE;
} else {
return LDAP_INVALID_SYNTAX;
}
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( have == HAVE_ALL ) {
break;
}
if ( x.bv_val[0] != ',' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len--;
} while ( 1 );
/* should have no characters left... */
if ( x.bv_len ) return LDAP_INVALID_SYNTAX;
if ( numdquotes == 0 ) {
ber_dupbv_x( &ni, is, ctx );
} else {
ber_len_t src, dst;
ni.bv_len = is->bv_len - numdquotes;
ni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx );
for ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {
if ( is->bv_val[src] == '"' ) {
src++;
}
ni.bv_val[dst] = is->bv_val[src];
}
ni.bv_val[dst] = '\0';
}
*is = ni;
return 0;
}
|
320953270427993363171410441809926002124
|
schema_init.c
|
177224706623297221858931327325567866275
|
CWE-617
|
CVE-2021-27212
|
In OpenLDAP through 2.4.57 and 2.5.x through 2.5.1alpha, an assertion failure in slapd can occur in the issuerAndThisUpdateCheck function via a crafted packet, resulting in a denial of service (daemon exit) via a short timestamp. This is related to schema_init.c and checkTime.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-27212
|
353,015
|
openldap
|
3539fc33212b528c56b716584f2c2994af7c30b0
|
https://github.com/openldap/openldap
|
https://git.openldap.org/openldap/openldap/-/commit/3539fc33212b528c56b716584f2c2994af7c30b0
|
ITS#9454 fix issuerAndThisUpdateCheck
| 0
|
issuerAndThisUpdateCheck(
struct berval *in,
struct berval *is,
struct berval *tu,
void *ctx )
{
int numdquotes = 0;
struct berval x = *in;
struct berval ni = BER_BVNULL;
/* Parse GSER format */
enum {
HAVE_NONE = 0x0,
HAVE_ISSUER = 0x1,
HAVE_THISUPDATE = 0x2,
HAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE )
} have = HAVE_NONE;
if ( in->bv_len < STRLENOF( "{issuer \"\",thisUpdate \"YYMMDDhhmmssZ\"}" ) ) return LDAP_INVALID_SYNTAX;
if ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len -= STRLENOF("{}");
do {
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* should be at issuer or thisUpdate */
if ( strncasecmp( x.bv_val, "issuer", STRLENOF("issuer") ) == 0 ) {
if ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX;
/* parse issuer */
x.bv_val += STRLENOF("issuer");
x.bv_len -= STRLENOF("issuer");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* For backward compatibility, this part is optional */
if ( strncasecmp( x.bv_val, "rdnSequence:", STRLENOF("rdnSequence:") ) != 0 ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val += STRLENOF("rdnSequence:");
x.bv_len -= STRLENOF("rdnSequence:");
if ( x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
is->bv_val = x.bv_val;
is->bv_len = 0;
for ( ; is->bv_len < x.bv_len; ) {
if ( is->bv_val[is->bv_len] != '"' ) {
is->bv_len++;
continue;
}
if ( is->bv_val[is->bv_len+1] == '"' ) {
/* double dquote */
numdquotes++;
is->bv_len += 2;
continue;
}
break;
}
x.bv_val += is->bv_len + 1;
x.bv_len -= is->bv_len + 1;
have |= HAVE_ISSUER;
} else if ( strncasecmp( x.bv_val, "thisUpdate", STRLENOF("thisUpdate") ) == 0 )
{
if ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX;
/* parse thisUpdate */
x.bv_val += STRLENOF("thisUpdate");
x.bv_len -= STRLENOF("thisUpdate");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( !x.bv_len || x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
tu->bv_val = x.bv_val;
tu->bv_len = 0;
for ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) {
if ( tu->bv_val[tu->bv_len] == '"' ) {
break;
}
}
if ( tu->bv_len < STRLENOF("YYYYmmddHHmmssZ") ) return LDAP_INVALID_SYNTAX;
x.bv_val += tu->bv_len + 1;
x.bv_len -= tu->bv_len + 1;
have |= HAVE_THISUPDATE;
} else {
return LDAP_INVALID_SYNTAX;
}
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( have == HAVE_ALL ) {
break;
}
if ( x.bv_val[0] != ',' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len--;
} while ( 1 );
/* should have no characters left... */
if ( x.bv_len ) return LDAP_INVALID_SYNTAX;
if ( numdquotes == 0 ) {
ber_dupbv_x( &ni, is, ctx );
} else {
ber_len_t src, dst;
ni.bv_len = is->bv_len - numdquotes;
ni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx );
for ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {
if ( is->bv_val[src] == '"' ) {
src++;
}
ni.bv_val[dst] = is->bv_val[src];
}
ni.bv_val[dst] = '\0';
}
*is = ni;
return 0;
}
|
298149048073642841250394521193700631288
|
schema_init.c
|
127214091536244192150172242805699646468
|
CWE-617
|
CVE-2021-27212
|
In OpenLDAP through 2.4.57 and 2.5.x through 2.5.1alpha, an assertion failure in slapd can occur in the issuerAndThisUpdateCheck function via a crafted packet, resulting in a denial of service (daemon exit) via a short timestamp. This is related to schema_init.c and checkTime.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-27212
|
204,137
|
poppler
|
b224e2f5739fe61de9fa69955d016725b2a4b78d
|
https://github.com/freedesktop/poppler
|
https://gitlab.freedesktop.org/poppler/poppler/commit/b224e2f5739fe61de9fa69955d016725b2a4b78d
|
SplashOutputDev::tilingPatternFill: Fix crash on broken file
Issue #802
| 1
|
bool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str,
const double *ptm, int paintType, int /*tilingType*/, Dict *resDict,
const double *mat, const double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep)
{
PDFRectangle box;
Gfx *gfx;
Splash *formerSplash = splash;
SplashBitmap *formerBitmap = bitmap;
double width, height;
int surface_width, surface_height, result_width, result_height, i;
int repeatX, repeatY;
SplashCoord matc[6];
Matrix m1;
const double *ctm;
double savedCTM[6];
double kx, ky, sx, sy;
bool retValue = false;
width = bbox[2] - bbox[0];
height = bbox[3] - bbox[1];
if (xStep != width || yStep != height)
return false;
// calculate offsets
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
savedCTM[i] = ctm[i];
}
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]);
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
if (!std::isfinite(ctm[i])) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
}
matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4];
matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5];
if (splashAbs(ctm[1]) > splashAbs(ctm[0])) {
kx = -ctm[1];
ky = ctm[2] - (ctm[0] * ctm[3]) / ctm[1];
} else {
kx = ctm[0];
ky = ctm[3] - (ctm[1] * ctm[2]) / ctm[0];
}
result_width = (int) ceil(fabs(kx * width * (x1 - x0)));
result_height = (int) ceil(fabs(ky * height * (y1 - y0)));
kx = state->getHDPI() / 72.0;
ky = state->getVDPI() / 72.0;
m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx;
m1.m[1] = 0;
m1.m[2] = 0;
m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky;
m1.m[4] = 0;
m1.m[5] = 0;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
sx = (double) result_width / (surface_width * (x1 - x0));
sy = (double) result_height / (surface_height * (y1 - y0));
m1.m[0] *= sx;
m1.m[3] *= sy;
m1.transform(width, height, &kx, &ky);
if(fabs(kx) < 1 && fabs(ky) < 1) {
kx = std::min<double>(kx, ky);
ky = 2 / kx;
m1.m[0] *= ky;
m1.m[3] *= ky;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
repeatX = x1 - x0;
repeatY = y1 - y0;
} else {
if ((unsigned long) surface_width * surface_height > 0x800000L) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
while(fabs(kx) > 16384 || fabs(ky) > 16384) {
// limit pattern bitmap size
m1.m[0] /= 2;
m1.m[3] /= 2;
m1.transform(width, height, &kx, &ky);
}
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
// adjust repeat values to completely fill region
repeatX = result_width / surface_width;
repeatY = result_height / surface_height;
if (surface_width * repeatX < result_width)
repeatX++;
if (surface_height * repeatY < result_height)
repeatY++;
if (x1 - x0 > repeatX)
repeatX = x1 - x0;
if (y1 - y0 > repeatY)
repeatY = y1 - y0;
}
// restore CTM and calculate rotate and scale with rounded matrix
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
if (surface_width == 0 || surface_height == 0 || repeatX * repeatY <= 4) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
m1.transform(bbox[0], bbox[1], &kx, &ky);
m1.m[4] = -kx;
m1.m[5] = -ky;
bitmap = new SplashBitmap(surface_width, surface_height, 1,
(paintType == 1) ? colorMode : splashModeMono8, true);
if (bitmap->getDataPtr() == nullptr) {
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
delete tBitmap;
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
splash = new Splash(bitmap, true);
if (paintType == 2) {
SplashColor clearColor;
#ifdef SPLASH_CMYK
clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF;
#else
clearColor[0] = 0xFF;
#endif
splash->clear(clearColor, 0);
} else {
splash->clear(paperColor, 0);
}
splash->setThinLineMode(formerSplash->getThinLineMode());
splash->setMinLineWidth(s_minLineWidth);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
// set pattern transformation matrix
gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
gfx->display(str);
delete splash;
splash = formerSplash;
TilingSplashOutBitmap imgData;
imgData.bitmap = bitmap;
imgData.paintType = paintType;
imgData.pattern = splash->getFillPattern();
imgData.colorMode = colorMode;
imgData.y = 0;
imgData.repeatX = repeatX;
imgData.repeatY = repeatY;
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
result_width = tBitmap->getWidth() * imgData.repeatX;
result_height = tBitmap->getHeight() * imgData.repeatY;
if (splashAbs(matc[1]) > splashAbs(matc[0])) {
kx = -matc[1];
ky = matc[2] - (matc[0] * matc[3]) / matc[1];
} else {
kx = matc[0];
ky = matc[3] - (matc[1] * matc[2]) / matc[0];
}
kx = result_width / (fabs(kx) + 1);
ky = result_height / (fabs(ky) + 1);
state->concatCTM(kx, 0, 0, ky, 0, 0);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
bool minorAxisZero = matc[1] == 0 && matc[2] == 0;
if (matc[0] > 0 && minorAxisZero && matc[3] > 0) {
// draw the tiles
for (int y = 0; y < imgData.repeatY; ++y) {
for (int x = 0; x < imgData.repeatX; ++x) {
x0 = splashFloor(matc[4]) + x * tBitmap->getWidth();
y0 = splashFloor(matc[5]) + y * tBitmap->getHeight();
splash->blitImage(tBitmap, true, x0, y0);
}
}
retValue = true;
} else {
retValue = splash->drawImage(&tilingBitmapSrc, nullptr, &imgData, colorMode, true, result_width, result_height, matc, false, true) == splashOk;
}
delete tBitmap;
delete gfx;
return retValue;
}
|
185397419658299701437950097682121552321
|
None
|
CWE-369
|
CVE-2019-14494
|
An issue was discovered in Poppler through 0.78.0. There is a divide-by-zero error in the function SplashOutputDev::tilingPatternFill at SplashOutputDev.cc.
|
https://nvd.nist.gov/vuln/detail/CVE-2019-14494
|
|
353,124
|
poppler
|
b224e2f5739fe61de9fa69955d016725b2a4b78d
|
https://github.com/freedesktop/poppler
|
https://gitlab.freedesktop.org/poppler/poppler/commit/b224e2f5739fe61de9fa69955d016725b2a4b78d
|
SplashOutputDev::tilingPatternFill: Fix crash on broken file
Issue #802
| 0
|
bool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *catalog, Object *str,
const double *ptm, int paintType, int /*tilingType*/, Dict *resDict,
const double *mat, const double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep)
{
PDFRectangle box;
Gfx *gfx;
Splash *formerSplash = splash;
SplashBitmap *formerBitmap = bitmap;
double width, height;
int surface_width, surface_height, result_width, result_height, i;
int repeatX, repeatY;
SplashCoord matc[6];
Matrix m1;
const double *ctm;
double savedCTM[6];
double kx, ky, sx, sy;
bool retValue = false;
width = bbox[2] - bbox[0];
height = bbox[3] - bbox[1];
if (xStep != width || yStep != height)
return false;
// calculate offsets
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
savedCTM[i] = ctm[i];
}
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]);
ctm = state->getCTM();
for (i = 0; i < 6; ++i) {
if (!std::isfinite(ctm[i])) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
}
matc[4] = x0 * xStep * ctm[0] + y0 * yStep * ctm[2] + ctm[4];
matc[5] = x0 * xStep * ctm[1] + y0 * yStep * ctm[3] + ctm[5];
if (splashAbs(ctm[1]) > splashAbs(ctm[0])) {
kx = -ctm[1];
ky = ctm[2] - (ctm[0] * ctm[3]) / ctm[1];
} else {
kx = ctm[0];
ky = ctm[3] - (ctm[1] * ctm[2]) / ctm[0];
}
result_width = (int) ceil(fabs(kx * width * (x1 - x0)));
result_height = (int) ceil(fabs(ky * height * (y1 - y0)));
kx = state->getHDPI() / 72.0;
ky = state->getVDPI() / 72.0;
m1.m[0] = (ptm[0] == 0) ? fabs(ptm[2]) * kx : fabs(ptm[0]) * kx;
m1.m[1] = 0;
m1.m[2] = 0;
m1.m[3] = (ptm[3] == 0) ? fabs(ptm[1]) * ky : fabs(ptm[3]) * ky;
m1.m[4] = 0;
m1.m[5] = 0;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
sx = (double) result_width / (surface_width * (x1 - x0));
sy = (double) result_height / (surface_height * (y1 - y0));
m1.m[0] *= sx;
m1.m[3] *= sy;
m1.transform(width, height, &kx, &ky);
if(fabs(kx) < 1 && fabs(ky) < 1) {
kx = std::min<double>(kx, ky);
ky = 2 / kx;
m1.m[0] *= ky;
m1.m[3] *= ky;
m1.transform(width, height, &kx, &ky);
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
repeatX = x1 - x0;
repeatY = y1 - y0;
} else {
if ((unsigned long) surface_width * surface_height > 0x800000L) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
while(fabs(kx) > 16384 || fabs(ky) > 16384) {
// limit pattern bitmap size
m1.m[0] /= 2;
m1.m[3] /= 2;
m1.transform(width, height, &kx, &ky);
}
surface_width = (int) ceil (fabs(kx));
surface_height = (int) ceil (fabs(ky));
// adjust repeat values to completely fill region
if (unlikely(surface_width == 0 || surface_height == 0)) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
repeatX = result_width / surface_width;
repeatY = result_height / surface_height;
if (surface_width * repeatX < result_width)
repeatX++;
if (surface_height * repeatY < result_height)
repeatY++;
if (x1 - x0 > repeatX)
repeatX = x1 - x0;
if (y1 - y0 > repeatY)
repeatY = y1 - y0;
}
// restore CTM and calculate rotate and scale with rounded matrix
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
state->concatCTM(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
state->concatCTM(width * repeatX, 0, 0, height * repeatY, bbox[0], bbox[1]);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
if (surface_width == 0 || surface_height == 0 || repeatX * repeatY <= 4) {
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
m1.transform(bbox[0], bbox[1], &kx, &ky);
m1.m[4] = -kx;
m1.m[5] = -ky;
bitmap = new SplashBitmap(surface_width, surface_height, 1,
(paintType == 1) ? colorMode : splashModeMono8, true);
if (bitmap->getDataPtr() == nullptr) {
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
delete tBitmap;
state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]);
return false;
}
splash = new Splash(bitmap, true);
if (paintType == 2) {
SplashColor clearColor;
#ifdef SPLASH_CMYK
clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF;
#else
clearColor[0] = 0xFF;
#endif
splash->clear(clearColor, 0);
} else {
splash->clear(paperColor, 0);
}
splash->setThinLineMode(formerSplash->getThinLineMode());
splash->setMinLineWidth(s_minLineWidth);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
gfx = new Gfx(doc, this, resDict, &box, nullptr, nullptr, nullptr, gfxA);
// set pattern transformation matrix
gfx->getState()->setCTM(m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
updateCTM(gfx->getState(), m1.m[0], m1.m[1], m1.m[2], m1.m[3], m1.m[4], m1.m[5]);
gfx->display(str);
delete splash;
splash = formerSplash;
TilingSplashOutBitmap imgData;
imgData.bitmap = bitmap;
imgData.paintType = paintType;
imgData.pattern = splash->getFillPattern();
imgData.colorMode = colorMode;
imgData.y = 0;
imgData.repeatX = repeatX;
imgData.repeatY = repeatY;
SplashBitmap *tBitmap = bitmap;
bitmap = formerBitmap;
result_width = tBitmap->getWidth() * imgData.repeatX;
result_height = tBitmap->getHeight() * imgData.repeatY;
if (splashAbs(matc[1]) > splashAbs(matc[0])) {
kx = -matc[1];
ky = matc[2] - (matc[0] * matc[3]) / matc[1];
} else {
kx = matc[0];
ky = matc[3] - (matc[1] * matc[2]) / matc[0];
}
kx = result_width / (fabs(kx) + 1);
ky = result_height / (fabs(ky) + 1);
state->concatCTM(kx, 0, 0, ky, 0, 0);
ctm = state->getCTM();
matc[0] = ctm[0];
matc[1] = ctm[1];
matc[2] = ctm[2];
matc[3] = ctm[3];
bool minorAxisZero = matc[1] == 0 && matc[2] == 0;
if (matc[0] > 0 && minorAxisZero && matc[3] > 0) {
// draw the tiles
for (int y = 0; y < imgData.repeatY; ++y) {
for (int x = 0; x < imgData.repeatX; ++x) {
x0 = splashFloor(matc[4]) + x * tBitmap->getWidth();
y0 = splashFloor(matc[5]) + y * tBitmap->getHeight();
splash->blitImage(tBitmap, true, x0, y0);
}
}
retValue = true;
} else {
retValue = splash->drawImage(&tilingBitmapSrc, nullptr, &imgData, colorMode, true, result_width, result_height, matc, false, true) == splashOk;
}
delete tBitmap;
delete gfx;
return retValue;
}
|
66158581333655074861214413743208531440
|
None
|
CWE-369
|
CVE-2019-14494
|
An issue was discovered in Poppler through 0.78.0. There is a divide-by-zero error in the function SplashOutputDev::tilingPatternFill at SplashOutputDev.cc.
|
https://nvd.nist.gov/vuln/detail/CVE-2019-14494
|
|
204,195
|
pjproject
|
8b621f192cae14456ee0b0ade52ce6c6f258af1e
|
https://github.com/pjsip/pjproject
|
https://github.com/pjsip/pjproject/commit/8b621f192cae14456ee0b0ade52ce6c6f258af1e
|
Merge pull request from GHSA-3qx3-cg72-wrh9
| 1
|
static void parse_rtcp_bye(pjmedia_rtcp_session *sess,
const void *pkt,
pj_size_t size)
{
pj_str_t reason = {"-", 1};
/* Check and get BYE reason */
if (size > 8) {
reason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_),
*((pj_uint8_t*)pkt+8));
pj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9),
reason.slen);
reason.ptr = sess->stat.peer_sdes_buf_;
}
/* Just print RTCP BYE log */
PJ_LOG(5, (sess->name, "Received RTCP BYE, reason: %.*s",
reason.slen, reason.ptr));
}
|
95691820477494011989494034307855997524
|
None
|
CWE-125
|
CVE-2021-43804
|
PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In affected versions if the incoming RTCP BYE message contains a reason's length, this declared length is not checked against the actual received packet size, potentially resulting in an out-of-bound read access. This issue affects all users that use PJMEDIA and RTCP. A malicious actor can send a RTCP BYE message with an invalid reason length. Users are advised to upgrade as soon as possible. There are no known workarounds.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-43804
|
|
355,014
|
pjproject
|
8b621f192cae14456ee0b0ade52ce6c6f258af1e
|
https://github.com/pjsip/pjproject
|
https://github.com/pjsip/pjproject/commit/8b621f192cae14456ee0b0ade52ce6c6f258af1e
|
Merge pull request from GHSA-3qx3-cg72-wrh9
| 0
|
static void parse_rtcp_bye(pjmedia_rtcp_session *sess,
const void *pkt,
pj_size_t size)
{
pj_str_t reason = {"-", 1};
/* Check and get BYE reason */
if (size > 8) {
/* Make sure the BYE reason does not exceed:
* - the size of the available buffer
* - the declared reason's length
* - the actual packet size
*/
reason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_),
*((pj_uint8_t*)pkt+8));
reason.slen = PJ_MIN(reason.slen, size-9);
pj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9),
reason.slen);
reason.ptr = sess->stat.peer_sdes_buf_;
}
/* Just print RTCP BYE log */
PJ_LOG(5, (sess->name, "Received RTCP BYE, reason: %.*s",
reason.slen, reason.ptr));
}
|
57940868666737291177801775704260101315
|
None
|
CWE-125
|
CVE-2021-43804
|
PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In affected versions if the incoming RTCP BYE message contains a reason's length, this declared length is not checked against the actual received packet size, potentially resulting in an out-of-bound read access. This issue affects all users that use PJMEDIA and RTCP. A malicious actor can send a RTCP BYE message with an invalid reason length. Users are advised to upgrade as soon as possible. There are no known workarounds.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-43804
|
|
204,243
|
vim
|
fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d
|
patch 8.2.4206: condition with many "(" causes a crash
Problem: Condition with many "(" causes a crash.
Solution: Limit recursion to 1000.
| 1
|
eval7(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
int want_string) // after "." operator
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
int len;
char_u *s;
char_u *name_start = NULL;
char_u *start_leader, *end_leader;
int ret = OK;
char_u *alias;
/*
* Initialise variable so that clear_tv() can't mistake this for a
* string and free a string that isn't there.
*/
rettv->v_type = VAR_UNKNOWN;
/*
* Skip '!', '-' and '+' characters. They are handled later.
*/
start_leader = *arg;
if (eval_leader(arg, in_vim9script()) == FAIL)
return FAIL;
end_leader = *arg;
if (**arg == '.' && (!isdigit(*(*arg + 1))
#ifdef FEAT_FLOAT
|| in_old_script(2)
#endif
))
{
semsg(_(e_invalid_expression_str), *arg);
++*arg;
return FAIL;
}
switch (**arg)
{
/*
* Number constant.
*/
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '.': ret = eval_number(arg, rettv, evaluate, want_string);
// Apply prefixed "-" and "+" now. Matters especially when
// "->" follows.
if (ret == OK && evaluate && end_leader > start_leader
&& rettv->v_type != VAR_BLOB)
ret = eval7_leader(rettv, TRUE, start_leader, &end_leader);
break;
/*
* String constant: "string".
*/
case '"': ret = eval_string(arg, rettv, evaluate);
break;
/*
* Literal string constant: 'str''ing'.
*/
case '\'': ret = eval_lit_string(arg, rettv, evaluate);
break;
/*
* List: [expr, expr]
*/
case '[': ret = eval_list(arg, rettv, evalarg, TRUE);
break;
/*
* Dictionary: #{key: val, key: val}
*/
case '#': if (in_vim9script())
{
ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;
}
else if ((*arg)[1] == '{')
{
++*arg;
ret = eval_dict(arg, rettv, evalarg, TRUE);
}
else
ret = NOTDONE;
break;
/*
* Lambda: {arg, arg -> expr}
* Dictionary: {'key': val, 'key': val}
*/
case '{': if (in_vim9script())
ret = NOTDONE;
else
ret = get_lambda_tv(arg, rettv, in_vim9script(), evalarg);
if (ret == NOTDONE)
ret = eval_dict(arg, rettv, evalarg, FALSE);
break;
/*
* Option value: &name
*/
case '&': ret = eval_option(arg, rettv, evaluate);
break;
/*
* Environment variable: $VAR.
*/
case '$': ret = eval_env_var(arg, rettv, evaluate);
break;
/*
* Register contents: @r.
*/
case '@': ++*arg;
if (evaluate)
{
if (in_vim9script() && IS_WHITE_OR_NUL(**arg))
semsg(_(e_syntax_error_at_str), *arg);
else if (in_vim9script() && !valid_yank_reg(**arg, FALSE))
emsg_invreg(**arg);
else
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = get_reg_contents(**arg,
GREG_EXPR_SRC);
}
}
if (**arg != NUL)
++*arg;
break;
/*
* nested expression: (expression).
* or lambda: (arg) => expr
*/
case '(': ret = NOTDONE;
if (in_vim9script())
{
ret = get_lambda_tv(arg, rettv, TRUE, evalarg);
if (ret == OK && evaluate)
{
ufunc_T *ufunc = rettv->vval.v_partial->pt_func;
// Compile it here to get the return type. The return
// type is optional, when it's missing use t_unknown.
// This is recognized in compile_return().
if (ufunc->uf_ret_type->tt_type == VAR_VOID)
ufunc->uf_ret_type = &t_unknown;
if (compile_def_function(ufunc,
FALSE, COMPILE_TYPE(ufunc), NULL) == FAIL)
{
clear_tv(rettv);
ret = FAIL;
}
}
}
if (ret == NOTDONE)
{
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
ret = eval1(arg, rettv, evalarg); // recursive!
*arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg == ')')
++*arg;
else if (ret == OK)
{
emsg(_(e_missing_closing_paren));
clear_tv(rettv);
ret = FAIL;
}
}
break;
default: ret = NOTDONE;
break;
}
if (ret == NOTDONE)
{
/*
* Must be a variable or function name.
* Can also be a curly-braces kind of name: {expr}.
*/
s = *arg;
len = get_name_len(arg, &alias, evaluate, TRUE);
if (alias != NULL)
s = alias;
if (len <= 0)
ret = FAIL;
else
{
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
if (evaluate && in_vim9script() && len == 1 && *s == '_')
{
emsg(_(e_cannot_use_underscore_here));
ret = FAIL;
}
else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')
{
// "name(..." recursive!
*arg = skipwhite(*arg);
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
}
else if (flags & EVAL_CONSTANT)
ret = FAIL;
else if (evaluate)
{
// get the value of "true", "false" or a variable
if (len == 4 && in_vim9script() && STRNCMP(s, "true", 4) == 0)
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_TRUE;
ret = OK;
}
else if (len == 5 && in_vim9script()
&& STRNCMP(s, "false", 5) == 0)
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_FALSE;
ret = OK;
}
else if (len == 4 && in_vim9script()
&& STRNCMP(s, "null", 4) == 0)
{
rettv->v_type = VAR_SPECIAL;
rettv->vval.v_number = VVAL_NULL;
ret = OK;
}
else
{
name_start = s;
ret = eval_variable(s, len, 0, rettv, NULL,
EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT);
}
}
else
{
// skip the name
check_vars(s, len);
ret = OK;
}
}
vim_free(alias);
}
// Handle following '[', '(' and '.' for expr[expr], expr.name,
// expr(expr), expr->name(expr)
if (ret == OK)
ret = handle_subscript(arg, name_start, rettv, evalarg, TRUE);
/*
* Apply logical NOT and unary '-', from right to left, ignore '+'.
*/
if (ret == OK && evaluate && end_leader > start_leader)
ret = eval7_leader(rettv, FALSE, start_leader, &end_leader);
return ret;
}
|
36727009233023880586835574908835910206
|
eval.c
|
215532001349875821306945607465028796767
|
CWE-787
|
CVE-2022-0351
|
Access of Memory Location Before Start of Buffer in GitHub repository vim/vim prior to 8.2.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0351
|
355,649
|
vim
|
fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d
|
https://github.com/vim/vim
|
https://github.com/vim/vim/commit/fe6fb267e6ee5c5da2f41889e4e0e0ac5bf4b89d
|
patch 8.2.4206: condition with many "(" causes a crash
Problem: Condition with many "(" causes a crash.
Solution: Limit recursion to 1000.
| 0
|
eval7(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
int want_string) // after "." operator
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
int len;
char_u *s;
char_u *name_start = NULL;
char_u *start_leader, *end_leader;
int ret = OK;
char_u *alias;
static int recurse = 0;
/*
* Initialise variable so that clear_tv() can't mistake this for a
* string and free a string that isn't there.
*/
rettv->v_type = VAR_UNKNOWN;
/*
* Skip '!', '-' and '+' characters. They are handled later.
*/
start_leader = *arg;
if (eval_leader(arg, in_vim9script()) == FAIL)
return FAIL;
end_leader = *arg;
if (**arg == '.' && (!isdigit(*(*arg + 1))
#ifdef FEAT_FLOAT
|| in_old_script(2)
#endif
))
{
semsg(_(e_invalid_expression_str), *arg);
++*arg;
return FAIL;
}
// Limit recursion to 1000 levels. At least at 10000 we run out of stack
// and crash.
if (recurse == 1000)
{
semsg(_(e_expression_too_recursive_str), *arg);
return FAIL;
}
++recurse;
switch (**arg)
{
/*
* Number constant.
*/
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '.': ret = eval_number(arg, rettv, evaluate, want_string);
// Apply prefixed "-" and "+" now. Matters especially when
// "->" follows.
if (ret == OK && evaluate && end_leader > start_leader
&& rettv->v_type != VAR_BLOB)
ret = eval7_leader(rettv, TRUE, start_leader, &end_leader);
break;
/*
* String constant: "string".
*/
case '"': ret = eval_string(arg, rettv, evaluate);
break;
/*
* Literal string constant: 'str''ing'.
*/
case '\'': ret = eval_lit_string(arg, rettv, evaluate);
break;
/*
* List: [expr, expr]
*/
case '[': ret = eval_list(arg, rettv, evalarg, TRUE);
break;
/*
* Dictionary: #{key: val, key: val}
*/
case '#': if (in_vim9script())
{
ret = vim9_bad_comment(*arg) ? FAIL : NOTDONE;
}
else if ((*arg)[1] == '{')
{
++*arg;
ret = eval_dict(arg, rettv, evalarg, TRUE);
}
else
ret = NOTDONE;
break;
/*
* Lambda: {arg, arg -> expr}
* Dictionary: {'key': val, 'key': val}
*/
case '{': if (in_vim9script())
ret = NOTDONE;
else
ret = get_lambda_tv(arg, rettv, in_vim9script(), evalarg);
if (ret == NOTDONE)
ret = eval_dict(arg, rettv, evalarg, FALSE);
break;
/*
* Option value: &name
*/
case '&': ret = eval_option(arg, rettv, evaluate);
break;
/*
* Environment variable: $VAR.
*/
case '$': ret = eval_env_var(arg, rettv, evaluate);
break;
/*
* Register contents: @r.
*/
case '@': ++*arg;
if (evaluate)
{
if (in_vim9script() && IS_WHITE_OR_NUL(**arg))
semsg(_(e_syntax_error_at_str), *arg);
else if (in_vim9script() && !valid_yank_reg(**arg, FALSE))
emsg_invreg(**arg);
else
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = get_reg_contents(**arg,
GREG_EXPR_SRC);
}
}
if (**arg != NUL)
++*arg;
break;
/*
* nested expression: (expression).
* or lambda: (arg) => expr
*/
case '(': ret = NOTDONE;
if (in_vim9script())
{
ret = get_lambda_tv(arg, rettv, TRUE, evalarg);
if (ret == OK && evaluate)
{
ufunc_T *ufunc = rettv->vval.v_partial->pt_func;
// Compile it here to get the return type. The return
// type is optional, when it's missing use t_unknown.
// This is recognized in compile_return().
if (ufunc->uf_ret_type->tt_type == VAR_VOID)
ufunc->uf_ret_type = &t_unknown;
if (compile_def_function(ufunc,
FALSE, COMPILE_TYPE(ufunc), NULL) == FAIL)
{
clear_tv(rettv);
ret = FAIL;
}
}
}
if (ret == NOTDONE)
{
*arg = skipwhite_and_linebreak(*arg + 1, evalarg);
ret = eval1(arg, rettv, evalarg); // recursive!
*arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg == ')')
++*arg;
else if (ret == OK)
{
emsg(_(e_missing_closing_paren));
clear_tv(rettv);
ret = FAIL;
}
}
break;
default: ret = NOTDONE;
break;
}
if (ret == NOTDONE)
{
/*
* Must be a variable or function name.
* Can also be a curly-braces kind of name: {expr}.
*/
s = *arg;
len = get_name_len(arg, &alias, evaluate, TRUE);
if (alias != NULL)
s = alias;
if (len <= 0)
ret = FAIL;
else
{
int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
if (evaluate && in_vim9script() && len == 1 && *s == '_')
{
emsg(_(e_cannot_use_underscore_here));
ret = FAIL;
}
else if ((in_vim9script() ? **arg : *skipwhite(*arg)) == '(')
{
// "name(..." recursive!
*arg = skipwhite(*arg);
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
}
else if (flags & EVAL_CONSTANT)
ret = FAIL;
else if (evaluate)
{
// get the value of "true", "false" or a variable
if (len == 4 && in_vim9script() && STRNCMP(s, "true", 4) == 0)
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_TRUE;
ret = OK;
}
else if (len == 5 && in_vim9script()
&& STRNCMP(s, "false", 5) == 0)
{
rettv->v_type = VAR_BOOL;
rettv->vval.v_number = VVAL_FALSE;
ret = OK;
}
else if (len == 4 && in_vim9script()
&& STRNCMP(s, "null", 4) == 0)
{
rettv->v_type = VAR_SPECIAL;
rettv->vval.v_number = VVAL_NULL;
ret = OK;
}
else
{
name_start = s;
ret = eval_variable(s, len, 0, rettv, NULL,
EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT);
}
}
else
{
// skip the name
check_vars(s, len);
ret = OK;
}
}
vim_free(alias);
}
// Handle following '[', '(' and '.' for expr[expr], expr.name,
// expr(expr), expr->name(expr)
if (ret == OK)
ret = handle_subscript(arg, name_start, rettv, evalarg, TRUE);
/*
* Apply logical NOT and unary '-', from right to left, ignore '+'.
*/
if (ret == OK && evaluate && end_leader > start_leader)
ret = eval7_leader(rettv, FALSE, start_leader, &end_leader);
--recurse;
return ret;
}
|
324139368658301016034800923930937563014
|
eval.c
|
208824404078014502397565483410500490043
|
CWE-787
|
CVE-2022-0351
|
Access of Memory Location Before Start of Buffer in GitHub repository vim/vim prior to 8.2.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-0351
|
204,278
|
firejail
|
1884ea22a90d225950d81c804f1771b42ae55f54
|
https://github.com/netblue30/firejail
|
https://github.com/netblue30/firejail/commit/1884ea22a90d225950d81c804f1771b42ae55f54
|
CVE-2022-31214: fixing the fix, one more time
the previous commit "CVE-2022-31214: fixing the fix"
made private-etc=fonts,fonts and similar commands
fail with an error
fix that regression by tolerating already existing
directories
| 1
|
static void build_dirs(char *src, char *dst, size_t src_prefix_len, size_t dst_prefix_len) {
char *p = src + src_prefix_len + 1;
char *q = dst + dst_prefix_len + 1;
char *r = dst + dst_prefix_len;
struct stat s;
bool last = false;
*r = '\0';
for (; !last; p++, q++) {
if (*p == '\0') {
last = true;
}
if (*p == '\0' || (*p == '/' && *(p - 1) != '/')) {
// We found a new component of our src path.
// Null-terminate it temporarily here so that we can work
// with it.
*p = '\0';
if (stat(src, &s) == 0 && S_ISDIR(s.st_mode)) {
// Null-terminate the dst path and undo its previous
// termination.
*q = '\0';
*r = '/';
r = q;
mkdir_attr(dst, s.st_mode, 0, 0);
}
if (!last) {
// If we're not at the final terminating null, restore
// the slash so that we can continue our traversal.
*p = '/';
}
}
}
}
|
306665336163416948713995999483700256340
|
None
|
CWE-94
|
CVE-2022-31214
|
A Privilege Context Switching issue was discovered in join.c in Firejail 0.9.68. By crafting a bogus Firejail container that is accepted by the Firejail setuid-root program as a join target, a local attacker can enter an environment in which the Linux user namespace is still the initial user namespace, the NO_NEW_PRIVS prctl is not activated, and the entered mount namespace is under the attacker's control. In this way, the filesystem layout can be adjusted to gain root privileges through execution of available setuid-root binaries such as su or sudo.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-31214
|
|
356,170
|
firejail
|
1884ea22a90d225950d81c804f1771b42ae55f54
|
https://github.com/netblue30/firejail
|
https://github.com/netblue30/firejail/commit/1884ea22a90d225950d81c804f1771b42ae55f54
|
CVE-2022-31214: fixing the fix, one more time
the previous commit "CVE-2022-31214: fixing the fix"
made private-etc=fonts,fonts and similar commands
fail with an error
fix that regression by tolerating already existing
directories
| 0
|
static void build_dirs(char *src, char *dst, size_t src_prefix_len, size_t dst_prefix_len) {
char *p = src + src_prefix_len + 1;
char *q = dst + dst_prefix_len + 1;
char *r = dst + dst_prefix_len;
struct stat s;
bool last = false;
*r = '\0';
for (; !last; p++, q++) {
if (*p == '\0') {
last = true;
}
if (*p == '\0' || (*p == '/' && *(p - 1) != '/')) {
// We found a new component of our src path.
// Null-terminate it temporarily here so that we can work
// with it.
*p = '\0';
if (stat(src, &s) == 0 && S_ISDIR(s.st_mode)) {
// Null-terminate the dst path and undo its previous
// termination.
*q = '\0';
*r = '/';
r = q;
if (mkdir(dst, 0700) != 0 && errno != EEXIST)
errExit("mkdir");
if (chmod(dst, s.st_mode) != 0)
errExit("chmod");
}
if (!last) {
// If we're not at the final terminating null, restore
// the slash so that we can continue our traversal.
*p = '/';
}
}
}
}
|
189578159776607937045956887346946926481
|
None
|
CWE-94
|
CVE-2022-31214
|
A Privilege Context Switching issue was discovered in join.c in Firejail 0.9.68. By crafting a bogus Firejail container that is accepted by the Firejail setuid-root program as a join target, a local attacker can enter an environment in which the Linux user namespace is still the initial user namespace, the NO_NEW_PRIVS prctl is not activated, and the entered mount namespace is under the attacker's control. In this way, the filesystem layout can be adjusted to gain root privileges through execution of available setuid-root binaries such as su or sudo.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-31214
|
|
204,351
|
squirrel
|
23a0620658714b996d20da3d4dd1a0dcf9b0bd98
|
https://github.com/albertodemichelis/squirrel
|
https://github.com/albertodemichelis/squirrel/commit/23a0620658714b996d20da3d4dd1a0dcf9b0bd98
|
check max member count in class
| 1
|
bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
{
SQObjectPtr temp;
bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;
if(_locked && !belongs_to_static_table)
return false; //the class already has an instance so cannot be modified
if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
{
_defaultvalues[_member_idx(temp)].val = val;
return true;
}
if(belongs_to_static_table) {
SQInteger mmidx;
if((sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE) &&
(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
_metamethods[mmidx] = val;
}
else {
SQObjectPtr theval = val;
if(_base && sq_type(val) == OT_CLOSURE) {
theval = _closure(val)->Clone();
_closure(theval)->_base = _base;
__ObjAddRef(_base); //ref for the closure
}
if(sq_type(temp) == OT_NULL) {
bool isconstructor;
SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
if(isconstructor) {
_constructoridx = (SQInteger)_methods.size();
}
SQClassMember m;
m.val = theval;
_members->NewSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));
_methods.push_back(m);
}
else {
_methods[_member_idx(temp)].val = theval;
}
}
return true;
}
SQClassMember m;
m.val = val;
_members->NewSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));
_defaultvalues.push_back(m);
return true;
}
|
269872855469648419079058130898644045027
|
sqclass.cpp
|
75131817582394814638781750834830258905
|
CWE-125
|
CVE-2021-41556
|
sqclass.cpp in Squirrel through 2.2.5 and 3.x through 3.1 allows an out-of-bounds read (in the core interpreter) that can lead to Code Execution. If a victim executes an attacker-controlled squirrel script, it is possible for the attacker to break out of the squirrel script sandbox even if all dangerous functionality such as File System functions has been disabled. An attacker might abuse this bug to target (for example) Cloud services that allow customization via SquirrelScripts, or distribute malware through video games that embed a Squirrel Engine.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41556
|
357,668
|
squirrel
|
23a0620658714b996d20da3d4dd1a0dcf9b0bd98
|
https://github.com/albertodemichelis/squirrel
|
https://github.com/albertodemichelis/squirrel/commit/23a0620658714b996d20da3d4dd1a0dcf9b0bd98
|
check max member count in class
| 0
|
bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
{
SQObjectPtr temp;
bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;
if(_locked && !belongs_to_static_table)
return false; //the class already has an instance so cannot be modified
if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
{
_defaultvalues[_member_idx(temp)].val = val;
return true;
}
if (_members->CountUsed() >= MEMBER_MAX_COUNT) {
return false;
}
if(belongs_to_static_table) {
SQInteger mmidx;
if((sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE) &&
(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
_metamethods[mmidx] = val;
}
else {
SQObjectPtr theval = val;
if(_base && sq_type(val) == OT_CLOSURE) {
theval = _closure(val)->Clone();
_closure(theval)->_base = _base;
__ObjAddRef(_base); //ref for the closure
}
if(sq_type(temp) == OT_NULL) {
bool isconstructor;
SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
if(isconstructor) {
_constructoridx = (SQInteger)_methods.size();
}
SQClassMember m;
m.val = theval;
_members->NewSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));
_methods.push_back(m);
}
else {
_methods[_member_idx(temp)].val = theval;
}
}
return true;
}
SQClassMember m;
m.val = val;
_members->NewSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));
_defaultvalues.push_back(m);
return true;
}
|
114176109037888032181151333197990654093
|
sqclass.cpp
|
129356662613675265537572681929065618991
|
CWE-125
|
CVE-2021-41556
|
sqclass.cpp in Squirrel through 2.2.5 and 3.x through 3.1 allows an out-of-bounds read (in the core interpreter) that can lead to Code Execution. If a victim executes an attacker-controlled squirrel script, it is possible for the attacker to break out of the squirrel script sandbox even if all dangerous functionality such as File System functions has been disabled. An attacker might abuse this bug to target (for example) Cloud services that allow customization via SquirrelScripts, or distribute malware through video games that embed a Squirrel Engine.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-41556
|
204,412
|
bpf
|
4b81ccebaeee885ab1aa1438133f2991e3a2b6ea
|
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
|
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=4b81ccebaeee885ab1aa1438133f2991e3a2b6ea
|
bpf, ringbuf: Deny reserve of buffers larger than ringbuf
A BPF program might try to reserve a buffer larger than the ringbuf size.
If the consumer pointer is way ahead of the producer, that would be
successfully reserved, allowing the BPF program to read or write out of
the ringbuf allocated area.
Reported-by: Ryota Shiga (Flatt Security)
Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it")
Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
| 1
|
static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
{
unsigned long cons_pos, prod_pos, new_prod_pos, flags;
u32 len, pg_off;
struct bpf_ringbuf_hdr *hdr;
if (unlikely(size > RINGBUF_MAX_RECORD_SZ))
return NULL;
len = round_up(size + BPF_RINGBUF_HDR_SZ, 8);
cons_pos = smp_load_acquire(&rb->consumer_pos);
if (in_nmi()) {
if (!spin_trylock_irqsave(&rb->spinlock, flags))
return NULL;
} else {
spin_lock_irqsave(&rb->spinlock, flags);
}
prod_pos = rb->producer_pos;
new_prod_pos = prod_pos + len;
/* check for out of ringbuf space by ensuring producer position
* doesn't advance more than (ringbuf_size - 1) ahead
*/
if (new_prod_pos - cons_pos > rb->mask) {
spin_unlock_irqrestore(&rb->spinlock, flags);
return NULL;
}
hdr = (void *)rb->data + (prod_pos & rb->mask);
pg_off = bpf_ringbuf_rec_pg_off(rb, hdr);
hdr->len = size | BPF_RINGBUF_BUSY_BIT;
hdr->pg_off = pg_off;
/* pairs with consumer's smp_load_acquire() */
smp_store_release(&rb->producer_pos, new_prod_pos);
spin_unlock_irqrestore(&rb->spinlock, flags);
return (void *)hdr + BPF_RINGBUF_HDR_SZ;
}
|
305878074800514937766892583405358065403
|
ringbuf.c
|
6876939472683174674440151046802738508
|
CWE-787
|
CVE-2021-3489
|
The eBPF RINGBUF bpf_ringbuf_reserve() function in the Linux kernel did not check that the allocated size was smaller than the ringbuf size, allowing an attacker to perform out-of-bounds writes within the kernel and therefore, arbitrary code execution. This issue was fixed via commit 4b81ccebaeee ("bpf, ringbuf: Deny reserve of buffers larger than ringbuf") (v5.13-rc4) and backported to the stable kernels in v5.12.4, v5.11.21, and v5.10.37. It was introduced via 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it") (v5.8-rc1).
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3489
|
359,206
|
bpf
|
4b81ccebaeee885ab1aa1438133f2991e3a2b6ea
|
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
|
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=4b81ccebaeee885ab1aa1438133f2991e3a2b6ea
|
bpf, ringbuf: Deny reserve of buffers larger than ringbuf
A BPF program might try to reserve a buffer larger than the ringbuf size.
If the consumer pointer is way ahead of the producer, that would be
successfully reserved, allowing the BPF program to read or write out of
the ringbuf allocated area.
Reported-by: Ryota Shiga (Flatt Security)
Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it")
Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
| 0
|
static void *__bpf_ringbuf_reserve(struct bpf_ringbuf *rb, u64 size)
{
unsigned long cons_pos, prod_pos, new_prod_pos, flags;
u32 len, pg_off;
struct bpf_ringbuf_hdr *hdr;
if (unlikely(size > RINGBUF_MAX_RECORD_SZ))
return NULL;
len = round_up(size + BPF_RINGBUF_HDR_SZ, 8);
if (len > rb->mask + 1)
return NULL;
cons_pos = smp_load_acquire(&rb->consumer_pos);
if (in_nmi()) {
if (!spin_trylock_irqsave(&rb->spinlock, flags))
return NULL;
} else {
spin_lock_irqsave(&rb->spinlock, flags);
}
prod_pos = rb->producer_pos;
new_prod_pos = prod_pos + len;
/* check for out of ringbuf space by ensuring producer position
* doesn't advance more than (ringbuf_size - 1) ahead
*/
if (new_prod_pos - cons_pos > rb->mask) {
spin_unlock_irqrestore(&rb->spinlock, flags);
return NULL;
}
hdr = (void *)rb->data + (prod_pos & rb->mask);
pg_off = bpf_ringbuf_rec_pg_off(rb, hdr);
hdr->len = size | BPF_RINGBUF_BUSY_BIT;
hdr->pg_off = pg_off;
/* pairs with consumer's smp_load_acquire() */
smp_store_release(&rb->producer_pos, new_prod_pos);
spin_unlock_irqrestore(&rb->spinlock, flags);
return (void *)hdr + BPF_RINGBUF_HDR_SZ;
}
|
233821322614692863219886146117009832812
|
ringbuf.c
|
3063228527898556498340075998394929987
|
CWE-787
|
CVE-2021-3489
|
The eBPF RINGBUF bpf_ringbuf_reserve() function in the Linux kernel did not check that the allocated size was smaller than the ringbuf size, allowing an attacker to perform out-of-bounds writes within the kernel and therefore, arbitrary code execution. This issue was fixed via commit 4b81ccebaeee ("bpf, ringbuf: Deny reserve of buffers larger than ringbuf") (v5.13-rc4) and backported to the stable kernels in v5.12.4, v5.11.21, and v5.10.37. It was introduced via 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it") (v5.8-rc1).
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3489
|
204,425
|
frr
|
6d58272b4cf96f0daa846210dd2104877900f921
|
https://github.com/FRRouting/frr
|
https://github.com/FRRouting/frr/commit/6d58272b4cf96f0daa846210dd2104877900f921
|
[bgpd] cleanup, compact and consolidate capability parsing code
2007-07-26 Paul Jakma <[email protected]>
* (general) Clean up and compact capability parsing slightly.
Consolidate validation of length and logging of generic TLV, and
memcpy of capability data, thus removing such from cap specifc
code (not always present or correct).
* bgp_open.h: Add structures for the generic capability TLV header
and for the data formats of the various specific capabilities we
support. Hence remove the badly named, or else misdefined, struct
capability.
* bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data.
Do the length checks *before* memcpy()'ing based on that length
(stored capability - should have been validated anyway on input,
but..).
(bgp_afi_safi_valid_indices) new function to validate (afi,safi)
which is about to be used as index into arrays, consolidates
several instances of same, at least one of which appeared to be
incomplete..
(bgp_capability_mp) Much condensed.
(bgp_capability_orf_entry) New, process one ORF entry
(bgp_capability_orf) Condensed. Fixed to process all ORF entries.
(bgp_capability_restart) Condensed, and fixed to use a
cap-specific type, rather than abusing capability_mp.
(struct message capcode_str) added to aid generic logging.
(size_t cap_minsizes[]) added to aid generic validation of
capability length field.
(bgp_capability_parse) Generic logging and validation of TLV
consolidated here. Code compacted as much as possible.
* bgp_packet.c: (bgp_open_receive) Capability parsers now use
streams, so no more need here to manually fudge the input stream
getp.
(bgp_capability_msg_parse) use struct capability_mp_data. Validate
lengths /before/ memcpy. Use bgp_afi_safi_valid_indices.
(bgp_capability_receive) Exported for use by test harness.
* bgp_vty.c: (bgp_show_summary) fix conversion warning
(bgp_show_peer) ditto
* bgp_debug.h: Fix storage 'extern' after type 'const'.
* lib/log.c: (mes_lookup) warning about code not being in
same-number array slot should be debug, not warning. E.g. BGP
has several discontigious number spaces, allocating from
different parts of a space is not uncommon (e.g. IANA
assigned versus vendor-assigned code points in some number
space).
| 1
|
bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
{
u_char *end;
struct capability cap;
u_char action;
struct bgp *bgp;
afi_t afi;
safi_t safi;
bgp = peer->bgp;
end = pnt + length;
while (pnt < end)
{
/* We need at least action, capability code and capability length. */
if (pnt + 3 > end)
{
zlog_info ("%s Capability length error", peer->host);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
action = *pnt;
/* Fetch structure to the byte stream. */
memcpy (&cap, pnt + 1, sizeof (struct capability));
/* Action value check. */
if (action != CAPABILITY_ACTION_SET
&& action != CAPABILITY_ACTION_UNSET)
{
zlog_info ("%s Capability Action Value error %d",
peer->host, action);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s CAPABILITY has action: %d, code: %u, length %u",
peer->host, action, cap.code, cap.length);
/* Capability length check. */
if (pnt + (cap.length + 3) > end)
{
zlog_info ("%s Capability length error", peer->host);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
/* We know MP Capability Code. */
if (cap.code == CAPABILITY_CODE_MP)
{
afi = ntohs (cap.mpc.afi);
safi = cap.mpc.safi;
/* Ignore capability when override-capability is set. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
continue;
/* Address family check. */
if ((afi == AFI_IP
|| afi == AFI_IP6)
&& (safi == SAFI_UNICAST
|| safi == SAFI_MULTICAST
|| safi == BGP_SAFI_VPNV4))
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s CAPABILITY has %s MP_EXT CAP for afi/safi: %u/%u",
peer->host,
action == CAPABILITY_ACTION_SET
? "Advertising" : "Removing",
ntohs(cap.mpc.afi) , cap.mpc.safi);
/* Adjust safi code. */
if (safi == BGP_SAFI_VPNV4)
safi = SAFI_MPLS_VPN;
if (action == CAPABILITY_ACTION_SET)
{
peer->afc_recv[afi][safi] = 1;
if (peer->afc[afi][safi])
{
peer->afc_nego[afi][safi] = 1;
bgp_announce_route (peer, afi, safi);
}
}
else
{
peer->afc_recv[afi][safi] = 0;
peer->afc_nego[afi][safi] = 0;
if (peer_active_nego (peer))
bgp_clear_route (peer, afi, safi);
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
}
else
{
zlog_warn ("%s unrecognized capability code: %d - ignored",
peer->host, cap.code);
}
pnt += cap.length + 3;
}
return 0;
}
|
158680384884701932457641345037828096002
|
bgp_packet.c
|
16679227999356180294013513559974077753
|
CWE-125
|
CVE-2022-37032
|
An out-of-bounds read in the BGP daemon of FRRouting FRR before 8.4 may lead to a segmentation fault and denial of service. This occurs in bgp_capability_msg_parse in bgpd/bgp_packet.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-37032
|
359,365
|
frr
|
6d58272b4cf96f0daa846210dd2104877900f921
|
https://github.com/FRRouting/frr
|
https://github.com/FRRouting/frr/commit/6d58272b4cf96f0daa846210dd2104877900f921
|
[bgpd] cleanup, compact and consolidate capability parsing code
2007-07-26 Paul Jakma <[email protected]>
* (general) Clean up and compact capability parsing slightly.
Consolidate validation of length and logging of generic TLV, and
memcpy of capability data, thus removing such from cap specifc
code (not always present or correct).
* bgp_open.h: Add structures for the generic capability TLV header
and for the data formats of the various specific capabilities we
support. Hence remove the badly named, or else misdefined, struct
capability.
* bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data.
Do the length checks *before* memcpy()'ing based on that length
(stored capability - should have been validated anyway on input,
but..).
(bgp_afi_safi_valid_indices) new function to validate (afi,safi)
which is about to be used as index into arrays, consolidates
several instances of same, at least one of which appeared to be
incomplete..
(bgp_capability_mp) Much condensed.
(bgp_capability_orf_entry) New, process one ORF entry
(bgp_capability_orf) Condensed. Fixed to process all ORF entries.
(bgp_capability_restart) Condensed, and fixed to use a
cap-specific type, rather than abusing capability_mp.
(struct message capcode_str) added to aid generic logging.
(size_t cap_minsizes[]) added to aid generic validation of
capability length field.
(bgp_capability_parse) Generic logging and validation of TLV
consolidated here. Code compacted as much as possible.
* bgp_packet.c: (bgp_open_receive) Capability parsers now use
streams, so no more need here to manually fudge the input stream
getp.
(bgp_capability_msg_parse) use struct capability_mp_data. Validate
lengths /before/ memcpy. Use bgp_afi_safi_valid_indices.
(bgp_capability_receive) Exported for use by test harness.
* bgp_vty.c: (bgp_show_summary) fix conversion warning
(bgp_show_peer) ditto
* bgp_debug.h: Fix storage 'extern' after type 'const'.
* lib/log.c: (mes_lookup) warning about code not being in
same-number array slot should be debug, not warning. E.g. BGP
has several discontigious number spaces, allocating from
different parts of a space is not uncommon (e.g. IANA
assigned versus vendor-assigned code points in some number
space).
| 0
|
bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length)
{
u_char *end;
struct capability_mp_data mpc;
struct capability_header *hdr;
u_char action;
struct bgp *bgp;
afi_t afi;
safi_t safi;
bgp = peer->bgp;
end = pnt + length;
while (pnt < end)
{
/* We need at least action, capability code and capability length. */
if (pnt + 3 > end)
{
zlog_info ("%s Capability length error", peer->host);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
action = *pnt;
hdr = (struct capability_header *)(pnt + 1);
/* Action value check. */
if (action != CAPABILITY_ACTION_SET
&& action != CAPABILITY_ACTION_UNSET)
{
zlog_info ("%s Capability Action Value error %d",
peer->host, action);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s CAPABILITY has action: %d, code: %u, length %u",
peer->host, action, hdr->code, hdr->length);
/* Capability length check. */
if ((pnt + hdr->length + 3) > end)
{
zlog_info ("%s Capability length error", peer->host);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
return -1;
}
/* Fetch structure to the byte stream. */
memcpy (&mpc, pnt + 3, sizeof (struct capability_mp_data));
/* We know MP Capability Code. */
if (hdr->code == CAPABILITY_CODE_MP)
{
afi = ntohs (mpc.afi);
safi = mpc.safi;
/* Ignore capability when override-capability is set. */
if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
continue;
if (!bgp_afi_safi_valid_indices (afi, &safi))
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s Dynamic Capability MP_EXT afi/safi invalid",
peer->host, afi, safi);
continue;
}
/* Address family check. */
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s CAPABILITY has %s MP_EXT CAP for afi/safi: %u/%u",
peer->host,
action == CAPABILITY_ACTION_SET
? "Advertising" : "Removing",
ntohs(mpc.afi) , mpc.safi);
if (action == CAPABILITY_ACTION_SET)
{
peer->afc_recv[afi][safi] = 1;
if (peer->afc[afi][safi])
{
peer->afc_nego[afi][safi] = 1;
bgp_announce_route (peer, afi, safi);
}
}
else
{
peer->afc_recv[afi][safi] = 0;
peer->afc_nego[afi][safi] = 0;
if (peer_active_nego (peer))
bgp_clear_route (peer, afi, safi);
else
BGP_EVENT_ADD (peer, BGP_Stop);
}
}
else
{
zlog_warn ("%s unrecognized capability code: %d - ignored",
peer->host, hdr->code);
}
pnt += hdr->length + 3;
}
return 0;
}
|
222322579110596507029051344758915923400
|
bgp_packet.c
|
203634856057323248974002745421549823051
|
CWE-125
|
CVE-2022-37032
|
An out-of-bounds read in the BGP daemon of FRRouting FRR before 8.4 may lead to a segmentation fault and denial of service. This occurs in bgp_capability_msg_parse in bgpd/bgp_packet.c.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-37032
|
204,438
|
ImageMagick
|
716496e6df0add89e9679d6da9c0afca814cfe49
|
https://github.com/ImageMagick/ImageMagick
|
https://github.com/ImageMagick/ImageMagick/commit/716496e6df0add89e9679d6da9c0afca814cfe49
|
do not attempt to write a null image list (thanks to Vinay Rohila)
| 1
|
WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,
const char *option,const char *arg1n,const char *arg2n)
{
const char /* percent escaped versions of the args */
*arg1,
*arg2;
#define _image_info (cli_wand->wand.image_info)
#define _images (cli_wand->wand.images)
#define _exception (cli_wand->wand.exception)
#define _process_flags (cli_wand->process_flags)
#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
#define IfNormalOp (*option=='-')
#define IfPlusOp (*option!='-')
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == MagickWandSignature);
assert(cli_wand->wand.signature == MagickWandSignature);
if (cli_wand->wand.debug != MagickFalse)
(void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
"- NoImage Operator: %s \"%s\" \"%s\"", option,
arg1n != (char *) NULL ? arg1n : "",
arg2n != (char *) NULL ? arg2n : "");
arg1 = arg1n;
arg2 = arg2n;
/* Interpret Percent Escapes in Arguments - using first image */
if ( (((_process_flags & ProcessInterpretProperities) != 0 )
|| ((_option_type & AlwaysInterpretArgsFlag) != 0)
) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
/* Interpret Percent escapes in argument 1 */
if (arg1n != (char *) NULL) {
arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
if (arg1 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg1=arg1n; /* use the given argument as is */
}
}
if (arg2n != (char *) NULL) {
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg2=arg2n; /* use the given argument as is */
}
}
}
#undef _process_flags
#undef _option_type
do { /* break to exit code */
/*
No-op options (ignore these)
*/
if (LocaleCompare("noop",option+1) == 0) /* zero argument */
break;
if (LocaleCompare("sans",option+1) == 0) /* one argument */
break;
if (LocaleCompare("sans0",option+1) == 0) /* zero argument */
break;
if (LocaleCompare("sans1",option+1) == 0) /* one argument */
break;
if (LocaleCompare("sans2",option+1) == 0) /* two arguments */
break;
/*
Image Reading
*/
if ( ( LocaleCompare("read",option+1) == 0 ) ||
( LocaleCompare("--",option) == 0 ) ) {
/* Do Glob filename Expansion for 'arg1' then read all images.
*
* Expansion handles '@', '~', '*', and '?' meta-characters while ignoring
* (but attaching to the filenames in the generated argument list) any
* [...] read modifiers that may be present.
*
* For example: It will expand '*.gif[20x20]' into a list such as
* 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]'
*
* NOTE: In IMv6 this was done globally across all images. This
* meant you could include IM options in '@filename' lists, but you
* could not include comments. Doing it only for image read makes
* it far more secure.
*
* Note: arguments do not have percent escapes expanded for security
* reasons.
*/
int argc;
char **argv;
ssize_t i;
argc = 1;
argv = (char **) &arg1;
/* Expand 'glob' expressions in the given filename.
Expansion handles any 'coder:' prefix, or read modifiers attached
to the filename, including them in the resulting expanded list.
*/
if (ExpandFilenames(&argc,&argv) == MagickFalse)
CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed",
option,GetExceptionMessage(errno));
/* loop over expanded filename list, and read then all in */
for (i=0; i < (ssize_t) argc; i++) {
Image *
new_images;
if (_image_info->ping != MagickFalse)
new_images=PingImages(_image_info,argv[i],_exception);
else
new_images=ReadImages(_image_info,argv[i],_exception);
AppendImageToList(&_images, new_images);
argv[i]=DestroyString(argv[i]);
}
argv=(char **) RelinquishMagickMemory(argv);
break;
}
/*
Image Writing
Note: Writing a empty image list is valid in specific cases
*/
if (LocaleCompare("write",option+1) == 0) {
/* Note: arguments do not have percent escapes expanded */
char
key[MagickPathExtent];
Image
*write_images;
ImageInfo
*write_info;
/* Need images, unless a "null:" output coder is used */
if ( _images == (Image *) NULL ) {
if ( LocaleCompare(arg1,"null:") == 0 )
break;
CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1);
}
(void) FormatLocaleString(key,MagickPathExtent,"cache:%s",arg1);
(void) DeleteImageRegistry(key);
write_images=CloneImageList(_images,_exception);
write_info=CloneImageInfo(_image_info);
(void) WriteImages(write_info,write_images,arg1,_exception);
write_info=DestroyImageInfo(write_info);
write_images=DestroyImageList(write_images);
break;
}
/*
Parenthesis and Brace operations
*/
if (LocaleCompare("(",option) == 0) {
/* stack 'push' images */
Stack
*node;
size_t
size;
size=0;
node=cli_wand->image_list_stack;
for ( ; node != (Stack *) NULL; node=node->next)
size++;
if ( size >= MAX_STACK_DEPTH )
CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option);
node=(Stack *) AcquireMagickMemory(sizeof(*node));
if (node == (Stack *) NULL)
CLIWandExceptionBreak(ResourceLimitFatalError,
"MemoryAllocationFailed",option);
node->data = (void *)cli_wand->wand.images;
node->next = cli_wand->image_list_stack;
cli_wand->image_list_stack = node;
cli_wand->wand.images = NewImageList();
/* handle respect-parenthesis */
if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
"respect-parenthesis")) != MagickFalse)
option="{"; /* fall-thru so as to push image settings too */
else
break;
/* fall thru to operation */
}
if (LocaleCompare("{",option) == 0) {
/* stack 'push' of image_info settings */
Stack
*node;
size_t
size;
size=0;
node=cli_wand->image_info_stack;
for ( ; node != (Stack *) NULL; node=node->next)
size++;
if ( size >= MAX_STACK_DEPTH )
CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option);
node=(Stack *) AcquireMagickMemory(sizeof(*node));
if (node == (Stack *) NULL)
CLIWandExceptionBreak(ResourceLimitFatalError,
"MemoryAllocationFailed",option);
node->data = (void *)cli_wand->wand.image_info;
node->next = cli_wand->image_info_stack;
cli_wand->image_info_stack = node;
cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
if (cli_wand->wand.image_info == (ImageInfo *) NULL) {
CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
option);
cli_wand->wand.image_info = (ImageInfo *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
break;
}
break;
}
if (LocaleCompare(")",option) == 0) {
/* pop images from stack */
Stack
*node;
node = (Stack *)cli_wand->image_list_stack;
if ( node == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option);
cli_wand->image_list_stack = node->next;
AppendImageToList((Image **)&node->data,cli_wand->wand.images);
cli_wand->wand.images= (Image *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
/* handle respect-parenthesis - of the previous 'pushed' settings */
node = cli_wand->image_info_stack;
if ( node != (Stack *) NULL)
{
if (IsStringTrue(GetImageOption(
cli_wand->wand.image_info,"respect-parenthesis")) != MagickFalse)
option="}"; /* fall-thru so as to pop image settings too */
else
break;
}
else
break;
/* fall thru to next if */
}
if (LocaleCompare("}",option) == 0) {
/* pop image_info settings from stack */
Stack
*node;
node = (Stack *)cli_wand->image_info_stack;
if ( node == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option);
cli_wand->image_info_stack = node->next;
(void) DestroyImageInfo(cli_wand->wand.image_info);
cli_wand->wand.image_info = (ImageInfo *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
break;
}
if (LocaleCompare("print",option+1) == 0)
{
(void) FormatLocaleFile(stdout,"%s",arg1);
break;
}
if (LocaleCompare("set",option+1) == 0)
{
/* Settings are applied to each image in memory in turn (if any).
While a option: only need to be applied once globally.
NOTE: rguments have not been automatically percent expaneded
*/
/* escape the 'key' once only, using first image. */
arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
if (arg1 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
option);
if (LocaleNCompare(arg1,"registry:",9) == 0)
{
if (IfPlusOp)
{
(void) DeleteImageRegistry(arg1+9);
arg1=DestroyString((char *)arg1);
break;
}
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL) {
arg1=DestroyString((char *)arg1);
CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
option);
}
(void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);
arg1=DestroyString((char *)arg1);
arg2=DestroyString((char *)arg2);
break;
}
if (LocaleNCompare(arg1,"option:",7) == 0)
{
/* delete equivelent artifact from all images (if any) */
if (_images != (Image *) NULL)
{
MagickResetIterator(&cli_wand->wand);
while (MagickNextImage(&cli_wand->wand) != MagickFalse)
(void) DeleteImageArtifact(_images,arg1+7);
MagickResetIterator(&cli_wand->wand);
}
/* now set/delete the global option as needed */
/* FUTURE: make escapes in a global 'option:' delayed */
arg2=(char *) NULL;
if (IfNormalOp)
{
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",option);
}
(void) SetImageOption(_image_info,arg1+7,arg2);
arg1=DestroyString((char *)arg1);
arg2=DestroyString((char *)arg2);
break;
}
/* Set Artifacts/Properties/Attributes all images (required) */
if ( _images == (Image *) NULL )
CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1);
MagickResetIterator(&cli_wand->wand);
while (MagickNextImage(&cli_wand->wand) != MagickFalse)
{
arg2=(char *) NULL;
if (IfNormalOp)
{
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",option);
}
if (LocaleNCompare(arg1,"artifact:",9) == 0)
(void) SetImageArtifact(_images,arg1+9,arg2);
else if (LocaleNCompare(arg1,"property:",9) == 0)
(void) SetImageProperty(_images,arg1+9,arg2,_exception);
else
(void) SetImageProperty(_images,arg1,arg2,_exception);
arg2=DestroyString((char *)arg2);
}
MagickResetIterator(&cli_wand->wand);
arg1=DestroyString((char *)arg1);
break;
}
if (LocaleCompare("clone",option+1) == 0) {
Image
*new_images;
if (*option == '+')
arg1=AcquireString("-1");
if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
CLIWandExceptionBreak(OptionError,"InvalidArgument",option);
if ( cli_wand->image_list_stack == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
new_images = (Image *)cli_wand->image_list_stack->data;
if (new_images == (Image *) NULL)
CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
new_images=CloneImages(new_images,arg1,_exception);
if (new_images == (Image *) NULL)
CLIWandExceptionBreak(OptionError,"NoSuchImage",option);
AppendImageToList(&_images,new_images);
break;
}
/*
Informational Operations.
Note that these do not require either a cli-wand or images!
Though currently a cli-wand much be provided regardless.
*/
if (LocaleCompare("version",option+1) == 0)
{
ListMagickVersion(stdout);
break;
}
if (LocaleCompare("list",option+1) == 0) {
/*
FUTURE: This 'switch' should really be part of MagickCore
*/
ssize_t
list;
list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
if ( list < 0 ) {
CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
break;
}
switch (list)
{
case MagickCoderOptions:
{
(void) ListCoderInfo((FILE *) NULL,_exception);
break;
}
case MagickColorOptions:
{
(void) ListColorInfo((FILE *) NULL,_exception);
break;
}
case MagickConfigureOptions:
{
(void) ListConfigureInfo((FILE *) NULL,_exception);
break;
}
case MagickDelegateOptions:
{
(void) ListDelegateInfo((FILE *) NULL,_exception);
break;
}
case MagickFontOptions:
{
(void) ListTypeInfo((FILE *) NULL,_exception);
break;
}
case MagickFormatOptions:
(void) ListMagickInfo((FILE *) NULL,_exception);
break;
case MagickLocaleOptions:
(void) ListLocaleInfo((FILE *) NULL,_exception);
break;
case MagickLogOptions:
(void) ListLogInfo((FILE *) NULL,_exception);
break;
case MagickMagicOptions:
(void) ListMagicInfo((FILE *) NULL,_exception);
break;
case MagickMimeOptions:
(void) ListMimeInfo((FILE *) NULL,_exception);
break;
case MagickModuleOptions:
(void) ListModuleInfo((FILE *) NULL,_exception);
break;
case MagickPolicyOptions:
(void) ListPolicyInfo((FILE *) NULL,_exception);
break;
case MagickResourceOptions:
(void) ListMagickResourceInfo((FILE *) NULL,_exception);
break;
case MagickThresholdOptions:
(void) ListThresholdMaps((FILE *) NULL,_exception);
break;
default:
(void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
_exception);
break;
}
break;
}
CLIWandException(OptionError,"UnrecognizedOption",option);
DisableMSCWarning(4127)
} while (0); /* break to exit code. */
RestoreMSCWarning
/* clean up percent escape interpreted strings */
if (arg1 != arg1n )
arg1=DestroyString((char *)arg1);
if (arg2 != arg2n )
arg2=DestroyString((char *)arg2);
#undef _image_info
#undef _images
#undef _exception
#undef IfNormalOp
#undef IfPlusOp
}
|
310441418553941793285963012286957612842
|
operation.c
|
209735039697633444699043395330012675070
|
CWE-617
|
CVE-2022-2719
|
In ImageMagick, a crafted file could trigger an assertion failure when a call to WriteImages was made in MagickWand/operation.c, due to a NULL image list. This could potentially cause a denial of service. This was fixed in upstream ImageMagick version 7.1.0-30.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-2719
|
359,843
|
ImageMagick
|
716496e6df0add89e9679d6da9c0afca814cfe49
|
https://github.com/ImageMagick/ImageMagick
|
https://github.com/ImageMagick/ImageMagick/commit/716496e6df0add89e9679d6da9c0afca814cfe49
|
do not attempt to write a null image list (thanks to Vinay Rohila)
| 0
|
WandPrivate void CLINoImageOperator(MagickCLI *cli_wand,
const char *option,const char *arg1n,const char *arg2n)
{
const char /* percent escaped versions of the args */
*arg1,
*arg2;
#define _image_info (cli_wand->wand.image_info)
#define _images (cli_wand->wand.images)
#define _exception (cli_wand->wand.exception)
#define _process_flags (cli_wand->process_flags)
#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
#define IfNormalOp (*option=='-')
#define IfPlusOp (*option!='-')
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == MagickWandSignature);
assert(cli_wand->wand.signature == MagickWandSignature);
if (cli_wand->wand.debug != MagickFalse)
(void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(),
"- NoImage Operator: %s \"%s\" \"%s\"", option,
arg1n != (char *) NULL ? arg1n : "",
arg2n != (char *) NULL ? arg2n : "");
arg1 = arg1n;
arg2 = arg2n;
/* Interpret Percent Escapes in Arguments - using first image */
if ( (((_process_flags & ProcessInterpretProperities) != 0 )
|| ((_option_type & AlwaysInterpretArgsFlag) != 0)
) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
/* Interpret Percent escapes in argument 1 */
if (arg1n != (char *) NULL) {
arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
if (arg1 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg1=arg1n; /* use the given argument as is */
}
}
if (arg2n != (char *) NULL) {
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg2=arg2n; /* use the given argument as is */
}
}
}
#undef _process_flags
#undef _option_type
do { /* break to exit code */
/*
No-op options (ignore these)
*/
if (LocaleCompare("noop",option+1) == 0) /* zero argument */
break;
if (LocaleCompare("sans",option+1) == 0) /* one argument */
break;
if (LocaleCompare("sans0",option+1) == 0) /* zero argument */
break;
if (LocaleCompare("sans1",option+1) == 0) /* one argument */
break;
if (LocaleCompare("sans2",option+1) == 0) /* two arguments */
break;
/*
Image Reading
*/
if ( ( LocaleCompare("read",option+1) == 0 ) ||
( LocaleCompare("--",option) == 0 ) ) {
/* Do Glob filename Expansion for 'arg1' then read all images.
*
* Expansion handles '@', '~', '*', and '?' meta-characters while ignoring
* (but attaching to the filenames in the generated argument list) any
* [...] read modifiers that may be present.
*
* For example: It will expand '*.gif[20x20]' into a list such as
* 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]'
*
* NOTE: In IMv6 this was done globally across all images. This
* meant you could include IM options in '@filename' lists, but you
* could not include comments. Doing it only for image read makes
* it far more secure.
*
* Note: arguments do not have percent escapes expanded for security
* reasons.
*/
int argc;
char **argv;
ssize_t i;
argc = 1;
argv = (char **) &arg1;
/* Expand 'glob' expressions in the given filename.
Expansion handles any 'coder:' prefix, or read modifiers attached
to the filename, including them in the resulting expanded list.
*/
if (ExpandFilenames(&argc,&argv) == MagickFalse)
CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed",
option,GetExceptionMessage(errno));
/* loop over expanded filename list, and read then all in */
for (i=0; i < (ssize_t) argc; i++) {
Image *
new_images;
if (_image_info->ping != MagickFalse)
new_images=PingImages(_image_info,argv[i],_exception);
else
new_images=ReadImages(_image_info,argv[i],_exception);
AppendImageToList(&_images, new_images);
argv[i]=DestroyString(argv[i]);
}
argv=(char **) RelinquishMagickMemory(argv);
break;
}
/*
Image Writing
Note: Writing a empty image list is valid in specific cases
*/
if (LocaleCompare("write",option+1) == 0) {
/* Note: arguments do not have percent escapes expanded */
char
key[MagickPathExtent];
Image
*write_images;
ImageInfo
*write_info;
/* Need images, unless a "null:" output coder is used */
if ( _images == (Image *) NULL ) {
if ( LocaleCompare(arg1,"null:") == 0 )
break;
CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1);
}
(void) FormatLocaleString(key,MagickPathExtent,"cache:%s",arg1);
(void) DeleteImageRegistry(key);
write_images=CloneImageList(_images,_exception);
write_info=CloneImageInfo(_image_info);
if (write_images != (Image *) NULL)
(void) WriteImages(write_info,write_images,arg1,_exception);
write_info=DestroyImageInfo(write_info);
write_images=DestroyImageList(write_images);
break;
}
/*
Parenthesis and Brace operations
*/
if (LocaleCompare("(",option) == 0) {
/* stack 'push' images */
Stack
*node;
size_t
size;
size=0;
node=cli_wand->image_list_stack;
for ( ; node != (Stack *) NULL; node=node->next)
size++;
if ( size >= MAX_STACK_DEPTH )
CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option);
node=(Stack *) AcquireMagickMemory(sizeof(*node));
if (node == (Stack *) NULL)
CLIWandExceptionBreak(ResourceLimitFatalError,
"MemoryAllocationFailed",option);
node->data = (void *)cli_wand->wand.images;
node->next = cli_wand->image_list_stack;
cli_wand->image_list_stack = node;
cli_wand->wand.images = NewImageList();
/* handle respect-parenthesis */
if (IsStringTrue(GetImageOption(cli_wand->wand.image_info,
"respect-parenthesis")) != MagickFalse)
option="{"; /* fall-thru so as to push image settings too */
else
break;
/* fall thru to operation */
}
if (LocaleCompare("{",option) == 0) {
/* stack 'push' of image_info settings */
Stack
*node;
size_t
size;
size=0;
node=cli_wand->image_info_stack;
for ( ; node != (Stack *) NULL; node=node->next)
size++;
if ( size >= MAX_STACK_DEPTH )
CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option);
node=(Stack *) AcquireMagickMemory(sizeof(*node));
if (node == (Stack *) NULL)
CLIWandExceptionBreak(ResourceLimitFatalError,
"MemoryAllocationFailed",option);
node->data = (void *)cli_wand->wand.image_info;
node->next = cli_wand->image_info_stack;
cli_wand->image_info_stack = node;
cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info);
if (cli_wand->wand.image_info == (ImageInfo *) NULL) {
CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed",
option);
cli_wand->wand.image_info = (ImageInfo *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
break;
}
break;
}
if (LocaleCompare(")",option) == 0) {
/* pop images from stack */
Stack
*node;
node = (Stack *)cli_wand->image_list_stack;
if ( node == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option);
cli_wand->image_list_stack = node->next;
AppendImageToList((Image **)&node->data,cli_wand->wand.images);
cli_wand->wand.images= (Image *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
/* handle respect-parenthesis - of the previous 'pushed' settings */
node = cli_wand->image_info_stack;
if ( node != (Stack *) NULL)
{
if (IsStringTrue(GetImageOption(
cli_wand->wand.image_info,"respect-parenthesis")) != MagickFalse)
option="}"; /* fall-thru so as to pop image settings too */
else
break;
}
else
break;
/* fall thru to next if */
}
if (LocaleCompare("}",option) == 0) {
/* pop image_info settings from stack */
Stack
*node;
node = (Stack *)cli_wand->image_info_stack;
if ( node == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option);
cli_wand->image_info_stack = node->next;
(void) DestroyImageInfo(cli_wand->wand.image_info);
cli_wand->wand.image_info = (ImageInfo *)node->data;
node = (Stack *)RelinquishMagickMemory(node);
GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info);
cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info);
cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
break;
}
if (LocaleCompare("print",option+1) == 0)
{
(void) FormatLocaleFile(stdout,"%s",arg1);
break;
}
if (LocaleCompare("set",option+1) == 0)
{
/* Settings are applied to each image in memory in turn (if any).
While a option: only need to be applied once globally.
NOTE: rguments have not been automatically percent expaneded
*/
/* escape the 'key' once only, using first image. */
arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception);
if (arg1 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
option);
if (LocaleNCompare(arg1,"registry:",9) == 0)
{
if (IfPlusOp)
{
(void) DeleteImageRegistry(arg1+9);
arg1=DestroyString((char *)arg1);
break;
}
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL) {
arg1=DestroyString((char *)arg1);
CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
option);
}
(void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception);
arg1=DestroyString((char *)arg1);
arg2=DestroyString((char *)arg2);
break;
}
if (LocaleNCompare(arg1,"option:",7) == 0)
{
/* delete equivelent artifact from all images (if any) */
if (_images != (Image *) NULL)
{
MagickResetIterator(&cli_wand->wand);
while (MagickNextImage(&cli_wand->wand) != MagickFalse)
(void) DeleteImageArtifact(_images,arg1+7);
MagickResetIterator(&cli_wand->wand);
}
/* now set/delete the global option as needed */
/* FUTURE: make escapes in a global 'option:' delayed */
arg2=(char *) NULL;
if (IfNormalOp)
{
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",option);
}
(void) SetImageOption(_image_info,arg1+7,arg2);
arg1=DestroyString((char *)arg1);
arg2=DestroyString((char *)arg2);
break;
}
/* Set Artifacts/Properties/Attributes all images (required) */
if ( _images == (Image *) NULL )
CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1);
MagickResetIterator(&cli_wand->wand);
while (MagickNextImage(&cli_wand->wand) != MagickFalse)
{
arg2=(char *) NULL;
if (IfNormalOp)
{
arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception);
if (arg2 == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,
"InterpretPropertyFailure",option);
}
if (LocaleNCompare(arg1,"artifact:",9) == 0)
(void) SetImageArtifact(_images,arg1+9,arg2);
else if (LocaleNCompare(arg1,"property:",9) == 0)
(void) SetImageProperty(_images,arg1+9,arg2,_exception);
else
(void) SetImageProperty(_images,arg1,arg2,_exception);
arg2=DestroyString((char *)arg2);
}
MagickResetIterator(&cli_wand->wand);
arg1=DestroyString((char *)arg1);
break;
}
if (LocaleCompare("clone",option+1) == 0) {
Image
*new_images;
if (*option == '+')
arg1=AcquireString("-1");
if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse)
CLIWandExceptionBreak(OptionError,"InvalidArgument",option);
if ( cli_wand->image_list_stack == (Stack *) NULL)
CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
new_images = (Image *)cli_wand->image_list_stack->data;
if (new_images == (Image *) NULL)
CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option);
new_images=CloneImages(new_images,arg1,_exception);
if (new_images == (Image *) NULL)
CLIWandExceptionBreak(OptionError,"NoSuchImage",option);
AppendImageToList(&_images,new_images);
break;
}
/*
Informational Operations.
Note that these do not require either a cli-wand or images!
Though currently a cli-wand much be provided regardless.
*/
if (LocaleCompare("version",option+1) == 0)
{
ListMagickVersion(stdout);
break;
}
if (LocaleCompare("list",option+1) == 0) {
/*
FUTURE: This 'switch' should really be part of MagickCore
*/
ssize_t
list;
list=ParseCommandOption(MagickListOptions,MagickFalse,arg1);
if ( list < 0 ) {
CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1);
break;
}
switch (list)
{
case MagickCoderOptions:
{
(void) ListCoderInfo((FILE *) NULL,_exception);
break;
}
case MagickColorOptions:
{
(void) ListColorInfo((FILE *) NULL,_exception);
break;
}
case MagickConfigureOptions:
{
(void) ListConfigureInfo((FILE *) NULL,_exception);
break;
}
case MagickDelegateOptions:
{
(void) ListDelegateInfo((FILE *) NULL,_exception);
break;
}
case MagickFontOptions:
{
(void) ListTypeInfo((FILE *) NULL,_exception);
break;
}
case MagickFormatOptions:
(void) ListMagickInfo((FILE *) NULL,_exception);
break;
case MagickLocaleOptions:
(void) ListLocaleInfo((FILE *) NULL,_exception);
break;
case MagickLogOptions:
(void) ListLogInfo((FILE *) NULL,_exception);
break;
case MagickMagicOptions:
(void) ListMagicInfo((FILE *) NULL,_exception);
break;
case MagickMimeOptions:
(void) ListMimeInfo((FILE *) NULL,_exception);
break;
case MagickModuleOptions:
(void) ListModuleInfo((FILE *) NULL,_exception);
break;
case MagickPolicyOptions:
(void) ListPolicyInfo((FILE *) NULL,_exception);
break;
case MagickResourceOptions:
(void) ListMagickResourceInfo((FILE *) NULL,_exception);
break;
case MagickThresholdOptions:
(void) ListThresholdMaps((FILE *) NULL,_exception);
break;
default:
(void) ListCommandOptions((FILE *) NULL,(CommandOption) list,
_exception);
break;
}
break;
}
CLIWandException(OptionError,"UnrecognizedOption",option);
DisableMSCWarning(4127)
} while (0); /* break to exit code. */
RestoreMSCWarning
/* clean up percent escape interpreted strings */
if (arg1 != arg1n )
arg1=DestroyString((char *)arg1);
if (arg2 != arg2n )
arg2=DestroyString((char *)arg2);
#undef _image_info
#undef _images
#undef _exception
#undef IfNormalOp
#undef IfPlusOp
}
|
579576062025196307167021581529787649
|
operation.c
|
114606754670284270817581814822080534295
|
CWE-617
|
CVE-2022-2719
|
In ImageMagick, a crafted file could trigger an assertion failure when a call to WriteImages was made in MagickWand/operation.c, due to a NULL image list. This could potentially cause a denial of service. This was fixed in upstream ImageMagick version 7.1.0-30.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-2719
|
204,495
|
linux
|
47abea041f897d64dbd5777f0cf7745148f85d75
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/47abea041f897d64dbd5777f0cf7745148f85d75
|
io_uring: fix off-by-one in sync cancelation file check
The passed in index should be validated against the number of registered
files we have, it needs to be smaller than the index value to avoid going
one beyond the end.
Fixes: 78a861b94959 ("io_uring: add sync cancelation API through io_uring_register()")
Reported-by: Luo Likang <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
| 1
|
static int __io_sync_cancel(struct io_uring_task *tctx,
struct io_cancel_data *cd, int fd)
{
struct io_ring_ctx *ctx = cd->ctx;
/* fixed must be grabbed every time since we drop the uring_lock */
if ((cd->flags & IORING_ASYNC_CANCEL_FD) &&
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
unsigned long file_ptr;
if (unlikely(fd > ctx->nr_user_files))
return -EBADF;
fd = array_index_nospec(fd, ctx->nr_user_files);
file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;
cd->file = (struct file *) (file_ptr & FFS_MASK);
if (!cd->file)
return -EBADF;
}
return __io_async_cancel(cd, tctx, 0);
}
|
178631003172617197260225259743936148137
|
cancel.c
|
251597362135051290688561510710144448867
|
CWE-193
|
CVE-2022-3103
|
off-by-one in io_uring module.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3103
|
360,829
|
linux
|
47abea041f897d64dbd5777f0cf7745148f85d75
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/47abea041f897d64dbd5777f0cf7745148f85d75
|
io_uring: fix off-by-one in sync cancelation file check
The passed in index should be validated against the number of registered
files we have, it needs to be smaller than the index value to avoid going
one beyond the end.
Fixes: 78a861b94959 ("io_uring: add sync cancelation API through io_uring_register()")
Reported-by: Luo Likang <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
| 0
|
static int __io_sync_cancel(struct io_uring_task *tctx,
struct io_cancel_data *cd, int fd)
{
struct io_ring_ctx *ctx = cd->ctx;
/* fixed must be grabbed every time since we drop the uring_lock */
if ((cd->flags & IORING_ASYNC_CANCEL_FD) &&
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
unsigned long file_ptr;
if (unlikely(fd >= ctx->nr_user_files))
return -EBADF;
fd = array_index_nospec(fd, ctx->nr_user_files);
file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;
cd->file = (struct file *) (file_ptr & FFS_MASK);
if (!cd->file)
return -EBADF;
}
return __io_async_cancel(cd, tctx, 0);
}
|
191453192245381781842321164119198990689
|
cancel.c
|
191362883793091950391767824989989369401
|
CWE-193
|
CVE-2022-3103
|
off-by-one in io_uring module.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3103
|
204,534
|
admesh
|
e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
https://github.com/admesh/admesh
|
https://github.com/admesh/admesh/commit/e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
Fix heap buffer overflow in stl_update_connects_remove_1
- Add argument value check to the stl_update_connects_remove_1
- Add neighbor value check in stl_remove_degenerate
Fixes https://github.com/admesh/admesh/issues/28
Merges https://github.com/admesh/admesh/pull/55
| 1
|
stl_remove_degenerate(stl_file *stl, int facet) {
int edge1;
int edge2;
int edge3;
int neighbor1;
int neighbor2;
int neighbor3;
int vnot1;
int vnot2;
int vnot3;
if (stl->error) return;
if( !memcmp(&stl->facet_start[facet].vertex[0],
&stl->facet_start[facet].vertex[1], sizeof(stl_vertex))
&& !memcmp(&stl->facet_start[facet].vertex[1],
&stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {
/* all 3 vertices are equal. Just remove the facet. I don't think*/
/* this is really possible, but just in case... */
printf("removing a facet in stl_remove_degenerate\n");
stl_remove_facet(stl, facet);
return;
}
if(!memcmp(&stl->facet_start[facet].vertex[0],
&stl->facet_start[facet].vertex[1], sizeof(stl_vertex))) {
edge1 = 1;
edge2 = 2;
edge3 = 0;
} else if(!memcmp(&stl->facet_start[facet].vertex[1],
&stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {
edge1 = 0;
edge2 = 2;
edge3 = 1;
} else if(!memcmp(&stl->facet_start[facet].vertex[2],
&stl->facet_start[facet].vertex[0], sizeof(stl_vertex))) {
edge1 = 0;
edge2 = 1;
edge3 = 2;
} else {
/* No degenerate. Function shouldn't have been called. */
return;
}
neighbor1 = stl->neighbors_start[facet].neighbor[edge1];
neighbor2 = stl->neighbors_start[facet].neighbor[edge2];
if(neighbor1 == -1) {
stl_update_connects_remove_1(stl, neighbor2);
}
if(neighbor2 == -1) {
stl_update_connects_remove_1(stl, neighbor1);
}
neighbor3 = stl->neighbors_start[facet].neighbor[edge3];
vnot1 = stl->neighbors_start[facet].which_vertex_not[edge1];
vnot2 = stl->neighbors_start[facet].which_vertex_not[edge2];
vnot3 = stl->neighbors_start[facet].which_vertex_not[edge3];
if(neighbor1 != -1){
stl->neighbors_start[neighbor1].neighbor[(vnot1 + 1) % 3] = neighbor2;
stl->neighbors_start[neighbor1].which_vertex_not[(vnot1 + 1) % 3] = vnot2;
}
if(neighbor2 != -1){
stl->neighbors_start[neighbor2].neighbor[(vnot2 + 1) % 3] = neighbor1;
stl->neighbors_start[neighbor2].which_vertex_not[(vnot2 + 1) % 3] = vnot1;
}
stl_remove_facet(stl, facet);
if(neighbor3 != -1) {
stl_update_connects_remove_1(stl, neighbor3);
stl->neighbors_start[neighbor3].neighbor[(vnot3 + 1) % 3] = -1;
}
}
|
62749783590026466291303120848549680020
|
connect.c
|
88334157411234536587499947341326463538
|
CWE-125
|
CVE-2018-25033
|
ADMesh through 0.98.4 has a heap-based buffer over-read in stl_update_connects_remove_1 (called from stl_remove_degenerate) in connect.c in libadmesh.a.
|
https://nvd.nist.gov/vuln/detail/CVE-2018-25033
|
361,303
|
admesh
|
e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
https://github.com/admesh/admesh
|
https://github.com/admesh/admesh/commit/e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
Fix heap buffer overflow in stl_update_connects_remove_1
- Add argument value check to the stl_update_connects_remove_1
- Add neighbor value check in stl_remove_degenerate
Fixes https://github.com/admesh/admesh/issues/28
Merges https://github.com/admesh/admesh/pull/55
| 0
|
stl_remove_degenerate(stl_file *stl, int facet) {
int edge1;
int edge2;
int edge3;
int neighbor1;
int neighbor2;
int neighbor3;
int vnot1;
int vnot2;
int vnot3;
if (stl->error) return;
if( !memcmp(&stl->facet_start[facet].vertex[0],
&stl->facet_start[facet].vertex[1], sizeof(stl_vertex))
&& !memcmp(&stl->facet_start[facet].vertex[1],
&stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {
/* all 3 vertices are equal. Just remove the facet. I don't think*/
/* this is really possible, but just in case... */
printf("removing a facet in stl_remove_degenerate\n");
stl_remove_facet(stl, facet);
return;
}
if(!memcmp(&stl->facet_start[facet].vertex[0],
&stl->facet_start[facet].vertex[1], sizeof(stl_vertex))) {
edge1 = 1;
edge2 = 2;
edge3 = 0;
} else if(!memcmp(&stl->facet_start[facet].vertex[1],
&stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) {
edge1 = 0;
edge2 = 2;
edge3 = 1;
} else if(!memcmp(&stl->facet_start[facet].vertex[2],
&stl->facet_start[facet].vertex[0], sizeof(stl_vertex))) {
edge1 = 0;
edge2 = 1;
edge3 = 2;
} else {
/* No degenerate. Function shouldn't have been called. */
return;
}
neighbor1 = stl->neighbors_start[facet].neighbor[edge1];
neighbor2 = stl->neighbors_start[facet].neighbor[edge2];
if(neighbor1 == -1 && neighbor2 != -1) {
stl_update_connects_remove_1(stl, neighbor2);
}
else if (neighbor2 == -1 && neighbor1 != -1) {
stl_update_connects_remove_1(stl, neighbor1);
}
neighbor3 = stl->neighbors_start[facet].neighbor[edge3];
vnot1 = stl->neighbors_start[facet].which_vertex_not[edge1];
vnot2 = stl->neighbors_start[facet].which_vertex_not[edge2];
vnot3 = stl->neighbors_start[facet].which_vertex_not[edge3];
if(neighbor1 != -1){
stl->neighbors_start[neighbor1].neighbor[(vnot1 + 1) % 3] = neighbor2;
stl->neighbors_start[neighbor1].which_vertex_not[(vnot1 + 1) % 3] = vnot2;
}
if(neighbor2 != -1){
stl->neighbors_start[neighbor2].neighbor[(vnot2 + 1) % 3] = neighbor1;
stl->neighbors_start[neighbor2].which_vertex_not[(vnot2 + 1) % 3] = vnot1;
}
stl_remove_facet(stl, facet);
if(neighbor3 != -1) {
stl_update_connects_remove_1(stl, neighbor3);
stl->neighbors_start[neighbor3].neighbor[(vnot3 + 1) % 3] = -1;
}
}
|
25155049141523797391201320731237896996
|
connect.c
|
216745481854892780790975730037335372174
|
CWE-125
|
CVE-2018-25033
|
ADMesh through 0.98.4 has a heap-based buffer over-read in stl_update_connects_remove_1 (called from stl_remove_degenerate) in connect.c in libadmesh.a.
|
https://nvd.nist.gov/vuln/detail/CVE-2018-25033
|
204,535
|
admesh
|
e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
https://github.com/admesh/admesh
|
https://github.com/admesh/admesh/commit/e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
Fix heap buffer overflow in stl_update_connects_remove_1
- Add argument value check to the stl_update_connects_remove_1
- Add neighbor value check in stl_remove_degenerate
Fixes https://github.com/admesh/admesh/issues/28
Merges https://github.com/admesh/admesh/pull/55
| 1
|
stl_update_connects_remove_1(stl_file *stl, int facet_num) {
int j;
if (stl->error) return;
/* Update list of connected edges */
j = ((stl->neighbors_start[facet_num].neighbor[0] == -1) +
(stl->neighbors_start[facet_num].neighbor[1] == -1) +
(stl->neighbors_start[facet_num].neighbor[2] == -1));
if(j == 0) { /* Facet has 3 neighbors */
stl->stats.connected_facets_3_edge -= 1;
} else if(j == 1) { /* Facet has 2 neighbors */
stl->stats.connected_facets_2_edge -= 1;
} else if(j == 2) { /* Facet has 1 neighbor */
stl->stats.connected_facets_1_edge -= 1;
}
}
|
254021536794522665519440114453059072369
|
connect.c
|
88334157411234536587499947341326463538
|
CWE-125
|
CVE-2018-25033
|
ADMesh through 0.98.4 has a heap-based buffer over-read in stl_update_connects_remove_1 (called from stl_remove_degenerate) in connect.c in libadmesh.a.
|
https://nvd.nist.gov/vuln/detail/CVE-2018-25033
|
361,298
|
admesh
|
e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
https://github.com/admesh/admesh
|
https://github.com/admesh/admesh/commit/e84d8353f1347e1f26f0a95770d92ba14e6ede38
|
Fix heap buffer overflow in stl_update_connects_remove_1
- Add argument value check to the stl_update_connects_remove_1
- Add neighbor value check in stl_remove_degenerate
Fixes https://github.com/admesh/admesh/issues/28
Merges https://github.com/admesh/admesh/pull/55
| 0
|
stl_update_connects_remove_1(stl_file *stl, int facet_num) {
int j;
if (
stl->error ||
facet_num < 0
) return;
/* Update list of connected edges */
j = ((stl->neighbors_start[facet_num].neighbor[0] == -1) +
(stl->neighbors_start[facet_num].neighbor[1] == -1) +
(stl->neighbors_start[facet_num].neighbor[2] == -1));
if(j == 0) { /* Facet has 3 neighbors */
stl->stats.connected_facets_3_edge -= 1;
} else if(j == 1) { /* Facet has 2 neighbors */
stl->stats.connected_facets_2_edge -= 1;
} else if(j == 2) { /* Facet has 1 neighbor */
stl->stats.connected_facets_1_edge -= 1;
}
}
|
169061681318997992993751796896877966474
|
connect.c
|
216745481854892780790975730037335372174
|
CWE-125
|
CVE-2018-25033
|
ADMesh through 0.98.4 has a heap-based buffer over-read in stl_update_connects_remove_1 (called from stl_remove_degenerate) in connect.c in libadmesh.a.
|
https://nvd.nist.gov/vuln/detail/CVE-2018-25033
|
204,544
|
linux
|
c08eadca1bdfa099e20a32f8fa4b52b2f672236d
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c08eadca1bdfa099e20a32f8fa4b52b2f672236d
|
media: em28xx: initialize refcount before kref_get
The commit 47677e51e2a4("[media] em28xx: Only deallocate struct
em28xx after finishing all extensions") adds kref_get to many init
functions (e.g., em28xx_audio_init). However, kref_init is called too
late in em28xx_usb_probe, since em28xx_init_dev before will invoke
those init functions and call kref_get function. Then refcount bug
occurs in my local syzkaller instance.
Fix it by moving kref_init before em28xx_init_dev. This issue occurs
not only in dev but also dev->dev_next.
Fixes: 47677e51e2a4 ("[media] em28xx: Only deallocate struct em28xx after finishing all extensions")
Reported-by: syzkaller <[email protected]>
Signed-off-by: Dongliang Mu <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
| 1
|
static int em28xx_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev;
struct em28xx *dev = NULL;
int retval;
bool has_vendor_audio = false, has_video = false, has_dvb = false;
int i, nr, try_bulk;
const int ifnum = intf->altsetting[0].desc.bInterfaceNumber;
char *speed;
udev = usb_get_dev(interface_to_usbdev(intf));
/* Check to see next free device and mark as used */
do {
nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
if (nr >= EM28XX_MAXBOARDS) {
/* No free device slots */
dev_err(&intf->dev,
"Driver supports up to %i em28xx boards.\n",
EM28XX_MAXBOARDS);
retval = -ENOMEM;
goto err_no_slot;
}
} while (test_and_set_bit(nr, em28xx_devused));
/* Don't register audio interfaces */
if (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
dev_info(&intf->dev,
"audio device (%04x:%04x): interface %i, class %i\n",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum,
intf->altsetting[0].desc.bInterfaceClass);
retval = -ENODEV;
goto err;
}
/* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
retval = -ENOMEM;
goto err;
}
/* compute alternate max packet sizes */
dev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,
sizeof(dev->alt_max_pkt_size_isoc[0]),
GFP_KERNEL);
if (!dev->alt_max_pkt_size_isoc) {
kfree(dev);
retval = -ENOMEM;
goto err;
}
/* Get endpoints */
for (i = 0; i < intf->num_altsetting; i++) {
int ep;
for (ep = 0;
ep < intf->altsetting[i].desc.bNumEndpoints;
ep++)
em28xx_check_usb_descriptor(dev, udev, intf,
i, ep,
&has_vendor_audio,
&has_video,
&has_dvb);
}
if (!(has_vendor_audio || has_video || has_dvb)) {
retval = -ENODEV;
goto err_free;
}
switch (udev->speed) {
case USB_SPEED_LOW:
speed = "1.5";
break;
case USB_SPEED_UNKNOWN:
case USB_SPEED_FULL:
speed = "12";
break;
case USB_SPEED_HIGH:
speed = "480";
break;
default:
speed = "unknown";
}
dev_info(&intf->dev,
"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
udev->manufacturer ? udev->manufacturer : "",
udev->product ? udev->product : "",
speed,
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum,
intf->altsetting->desc.bInterfaceNumber);
/*
* Make sure we have 480 Mbps of bandwidth, otherwise things like
* video stream wouldn't likely work, since 12 Mbps is generally
* not enough even for most Digital TV streams.
*/
if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
dev_err(&intf->dev, "Device initialization failed.\n");
dev_err(&intf->dev,
"Device must be connected to a high-speed USB 2.0 port.\n");
retval = -ENODEV;
goto err_free;
}
dev->devno = nr;
dev->model = id->driver_info;
dev->alt = -1;
dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
dev->has_video = has_video;
dev->ifnum = ifnum;
dev->ts = PRIMARY_TS;
snprintf(dev->name, 28, "em28xx");
dev->dev_next = NULL;
if (has_vendor_audio) {
dev_info(&intf->dev,
"Audio interface %i found (Vendor Class)\n", ifnum);
dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
}
/* Checks if audio is provided by a USB Audio Class intf */
for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
struct usb_interface *uif = udev->config->interface[i];
if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
if (has_vendor_audio)
dev_err(&intf->dev,
"em28xx: device seems to have vendor AND usb audio class interfaces !\n"
"\t\tThe vendor interface will be ignored. Please contact the developers <[email protected]>\n");
dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
break;
}
}
if (has_video)
dev_info(&intf->dev, "Video interface %i found:%s%s\n",
ifnum,
dev->analog_ep_bulk ? " bulk" : "",
dev->analog_ep_isoc ? " isoc" : "");
if (has_dvb)
dev_info(&intf->dev, "DVB interface %i found:%s%s\n",
ifnum,
dev->dvb_ep_bulk ? " bulk" : "",
dev->dvb_ep_isoc ? " isoc" : "");
dev->num_alt = intf->num_altsetting;
if ((unsigned int)card[nr] < em28xx_bcount)
dev->model = card[nr];
/* save our data pointer in this intf device */
usb_set_intfdata(intf, dev);
/* allocate device struct and check if the device is a webcam */
mutex_init(&dev->lock);
retval = em28xx_init_dev(dev, udev, intf, nr);
if (retval)
goto err_free;
if (usb_xfer_mode < 0) {
if (dev->is_webcam)
try_bulk = 1;
else
try_bulk = 0;
} else {
try_bulk = usb_xfer_mode > 0;
}
/* Disable V4L2 if the device doesn't have a decoder or image sensor */
if (has_video &&
dev->board.decoder == EM28XX_NODECODER &&
dev->em28xx_sensor == EM28XX_NOSENSOR) {
dev_err(&intf->dev,
"Currently, V4L2 is not supported on this model\n");
has_video = false;
dev->has_video = false;
}
if (dev->board.has_dual_ts &&
(dev->tuner_type != TUNER_ABSENT || INPUT(0)->type)) {
/*
* The logic with sets alternate is not ready for dual-tuners
* which analog modes.
*/
dev_err(&intf->dev,
"We currently don't support analog TV or stream capture on dual tuners.\n");
has_video = false;
}
/* Select USB transfer types to use */
if (has_video) {
if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
dev->analog_xfer_bulk = 1;
dev_info(&intf->dev, "analog set to %s mode.\n",
dev->analog_xfer_bulk ? "bulk" : "isoc");
}
if (has_dvb) {
if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
dev->dvb_xfer_bulk = 1;
dev_info(&intf->dev, "dvb set to %s mode.\n",
dev->dvb_xfer_bulk ? "bulk" : "isoc");
}
if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
dev->dev_next->ts = SECONDARY_TS;
dev->dev_next->alt = -1;
dev->dev_next->is_audio_only = has_vendor_audio &&
!(has_video || has_dvb);
dev->dev_next->has_video = false;
dev->dev_next->ifnum = ifnum;
dev->dev_next->model = id->driver_info;
mutex_init(&dev->dev_next->lock);
retval = em28xx_init_dev(dev->dev_next, udev, intf,
dev->dev_next->devno);
if (retval)
goto err_free;
dev->dev_next->board.ir_codes = NULL; /* No IR for 2nd tuner */
dev->dev_next->board.has_ir_i2c = 0; /* No IR for 2nd tuner */
if (usb_xfer_mode < 0) {
if (dev->dev_next->is_webcam)
try_bulk = 1;
else
try_bulk = 0;
} else {
try_bulk = usb_xfer_mode > 0;
}
/* Select USB transfer types to use */
if (has_dvb) {
if (!dev->dvb_ep_isoc_ts2 ||
(try_bulk && dev->dvb_ep_bulk_ts2))
dev->dev_next->dvb_xfer_bulk = 1;
dev_info(&dev->intf->dev, "dvb ts2 set to %s mode.\n",
dev->dev_next->dvb_xfer_bulk ? "bulk" : "isoc");
}
dev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;
dev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;
dev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;
dev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;
/* Configure hardware to support TS2*/
if (dev->dvb_xfer_bulk) {
/* The ep4 and ep5 are configured for BULK */
em28xx_write_reg(dev, 0x0b, 0x96);
mdelay(100);
em28xx_write_reg(dev, 0x0b, 0x80);
mdelay(100);
} else {
/* The ep4 and ep5 are configured for ISO */
em28xx_write_reg(dev, 0x0b, 0x96);
mdelay(100);
em28xx_write_reg(dev, 0x0b, 0x82);
mdelay(100);
}
kref_init(&dev->dev_next->ref);
}
kref_init(&dev->ref);
request_modules(dev);
/*
* Do it at the end, to reduce dynamic configuration changes during
* the device init. Yet, as request_modules() can be async, the
* topology will likely change after the load of the em28xx subdrivers.
*/
#ifdef CONFIG_MEDIA_CONTROLLER
retval = media_device_register(dev->media_dev);
#endif
return 0;
err_free:
kfree(dev->alt_max_pkt_size_isoc);
kfree(dev);
err:
clear_bit(nr, em28xx_devused);
err_no_slot:
usb_put_dev(udev);
return retval;
}
|
76668846820258934149802408473302303407
|
em28xx-cards.c
|
309061862626800090542744203029600987742
|
CWE-416
|
CVE-2022-3239
|
A flaw use after free in the Linux kernel video4linux driver was found in the way user triggers em28xx_usb_probe() for the Empia 28xx based TV cards. A local user could use this flaw to crash the system or potentially escalate their privileges on the system.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3239
|
361,755
|
linux
|
c08eadca1bdfa099e20a32f8fa4b52b2f672236d
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c08eadca1bdfa099e20a32f8fa4b52b2f672236d
|
media: em28xx: initialize refcount before kref_get
The commit 47677e51e2a4("[media] em28xx: Only deallocate struct
em28xx after finishing all extensions") adds kref_get to many init
functions (e.g., em28xx_audio_init). However, kref_init is called too
late in em28xx_usb_probe, since em28xx_init_dev before will invoke
those init functions and call kref_get function. Then refcount bug
occurs in my local syzkaller instance.
Fix it by moving kref_init before em28xx_init_dev. This issue occurs
not only in dev but also dev->dev_next.
Fixes: 47677e51e2a4 ("[media] em28xx: Only deallocate struct em28xx after finishing all extensions")
Reported-by: syzkaller <[email protected]>
Signed-off-by: Dongliang Mu <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
| 0
|
static int em28xx_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev;
struct em28xx *dev = NULL;
int retval;
bool has_vendor_audio = false, has_video = false, has_dvb = false;
int i, nr, try_bulk;
const int ifnum = intf->altsetting[0].desc.bInterfaceNumber;
char *speed;
udev = usb_get_dev(interface_to_usbdev(intf));
/* Check to see next free device and mark as used */
do {
nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
if (nr >= EM28XX_MAXBOARDS) {
/* No free device slots */
dev_err(&intf->dev,
"Driver supports up to %i em28xx boards.\n",
EM28XX_MAXBOARDS);
retval = -ENOMEM;
goto err_no_slot;
}
} while (test_and_set_bit(nr, em28xx_devused));
/* Don't register audio interfaces */
if (intf->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
dev_info(&intf->dev,
"audio device (%04x:%04x): interface %i, class %i\n",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum,
intf->altsetting[0].desc.bInterfaceClass);
retval = -ENODEV;
goto err;
}
/* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) {
retval = -ENOMEM;
goto err;
}
/* compute alternate max packet sizes */
dev->alt_max_pkt_size_isoc = kcalloc(intf->num_altsetting,
sizeof(dev->alt_max_pkt_size_isoc[0]),
GFP_KERNEL);
if (!dev->alt_max_pkt_size_isoc) {
kfree(dev);
retval = -ENOMEM;
goto err;
}
/* Get endpoints */
for (i = 0; i < intf->num_altsetting; i++) {
int ep;
for (ep = 0;
ep < intf->altsetting[i].desc.bNumEndpoints;
ep++)
em28xx_check_usb_descriptor(dev, udev, intf,
i, ep,
&has_vendor_audio,
&has_video,
&has_dvb);
}
if (!(has_vendor_audio || has_video || has_dvb)) {
retval = -ENODEV;
goto err_free;
}
switch (udev->speed) {
case USB_SPEED_LOW:
speed = "1.5";
break;
case USB_SPEED_UNKNOWN:
case USB_SPEED_FULL:
speed = "12";
break;
case USB_SPEED_HIGH:
speed = "480";
break;
default:
speed = "unknown";
}
dev_info(&intf->dev,
"New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
udev->manufacturer ? udev->manufacturer : "",
udev->product ? udev->product : "",
speed,
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum,
intf->altsetting->desc.bInterfaceNumber);
/*
* Make sure we have 480 Mbps of bandwidth, otherwise things like
* video stream wouldn't likely work, since 12 Mbps is generally
* not enough even for most Digital TV streams.
*/
if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
dev_err(&intf->dev, "Device initialization failed.\n");
dev_err(&intf->dev,
"Device must be connected to a high-speed USB 2.0 port.\n");
retval = -ENODEV;
goto err_free;
}
kref_init(&dev->ref);
dev->devno = nr;
dev->model = id->driver_info;
dev->alt = -1;
dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
dev->has_video = has_video;
dev->ifnum = ifnum;
dev->ts = PRIMARY_TS;
snprintf(dev->name, 28, "em28xx");
dev->dev_next = NULL;
if (has_vendor_audio) {
dev_info(&intf->dev,
"Audio interface %i found (Vendor Class)\n", ifnum);
dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
}
/* Checks if audio is provided by a USB Audio Class intf */
for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
struct usb_interface *uif = udev->config->interface[i];
if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
if (has_vendor_audio)
dev_err(&intf->dev,
"em28xx: device seems to have vendor AND usb audio class interfaces !\n"
"\t\tThe vendor interface will be ignored. Please contact the developers <[email protected]>\n");
dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
break;
}
}
if (has_video)
dev_info(&intf->dev, "Video interface %i found:%s%s\n",
ifnum,
dev->analog_ep_bulk ? " bulk" : "",
dev->analog_ep_isoc ? " isoc" : "");
if (has_dvb)
dev_info(&intf->dev, "DVB interface %i found:%s%s\n",
ifnum,
dev->dvb_ep_bulk ? " bulk" : "",
dev->dvb_ep_isoc ? " isoc" : "");
dev->num_alt = intf->num_altsetting;
if ((unsigned int)card[nr] < em28xx_bcount)
dev->model = card[nr];
/* save our data pointer in this intf device */
usb_set_intfdata(intf, dev);
/* allocate device struct and check if the device is a webcam */
mutex_init(&dev->lock);
retval = em28xx_init_dev(dev, udev, intf, nr);
if (retval)
goto err_free;
if (usb_xfer_mode < 0) {
if (dev->is_webcam)
try_bulk = 1;
else
try_bulk = 0;
} else {
try_bulk = usb_xfer_mode > 0;
}
/* Disable V4L2 if the device doesn't have a decoder or image sensor */
if (has_video &&
dev->board.decoder == EM28XX_NODECODER &&
dev->em28xx_sensor == EM28XX_NOSENSOR) {
dev_err(&intf->dev,
"Currently, V4L2 is not supported on this model\n");
has_video = false;
dev->has_video = false;
}
if (dev->board.has_dual_ts &&
(dev->tuner_type != TUNER_ABSENT || INPUT(0)->type)) {
/*
* The logic with sets alternate is not ready for dual-tuners
* which analog modes.
*/
dev_err(&intf->dev,
"We currently don't support analog TV or stream capture on dual tuners.\n");
has_video = false;
}
/* Select USB transfer types to use */
if (has_video) {
if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
dev->analog_xfer_bulk = 1;
dev_info(&intf->dev, "analog set to %s mode.\n",
dev->analog_xfer_bulk ? "bulk" : "isoc");
}
if (has_dvb) {
if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
dev->dvb_xfer_bulk = 1;
dev_info(&intf->dev, "dvb set to %s mode.\n",
dev->dvb_xfer_bulk ? "bulk" : "isoc");
}
if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
kref_init(&dev->dev_next->ref);
dev->dev_next->ts = SECONDARY_TS;
dev->dev_next->alt = -1;
dev->dev_next->is_audio_only = has_vendor_audio &&
!(has_video || has_dvb);
dev->dev_next->has_video = false;
dev->dev_next->ifnum = ifnum;
dev->dev_next->model = id->driver_info;
mutex_init(&dev->dev_next->lock);
retval = em28xx_init_dev(dev->dev_next, udev, intf,
dev->dev_next->devno);
if (retval)
goto err_free;
dev->dev_next->board.ir_codes = NULL; /* No IR for 2nd tuner */
dev->dev_next->board.has_ir_i2c = 0; /* No IR for 2nd tuner */
if (usb_xfer_mode < 0) {
if (dev->dev_next->is_webcam)
try_bulk = 1;
else
try_bulk = 0;
} else {
try_bulk = usb_xfer_mode > 0;
}
/* Select USB transfer types to use */
if (has_dvb) {
if (!dev->dvb_ep_isoc_ts2 ||
(try_bulk && dev->dvb_ep_bulk_ts2))
dev->dev_next->dvb_xfer_bulk = 1;
dev_info(&dev->intf->dev, "dvb ts2 set to %s mode.\n",
dev->dev_next->dvb_xfer_bulk ? "bulk" : "isoc");
}
dev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;
dev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;
dev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;
dev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;
/* Configure hardware to support TS2*/
if (dev->dvb_xfer_bulk) {
/* The ep4 and ep5 are configured for BULK */
em28xx_write_reg(dev, 0x0b, 0x96);
mdelay(100);
em28xx_write_reg(dev, 0x0b, 0x80);
mdelay(100);
} else {
/* The ep4 and ep5 are configured for ISO */
em28xx_write_reg(dev, 0x0b, 0x96);
mdelay(100);
em28xx_write_reg(dev, 0x0b, 0x82);
mdelay(100);
}
}
request_modules(dev);
/*
* Do it at the end, to reduce dynamic configuration changes during
* the device init. Yet, as request_modules() can be async, the
* topology will likely change after the load of the em28xx subdrivers.
*/
#ifdef CONFIG_MEDIA_CONTROLLER
retval = media_device_register(dev->media_dev);
#endif
return 0;
err_free:
kfree(dev->alt_max_pkt_size_isoc);
kfree(dev);
err:
clear_bit(nr, em28xx_devused);
err_no_slot:
usb_put_dev(udev);
return retval;
}
|
34268190257933110062727844673317729884
|
em28xx-cards.c
|
107764567079866010944769027860344599929
|
CWE-416
|
CVE-2022-3239
|
A flaw use after free in the Linux kernel video4linux driver was found in the way user triggers em28xx_usb_probe() for the Empia 28xx based TV cards. A local user could use this flaw to crash the system or potentially escalate their privileges on the system.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-3239
|
204,814
|
linux
|
efe4186e6a1b54bf38b9e05450d43b0da1fd7739
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/efe4186e6a1b54bf38b9e05450d43b0da1fd7739
|
drivers: hamradio: 6pack: fix UAF bug caused by mod_timer()
When a 6pack device is detaching, the sixpack_close() will act to cleanup
necessary resources. Although del_timer_sync() in sixpack_close()
won't return if there is an active timer, one could use mod_timer() in
sp_xmit_on_air() to wake up timer again by calling userspace syscall such
as ax25_sendmsg(), ax25_connect() and ax25_ioctl().
This unexpected waked handler, sp_xmit_on_air(), realizes nothing about
the undergoing cleanup and may still call pty_write() to use driver layer
resources that have already been released.
One of the possible race conditions is shown below:
(USE) | (FREE)
ax25_sendmsg() |
ax25_queue_xmit() |
... |
sp_xmit() |
sp_encaps() | sixpack_close()
sp_xmit_on_air() | del_timer_sync(&sp->tx_t)
mod_timer(&sp->tx_t,...) | ...
| unregister_netdev()
| ...
(wait a while) | tty_release()
| tty_release_struct()
| release_tty()
sp_xmit_on_air() | tty_kref_put(tty_struct) //FREE
pty_write(tty_struct) //USE | ...
The corresponding fail log is shown below:
===============================================================
BUG: KASAN: use-after-free in __run_timers.part.0+0x170/0x470
Write of size 8 at addr ffff88800a652ab8 by task swapper/2/0
...
Call Trace:
...
queue_work_on+0x3f/0x50
pty_write+0xcd/0xe0pty_write+0xcd/0xe0
sp_xmit_on_air+0xb2/0x1f0
call_timer_fn+0x28/0x150
__run_timers.part.0+0x3c2/0x470
run_timer_softirq+0x3b/0x80
__do_softirq+0xf1/0x380
...
This patch reorders the del_timer_sync() after the unregister_netdev()
to avoid UAF bugs. Because the unregister_netdev() is well synchronized,
it flushs out any pending queues, waits the refcount of net_device
decreases to zero and removes net_device from kernel. There is not any
running routines after executing unregister_netdev(). Therefore, we could
not arouse timer from userspace again.
Signed-off-by: Duoming Zhou <[email protected]>
Reviewed-by: Lin Ma <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 1
|
static void sixpack_close(struct tty_struct *tty)
{
struct sixpack *sp;
write_lock_irq(&disc_data_lock);
sp = tty->disc_data;
tty->disc_data = NULL;
write_unlock_irq(&disc_data_lock);
if (!sp)
return;
/*
* We have now ensured that nobody can start using ap from now on, but
* we have to wait for all existing users to finish.
*/
if (!refcount_dec_and_test(&sp->refcnt))
wait_for_completion(&sp->dead);
/* We must stop the queue to avoid potentially scribbling
* on the free buffers. The sp->dead completion is not sufficient
* to protect us from sp->xbuff access.
*/
netif_stop_queue(sp->dev);
del_timer_sync(&sp->tx_t);
del_timer_sync(&sp->resync_t);
unregister_netdev(sp->dev);
/* Free all 6pack frame buffers after unreg. */
kfree(sp->rbuff);
kfree(sp->xbuff);
free_netdev(sp->dev);
}
|
162259032331314568256565537664821735227
|
None
|
CWE-703
|
CVE-2022-1198
|
A use-after-free vulnerabilitity was discovered in drivers/net/hamradio/6pack.c of linux that allows an attacker to crash linux kernel by simulating ax25 device using 6pack driver from user space.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1198
|
|
365,760
|
linux
|
efe4186e6a1b54bf38b9e05450d43b0da1fd7739
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/efe4186e6a1b54bf38b9e05450d43b0da1fd7739
|
drivers: hamradio: 6pack: fix UAF bug caused by mod_timer()
When a 6pack device is detaching, the sixpack_close() will act to cleanup
necessary resources. Although del_timer_sync() in sixpack_close()
won't return if there is an active timer, one could use mod_timer() in
sp_xmit_on_air() to wake up timer again by calling userspace syscall such
as ax25_sendmsg(), ax25_connect() and ax25_ioctl().
This unexpected waked handler, sp_xmit_on_air(), realizes nothing about
the undergoing cleanup and may still call pty_write() to use driver layer
resources that have already been released.
One of the possible race conditions is shown below:
(USE) | (FREE)
ax25_sendmsg() |
ax25_queue_xmit() |
... |
sp_xmit() |
sp_encaps() | sixpack_close()
sp_xmit_on_air() | del_timer_sync(&sp->tx_t)
mod_timer(&sp->tx_t,...) | ...
| unregister_netdev()
| ...
(wait a while) | tty_release()
| tty_release_struct()
| release_tty()
sp_xmit_on_air() | tty_kref_put(tty_struct) //FREE
pty_write(tty_struct) //USE | ...
The corresponding fail log is shown below:
===============================================================
BUG: KASAN: use-after-free in __run_timers.part.0+0x170/0x470
Write of size 8 at addr ffff88800a652ab8 by task swapper/2/0
...
Call Trace:
...
queue_work_on+0x3f/0x50
pty_write+0xcd/0xe0pty_write+0xcd/0xe0
sp_xmit_on_air+0xb2/0x1f0
call_timer_fn+0x28/0x150
__run_timers.part.0+0x3c2/0x470
run_timer_softirq+0x3b/0x80
__do_softirq+0xf1/0x380
...
This patch reorders the del_timer_sync() after the unregister_netdev()
to avoid UAF bugs. Because the unregister_netdev() is well synchronized,
it flushs out any pending queues, waits the refcount of net_device
decreases to zero and removes net_device from kernel. There is not any
running routines after executing unregister_netdev(). Therefore, we could
not arouse timer from userspace again.
Signed-off-by: Duoming Zhou <[email protected]>
Reviewed-by: Lin Ma <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| 0
|
static void sixpack_close(struct tty_struct *tty)
{
struct sixpack *sp;
write_lock_irq(&disc_data_lock);
sp = tty->disc_data;
tty->disc_data = NULL;
write_unlock_irq(&disc_data_lock);
if (!sp)
return;
/*
* We have now ensured that nobody can start using ap from now on, but
* we have to wait for all existing users to finish.
*/
if (!refcount_dec_and_test(&sp->refcnt))
wait_for_completion(&sp->dead);
/* We must stop the queue to avoid potentially scribbling
* on the free buffers. The sp->dead completion is not sufficient
* to protect us from sp->xbuff access.
*/
netif_stop_queue(sp->dev);
unregister_netdev(sp->dev);
del_timer_sync(&sp->tx_t);
del_timer_sync(&sp->resync_t);
/* Free all 6pack frame buffers after unreg. */
kfree(sp->rbuff);
kfree(sp->xbuff);
free_netdev(sp->dev);
}
|
179190846282520948095757872677047237728
|
None
|
CWE-703
|
CVE-2022-1198
|
A use-after-free vulnerabilitity was discovered in drivers/net/hamradio/6pack.c of linux that allows an attacker to crash linux kernel by simulating ax25 device using 6pack driver from user space.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-1198
|
|
204,830
|
linux
|
427215d85e8d1476da1a86b8d67aceb485eb3631
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/427215d85e8d1476da1a86b8d67aceb485eb3631
|
ovl: prevent private clone if bind mount is not allowed
Add the following checks from __do_loopback() to clone_private_mount() as
well:
- verify that the mount is in the current namespace
- verify that there are no locked children
Reported-by: Alois Wohlschlager <[email protected]>
Fixes: c771d683a62e ("vfs: introduce clone_private_mount()")
Cc: <[email protected]> # v3.18
Signed-off-by: Miklos Szeredi <[email protected]>
| 1
|
struct vfsmount *clone_private_mount(const struct path *path)
{
struct mount *old_mnt = real_mount(path->mnt);
struct mount *new_mnt;
if (IS_MNT_UNBINDABLE(old_mnt))
return ERR_PTR(-EINVAL);
new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
if (IS_ERR(new_mnt))
return ERR_CAST(new_mnt);
/* Longterm mount to be removed by kern_unmount*() */
new_mnt->mnt_ns = MNT_NS_INTERNAL;
return &new_mnt->mnt;
}
|
260474936923487005378622883442342647421
|
namespace.c
|
336414911625449496230254298040232985694
|
CWE-200
|
CVE-2021-3732
|
A flaw was found in the Linux kernel's OverlayFS subsystem in the way the user mounts the TmpFS filesystem with OverlayFS. This flaw allows a local user to gain access to hidden files that should not be accessible.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3732
|
366,223
|
linux
|
427215d85e8d1476da1a86b8d67aceb485eb3631
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/427215d85e8d1476da1a86b8d67aceb485eb3631
|
ovl: prevent private clone if bind mount is not allowed
Add the following checks from __do_loopback() to clone_private_mount() as
well:
- verify that the mount is in the current namespace
- verify that there are no locked children
Reported-by: Alois Wohlschlager <[email protected]>
Fixes: c771d683a62e ("vfs: introduce clone_private_mount()")
Cc: <[email protected]> # v3.18
Signed-off-by: Miklos Szeredi <[email protected]>
| 0
|
struct vfsmount *clone_private_mount(const struct path *path)
{
struct mount *old_mnt = real_mount(path->mnt);
struct mount *new_mnt;
down_read(&namespace_sem);
if (IS_MNT_UNBINDABLE(old_mnt))
goto invalid;
if (!check_mnt(old_mnt))
goto invalid;
if (has_locked_children(old_mnt, path->dentry))
goto invalid;
new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE);
up_read(&namespace_sem);
if (IS_ERR(new_mnt))
return ERR_CAST(new_mnt);
/* Longterm mount to be removed by kern_unmount*() */
new_mnt->mnt_ns = MNT_NS_INTERNAL;
return &new_mnt->mnt;
invalid:
up_read(&namespace_sem);
return ERR_PTR(-EINVAL);
}
|
181653158150363696384647639482948263222
|
namespace.c
|
152664695598789977004881235289769073267
|
CWE-200
|
CVE-2021-3732
|
A flaw was found in the Linux kernel's OverlayFS subsystem in the way the user mounts the TmpFS filesystem with OverlayFS. This flaw allows a local user to gain access to hidden files that should not be accessible.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3732
|
205,630
|
linux
|
32452a3eb8b64e01e2be717f518c0be046975b9d
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/32452a3eb8b64e01e2be717f518c0be046975b9d
|
io_uring: fix uninitialized field in rw io_kiocb
io_rw_init_file does not initialize kiocb->private, so when iocb_bio_iopoll
reads kiocb->private it can contain uninitialized data.
Fixes: 3e08773c3841 ("block: switch polling to be bio based")
Signed-off-by: Joseph Ravichandran <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
| 1
|
static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
{
struct kiocb *kiocb = &req->rw.kiocb;
struct io_ring_ctx *ctx = req->ctx;
struct file *file = req->file;
int ret;
if (unlikely(!file || !(file->f_mode & mode)))
return -EBADF;
if (!io_req_ffs_set(req))
req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;
kiocb->ki_flags = iocb_flags(file);
ret = kiocb_set_rw_flags(kiocb, req->rw.flags);
if (unlikely(ret))
return ret;
/*
* If the file is marked O_NONBLOCK, still allow retry for it if it
* supports async. Otherwise it's impossible to use O_NONBLOCK files
* reliably. If not, or it IOCB_NOWAIT is set, don't retry.
*/
if ((kiocb->ki_flags & IOCB_NOWAIT) ||
((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req)))
req->flags |= REQ_F_NOWAIT;
if (ctx->flags & IORING_SETUP_IOPOLL) {
if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)
return -EOPNOTSUPP;
kiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;
kiocb->ki_complete = io_complete_rw_iopoll;
req->iopoll_completed = 0;
} else {
if (kiocb->ki_flags & IOCB_HIPRI)
return -EINVAL;
kiocb->ki_complete = io_complete_rw;
}
return 0;
}
|
85149610434779656690730201934331639704
|
io_uring.c
|
148301731450961138992553369142373286456
|
CWE-94
|
CVE-2022-29968
|
An issue was discovered in the Linux kernel through 5.17.5. io_rw_init_file in fs/io_uring.c lacks initialization of kiocb->private.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-29968
|
369,215
|
linux
|
32452a3eb8b64e01e2be717f518c0be046975b9d
|
https://github.com/torvalds/linux
|
https://github.com/torvalds/linux/commit/32452a3eb8b64e01e2be717f518c0be046975b9d
|
io_uring: fix uninitialized field in rw io_kiocb
io_rw_init_file does not initialize kiocb->private, so when iocb_bio_iopoll
reads kiocb->private it can contain uninitialized data.
Fixes: 3e08773c3841 ("block: switch polling to be bio based")
Signed-off-by: Joseph Ravichandran <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
| 0
|
static int io_rw_init_file(struct io_kiocb *req, fmode_t mode)
{
struct kiocb *kiocb = &req->rw.kiocb;
struct io_ring_ctx *ctx = req->ctx;
struct file *file = req->file;
int ret;
if (unlikely(!file || !(file->f_mode & mode)))
return -EBADF;
if (!io_req_ffs_set(req))
req->flags |= io_file_get_flags(file) << REQ_F_SUPPORT_NOWAIT_BIT;
kiocb->ki_flags = iocb_flags(file);
ret = kiocb_set_rw_flags(kiocb, req->rw.flags);
if (unlikely(ret))
return ret;
/*
* If the file is marked O_NONBLOCK, still allow retry for it if it
* supports async. Otherwise it's impossible to use O_NONBLOCK files
* reliably. If not, or it IOCB_NOWAIT is set, don't retry.
*/
if ((kiocb->ki_flags & IOCB_NOWAIT) ||
((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req)))
req->flags |= REQ_F_NOWAIT;
if (ctx->flags & IORING_SETUP_IOPOLL) {
if (!(kiocb->ki_flags & IOCB_DIRECT) || !file->f_op->iopoll)
return -EOPNOTSUPP;
kiocb->private = NULL;
kiocb->ki_flags |= IOCB_HIPRI | IOCB_ALLOC_CACHE;
kiocb->ki_complete = io_complete_rw_iopoll;
req->iopoll_completed = 0;
} else {
if (kiocb->ki_flags & IOCB_HIPRI)
return -EINVAL;
kiocb->ki_complete = io_complete_rw;
}
return 0;
}
|
263180021211529326245362863666357731272
|
io_uring.c
|
302939069770693315001046423619225683925
|
CWE-94
|
CVE-2022-29968
|
An issue was discovered in the Linux kernel through 5.17.5. io_rw_init_file in fs/io_uring.c lacks initialization of kiocb->private.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-29968
|
205,734
|
rizin
|
38d8006cd609ac75de82b705891d3508d2c218d5
|
https://github.com/rizinorg/rizin
|
https://github.com/rizinorg/rizin/commit/38d8006cd609ac75de82b705891d3508d2c218d5
|
fix #2963 - oob write (1 byte) in pyc/marshal.c
| 1
|
static pyc_object *get_complex_object(RzBinPycObj *pyc, RzBuffer *buffer) {
pyc_object *ret = NULL;
bool error = false;
ut32 size = 0;
ut32 n1 = 0;
ut32 n2 = 0;
ret = RZ_NEW0(pyc_object);
if (!ret) {
return NULL;
}
if ((pyc->magic_int & 0xffff) <= 62061) {
n1 = get_ut8(buffer, &error);
} else {
n1 = get_st32(buffer, &error);
}
if (error) {
free(ret);
return NULL;
}
ut8 *s1 = malloc(n1 + 1);
if (!s1) {
return NULL;
}
/* object contain string representation of the number */
size = rz_buf_read(buffer, s1, n1);
if (size != n1) {
RZ_FREE(s1);
RZ_FREE(ret);
return NULL;
}
s1[n1] = '\0';
if ((pyc->magic_int & 0xffff) <= 62061) {
n2 = get_ut8(buffer, &error);
} else
n2 = get_st32(buffer, &error);
if (error) {
return NULL;
}
ut8 *s2 = malloc(n2 + 1);
if (!s2) {
return NULL;
}
/* object contain string representation of the number */
size = rz_buf_read(buffer, s2, n2);
if (size != n2) {
RZ_FREE(s1);
RZ_FREE(s2);
RZ_FREE(ret);
return NULL;
}
s2[n2] = '\0';
ret->type = TYPE_COMPLEX;
ret->data = rz_str_newf("%s+%sj", s1, s2);
RZ_FREE(s1);
RZ_FREE(s2);
if (!ret->data) {
RZ_FREE(ret);
return NULL;
}
return ret;
}
|
339221193473342829219562491579233996408
|
marshal.c
|
62206307764182880841643297994357401149
|
CWE-787
|
CVE-2022-36040
|
Rizin is a UNIX-like reverse engineering framework and command-line toolset. Versions 0.4.0 and prior are vulnerable to an out-of-bounds write when getting data from PYC(python) files. A user opening a malicious PYC file could be affected by this vulnerability, allowing an attacker to execute code on the user's machine. Commit number 68948017423a12786704e54227b8b2f918c2fd27 contains a patch.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-36040
|
371,185
|
rizin
|
38d8006cd609ac75de82b705891d3508d2c218d5
|
https://github.com/rizinorg/rizin
|
https://github.com/rizinorg/rizin/commit/38d8006cd609ac75de82b705891d3508d2c218d5
|
fix #2963 - oob write (1 byte) in pyc/marshal.c
| 0
|
static pyc_object *get_complex_object(RzBinPycObj *pyc, RzBuffer *buffer) {
pyc_object *ret = NULL;
bool error = false;
ut32 n1 = 0;
ut32 n2 = 0;
ret = RZ_NEW0(pyc_object);
if (!ret) {
return NULL;
}
if ((pyc->magic_int & 0xffff) <= 62061) {
n1 = get_ut8(buffer, &error);
} else {
n1 = get_st32(buffer, &error);
}
if (error || UT32_ADD_OVFCHK(n1, 1)) {
free(ret);
return NULL;
}
ut8 *s1 = malloc(n1 + 1);
if (!s1) {
return NULL;
}
/* object contain string representation of the number */
if (rz_buf_read(buffer, s1, n1) != n1) {
RZ_FREE(s1);
RZ_FREE(ret);
return NULL;
}
s1[n1] = '\0';
if ((pyc->magic_int & 0xffff) <= 62061) {
n2 = get_ut8(buffer, &error);
} else {
n2 = get_st32(buffer, &error);
}
if (error || UT32_ADD_OVFCHK(n2, 1)) {
return NULL;
}
ut8 *s2 = malloc(n2 + 1);
if (!s2) {
return NULL;
}
/* object contain string representation of the number */
if (rz_buf_read(buffer, s2, n2) != n2) {
RZ_FREE(s1);
RZ_FREE(s2);
RZ_FREE(ret);
return NULL;
}
s2[n2] = '\0';
ret->type = TYPE_COMPLEX;
ret->data = rz_str_newf("%s+%sj", s1, s2);
RZ_FREE(s1);
RZ_FREE(s2);
if (!ret->data) {
RZ_FREE(ret);
return NULL;
}
return ret;
}
|
99548148027118090642314481180057035575
|
marshal.c
|
23141269581653768082758645127626248017
|
CWE-787
|
CVE-2022-36040
|
Rizin is a UNIX-like reverse engineering framework and command-line toolset. Versions 0.4.0 and prior are vulnerable to an out-of-bounds write when getting data from PYC(python) files. A user opening a malicious PYC file could be affected by this vulnerability, allowing an attacker to execute code on the user's machine. Commit number 68948017423a12786704e54227b8b2f918c2fd27 contains a patch.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-36040
|
205,736
|
linux
|
775c5033a0d164622d9d10dd0f0a5531639ed3ed
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=775c5033a0d164622d9d10dd0f0a5531639ed3ed
|
fuse: fix live lock in fuse_iget()
Commit 5d069dbe8aaf ("fuse: fix bad inode") replaced make_bad_inode()
in fuse_iget() with a private implementation fuse_make_bad().
The private implementation fails to remove the bad inode from inode
cache, so the retry loop with iget5_locked() finds the same bad inode
and marks it bad forever.
kmsg snip:
[ ] rcu: INFO: rcu_sched self-detected stall on CPU
...
[ ] ? bit_wait_io+0x50/0x50
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ? find_inode.isra.32+0x60/0xb0
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ilookup5_nowait+0x65/0x90
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ilookup5.part.36+0x2e/0x80
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ? fuse_inode_eq+0x20/0x20
[ ] iget5_locked+0x21/0x80
[ ] ? fuse_inode_eq+0x20/0x20
[ ] fuse_iget+0x96/0x1b0
Fixes: 5d069dbe8aaf ("fuse: fix bad inode")
Cc: [email protected] # 5.10+
Signed-off-by: Amir Goldstein <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
| 1
|
static inline void fuse_make_bad(struct inode *inode)
{
set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);
}
|
47372311033330775185323042617136550109
|
fuse_i.h
|
275513758194031113369959181365685841551
|
CWE-834
|
CVE-2021-28950
|
An issue was discovered in fs/fuse/fuse_i.h in the Linux kernel before 5.11.8. A "stall on CPU" can occur because a retry loop continually finds the same bad inode, aka CID-775c5033a0d1.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-28950
|
371,226
|
linux
|
775c5033a0d164622d9d10dd0f0a5531639ed3ed
|
https://github.com/torvalds/linux
|
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=775c5033a0d164622d9d10dd0f0a5531639ed3ed
|
fuse: fix live lock in fuse_iget()
Commit 5d069dbe8aaf ("fuse: fix bad inode") replaced make_bad_inode()
in fuse_iget() with a private implementation fuse_make_bad().
The private implementation fails to remove the bad inode from inode
cache, so the retry loop with iget5_locked() finds the same bad inode
and marks it bad forever.
kmsg snip:
[ ] rcu: INFO: rcu_sched self-detected stall on CPU
...
[ ] ? bit_wait_io+0x50/0x50
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ? find_inode.isra.32+0x60/0xb0
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ilookup5_nowait+0x65/0x90
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ilookup5.part.36+0x2e/0x80
[ ] ? fuse_init_file_inode+0x70/0x70
[ ] ? fuse_inode_eq+0x20/0x20
[ ] iget5_locked+0x21/0x80
[ ] ? fuse_inode_eq+0x20/0x20
[ ] fuse_iget+0x96/0x1b0
Fixes: 5d069dbe8aaf ("fuse: fix bad inode")
Cc: [email protected] # 5.10+
Signed-off-by: Amir Goldstein <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
| 0
|
static inline void fuse_make_bad(struct inode *inode)
{
remove_inode_hash(inode);
set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);
}
|
322879755488186541223674702992331788623
|
fuse_i.h
|
37876063683408329716495167282300176867
|
CWE-834
|
CVE-2021-28950
|
An issue was discovered in fs/fuse/fuse_i.h in the Linux kernel before 5.11.8. A "stall on CPU" can occur because a retry loop continually finds the same bad inode, aka CID-775c5033a0d1.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-28950
|
205,806
|
Singular
|
5f28fbf066626fa9c4a8f0e6408c0bb362fb386c
|
https://github.com/Singular/Singular
|
https://github.com/Singular/Singular/commit/5f28fbf066626fa9c4a8f0e6408c0bb362fb386c
|
use mkstemp for sdb
| 1
|
void sdb_edit(procinfo *pi)
{
char * filename = omStrDup("/tmp/sd000000");
sprintf(filename+7,"%d",getpid());
FILE *fp=fopen(filename,"w");
if (fp==NULL)
{
Print("cannot open %s\n",filename);
omFree(filename);
return;
}
if (pi->language!= LANG_SINGULAR)
{
Print("cannot edit type %d\n",pi->language);
fclose(fp);
fp=NULL;
}
else
{
const char *editor=getenv("EDITOR");
if (editor==NULL)
editor=getenv("VISUAL");
if (editor==NULL)
editor="vi";
editor=omStrDup(editor);
if (pi->data.s.body==NULL)
{
iiGetLibProcBuffer(pi);
if (pi->data.s.body==NULL)
{
PrintS("cannot get the procedure body\n");
fclose(fp);
si_unlink(filename);
omFree(filename);
return;
}
}
fwrite(pi->data.s.body,1,strlen(pi->data.s.body),fp);
fclose(fp);
int pid=fork();
if (pid!=0)
{
si_wait(&pid);
}
else if(pid==0)
{
if (strchr(editor,' ')==NULL)
{
execlp(editor,editor,filename,NULL);
Print("cannot exec %s\n",editor);
}
else
{
char *p=(char *)omAlloc(strlen(editor)+strlen(filename)+2);
sprintf(p,"%s %s",editor,filename);
system(p);
}
exit(0);
}
else
{
PrintS("cannot fork\n");
}
fp=fopen(filename,"r");
if (fp==NULL)
{
Print("cannot read from %s\n",filename);
}
else
{
fseek(fp,0L,SEEK_END);
long len=ftell(fp);
fseek(fp,0L,SEEK_SET);
omFree((ADDRESS)pi->data.s.body);
pi->data.s.body=(char *)omAlloc((int)len+1);
myfread( pi->data.s.body, len, 1, fp);
pi->data.s.body[len]='\0';
fclose(fp);
}
}
si_unlink(filename);
omFree(filename);
}
|
10048081884359234906707051996001966428
|
None
|
CWE-269
|
CVE-2022-40299
|
In Singular before 4.3.1, a predictable /tmp pathname is used (e.g., by sdb.cc), which allows local users to gain the privileges of other users via a procedure in a file under /tmp. NOTE: this CVE Record is about sdb.cc and similar files in the Singular interface that have predictable /tmp pathnames; this CVE Record is not about the lack of a safe temporary-file creation capability in the Singular language.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-40299
|
|
372,352
|
Singular
|
5f28fbf066626fa9c4a8f0e6408c0bb362fb386c
|
https://github.com/Singular/Singular
|
https://github.com/Singular/Singular/commit/5f28fbf066626fa9c4a8f0e6408c0bb362fb386c
|
use mkstemp for sdb
| 0
|
void sdb_edit(procinfo *pi)
{
char * filename = omStrDup("/tmp/sdXXXXXX");
int f=mkstemp(filename);
if (f==-1)
{
Print("cannot open %s\n",filename);
omFree(filename);
return;
}
if (pi->language!= LANG_SINGULAR)
{
Print("cannot edit type %d\n",pi->language);
close(f);
f=NULL;
}
else
{
const char *editor=getenv("EDITOR");
if (editor==NULL)
editor=getenv("VISUAL");
if (editor==NULL)
editor="vi";
editor=omStrDup(editor);
if (pi->data.s.body==NULL)
{
iiGetLibProcBuffer(pi);
if (pi->data.s.body==NULL)
{
PrintS("cannot get the procedure body\n");
close(f);
si_unlink(filename);
omFree(filename);
return;
}
}
write(f,pi->data.s.body,strlen(pi->data.s.body));
close(f);
int pid=fork();
if (pid!=0)
{
si_wait(&pid);
}
else if(pid==0)
{
if (strchr(editor,' ')==NULL)
{
execlp(editor,editor,filename,NULL);
Print("cannot exec %s\n",editor);
}
else
{
char *p=(char *)omAlloc(strlen(editor)+strlen(filename)+2);
sprintf(p,"%s %s",editor,filename);
system(p);
}
exit(0);
}
else
{
PrintS("cannot fork\n");
}
FILE* fp=fopen(filename,"r");
if (fp==NULL)
{
Print("cannot read from %s\n",filename);
}
else
{
fseek(fp,0L,SEEK_END);
long len=ftell(fp);
fseek(fp,0L,SEEK_SET);
omFree((ADDRESS)pi->data.s.body);
pi->data.s.body=(char *)omAlloc((int)len+1);
myfread( pi->data.s.body, len, 1, fp);
pi->data.s.body[len]='\0';
fclose(fp);
}
}
si_unlink(filename);
omFree(filename);
}
|
297505880534279409095461525065078196664
|
None
|
CWE-269
|
CVE-2022-40299
|
In Singular before 4.3.1, a predictable /tmp pathname is used (e.g., by sdb.cc), which allows local users to gain the privileges of other users via a procedure in a file under /tmp. NOTE: this CVE Record is about sdb.cc and similar files in the Singular interface that have predictable /tmp pathnames; this CVE Record is not about the lack of a safe temporary-file creation capability in the Singular language.
|
https://nvd.nist.gov/vuln/detail/CVE-2022-40299
|
|
205,823
|
ovs
|
803ed12e31b0377c37d7aa8c94b3b92f2081e349
|
https://github.com/openvswitch/ovs
|
https://github.com/openvswitch/ovs/commit/803ed12e31b0377c37d7aa8c94b3b92f2081e349
|
ipf: release unhandled packets from the batch
Since 640d4db788ed ("ipf: Fix a use-after-free error, ...") the ipf
framework unconditionally allocates a new dp_packet to track
individual fragments. This prevents a use-after-free. However, an
additional issue was present - even when the packet buffer is cloned,
if the ip fragment handling code keeps it, the original buffer is
leaked during the refill loop. Even in the original processing code,
the hardcoded dnsteal branches would always leak a packet buffer from
the refill loop.
This can be confirmed with valgrind:
==717566== 16,672 (4,480 direct, 12,192 indirect) bytes in 8 blocks are definitely lost in loss record 390 of 390
==717566== at 0x484086F: malloc (vg_replace_malloc.c:380)
==717566== by 0x537BFD: xmalloc__ (util.c:137)
==717566== by 0x537BFD: xmalloc (util.c:172)
==717566== by 0x46DDD4: dp_packet_new (dp-packet.c:153)
==717566== by 0x46DDD4: dp_packet_new_with_headroom (dp-packet.c:163)
==717566== by 0x550AA6: netdev_linux_batch_rxq_recv_sock.constprop.0 (netdev-linux.c:1262)
==717566== by 0x5512AF: netdev_linux_rxq_recv (netdev-linux.c:1511)
==717566== by 0x4AB7E0: netdev_rxq_recv (netdev.c:727)
==717566== by 0x47F00D: dp_netdev_process_rxq_port (dpif-netdev.c:4699)
==717566== by 0x47FD13: dpif_netdev_run (dpif-netdev.c:5957)
==717566== by 0x4331D2: type_run (ofproto-dpif.c:370)
==717566== by 0x41DFD8: ofproto_type_run (ofproto.c:1768)
==717566== by 0x40A7FB: bridge_run__ (bridge.c:3245)
==717566== by 0x411269: bridge_run (bridge.c:3310)
==717566== by 0x406E6C: main (ovs-vswitchd.c:127)
The fix is to delete the original packet when it isn't able to be
reinserted into the packet batch. Subsequent valgrind runs show that
the packets are not leaked from the batch any longer.
Fixes: 640d4db788ed ("ipf: Fix a use-after-free error, and remove the 'do_not_steal' flag.")
Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Reported-by: Wan Junjie <[email protected]>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/226
Signed-off-by: Aaron Conole <[email protected]>
Reviewed-by: David Marchand <[email protected]>
Tested-by: Wan Junjie <[email protected]>
Signed-off-by: Alin-Gabriel Serdean <[email protected]>
| 1
|
ipf_extract_frags_from_batch(struct ipf *ipf, struct dp_packet_batch *pb,
ovs_be16 dl_type, uint16_t zone, long long now,
uint32_t hash_basis)
{
const size_t pb_cnt = dp_packet_batch_size(pb);
int pb_idx; /* Index in a packet batch. */
struct dp_packet *pkt;
DP_PACKET_BATCH_REFILL_FOR_EACH (pb_idx, pb_cnt, pkt, pb) {
if (OVS_UNLIKELY((dl_type == htons(ETH_TYPE_IP) &&
ipf_is_valid_v4_frag(ipf, pkt))
||
(dl_type == htons(ETH_TYPE_IPV6) &&
ipf_is_valid_v6_frag(ipf, pkt)))) {
ovs_mutex_lock(&ipf->ipf_lock);
if (!ipf_handle_frag(ipf, pkt, dl_type, zone, now, hash_basis)) {
dp_packet_batch_refill(pb, pkt, pb_idx);
}
ovs_mutex_unlock(&ipf->ipf_lock);
} else {
dp_packet_batch_refill(pb, pkt, pb_idx);
}
}
}
|
268719993787134993398351954055334505161
|
ipf.c
|
8691777507480014794600271586586377411
|
CWE-401
|
CVE-2021-3905
|
A memory leak was found in Open vSwitch (OVS) during userspace IP fragmentation processing. An attacker could use this flaw to potentially exhaust available memory by keeping sending packet fragments.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3905
|
373,535
|
ovs
|
803ed12e31b0377c37d7aa8c94b3b92f2081e349
|
https://github.com/openvswitch/ovs
|
https://github.com/openvswitch/ovs/commit/803ed12e31b0377c37d7aa8c94b3b92f2081e349
|
ipf: release unhandled packets from the batch
Since 640d4db788ed ("ipf: Fix a use-after-free error, ...") the ipf
framework unconditionally allocates a new dp_packet to track
individual fragments. This prevents a use-after-free. However, an
additional issue was present - even when the packet buffer is cloned,
if the ip fragment handling code keeps it, the original buffer is
leaked during the refill loop. Even in the original processing code,
the hardcoded dnsteal branches would always leak a packet buffer from
the refill loop.
This can be confirmed with valgrind:
==717566== 16,672 (4,480 direct, 12,192 indirect) bytes in 8 blocks are definitely lost in loss record 390 of 390
==717566== at 0x484086F: malloc (vg_replace_malloc.c:380)
==717566== by 0x537BFD: xmalloc__ (util.c:137)
==717566== by 0x537BFD: xmalloc (util.c:172)
==717566== by 0x46DDD4: dp_packet_new (dp-packet.c:153)
==717566== by 0x46DDD4: dp_packet_new_with_headroom (dp-packet.c:163)
==717566== by 0x550AA6: netdev_linux_batch_rxq_recv_sock.constprop.0 (netdev-linux.c:1262)
==717566== by 0x5512AF: netdev_linux_rxq_recv (netdev-linux.c:1511)
==717566== by 0x4AB7E0: netdev_rxq_recv (netdev.c:727)
==717566== by 0x47F00D: dp_netdev_process_rxq_port (dpif-netdev.c:4699)
==717566== by 0x47FD13: dpif_netdev_run (dpif-netdev.c:5957)
==717566== by 0x4331D2: type_run (ofproto-dpif.c:370)
==717566== by 0x41DFD8: ofproto_type_run (ofproto.c:1768)
==717566== by 0x40A7FB: bridge_run__ (bridge.c:3245)
==717566== by 0x411269: bridge_run (bridge.c:3310)
==717566== by 0x406E6C: main (ovs-vswitchd.c:127)
The fix is to delete the original packet when it isn't able to be
reinserted into the packet batch. Subsequent valgrind runs show that
the packets are not leaked from the batch any longer.
Fixes: 640d4db788ed ("ipf: Fix a use-after-free error, and remove the 'do_not_steal' flag.")
Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Reported-by: Wan Junjie <[email protected]>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/226
Signed-off-by: Aaron Conole <[email protected]>
Reviewed-by: David Marchand <[email protected]>
Tested-by: Wan Junjie <[email protected]>
Signed-off-by: Alin-Gabriel Serdean <[email protected]>
| 0
|
ipf_extract_frags_from_batch(struct ipf *ipf, struct dp_packet_batch *pb,
ovs_be16 dl_type, uint16_t zone, long long now,
uint32_t hash_basis)
{
const size_t pb_cnt = dp_packet_batch_size(pb);
int pb_idx; /* Index in a packet batch. */
struct dp_packet *pkt;
DP_PACKET_BATCH_REFILL_FOR_EACH (pb_idx, pb_cnt, pkt, pb) {
if (OVS_UNLIKELY((dl_type == htons(ETH_TYPE_IP) &&
ipf_is_valid_v4_frag(ipf, pkt))
||
(dl_type == htons(ETH_TYPE_IPV6) &&
ipf_is_valid_v6_frag(ipf, pkt)))) {
ovs_mutex_lock(&ipf->ipf_lock);
if (!ipf_handle_frag(ipf, pkt, dl_type, zone, now, hash_basis)) {
dp_packet_batch_refill(pb, pkt, pb_idx);
} else {
dp_packet_delete(pkt);
}
ovs_mutex_unlock(&ipf->ipf_lock);
} else {
dp_packet_batch_refill(pb, pkt, pb_idx);
}
}
}
|
120994420466199339145680136614353279460
|
ipf.c
|
251424754321869382912198899459965953031
|
CWE-401
|
CVE-2021-3905
|
A memory leak was found in Open vSwitch (OVS) during userspace IP fragmentation processing. An attacker could use this flaw to potentially exhaust available memory by keeping sending packet fragments.
|
https://nvd.nist.gov/vuln/detail/CVE-2021-3905
|
206,025
|
evolution-data-server
|
5d8b92c622f6927b253762ff9310479dd3ac627d
|
https://git.gnome.org/browse/evolution-data-server
|
https://git.gnome.org/browse/evolution-data-server/commit/?id=5d8b92c622f6927b253762ff9310479dd3ac627d
|
CamelGpgContext: Enclose email addresses in brackets.
The recipient list for encrypting can be specified by either key ID or
email address. Enclose email addresses in brackets to ensure an exact
match, as per the gpg man page:
HOW TO SPECIFY A USER ID
...
By exact match on an email address.
This is indicated by enclosing the email address in the
usual way with left and right angles.
<[email protected]>
Without the brackets gpg uses a substring match, which risks selecting
the wrong recipient.
| 1
|
gpg_ctx_add_recipient (struct _GpgCtx *gpg,
const gchar *keyid)
{
if (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)
return;
if (!gpg->recipients)
gpg->recipients = g_ptr_array_new ();
g_ptr_array_add (gpg->recipients, g_strdup (keyid));
}
|
52853002144529989504123015024381136054
|
None
|
CWE-200
|
CVE-2013-4166
|
The gpg_ctx_add_recipient function in camel/camel-gpg-context.c in GNOME Evolution 3.8.4 and earlier and Evolution Data Server 3.9.5 and earlier does not properly select the GPG key to use for email encryption, which might cause the email to be encrypted with the wrong key and allow remote attackers to obtain sensitive information.
|
https://nvd.nist.gov/vuln/detail/CVE-2013-4166
|
|
376,350
|
evolution-data-server
|
5d8b92c622f6927b253762ff9310479dd3ac627d
|
https://git.gnome.org/browse/evolution-data-server
|
https://git.gnome.org/browse/evolution-data-server/commit/?id=5d8b92c622f6927b253762ff9310479dd3ac627d
|
CamelGpgContext: Enclose email addresses in brackets.
The recipient list for encrypting can be specified by either key ID or
email address. Enclose email addresses in brackets to ensure an exact
match, as per the gpg man page:
HOW TO SPECIFY A USER ID
...
By exact match on an email address.
This is indicated by enclosing the email address in the
usual way with left and right angles.
<[email protected]>
Without the brackets gpg uses a substring match, which risks selecting
the wrong recipient.
| 0
|
gpg_ctx_add_recipient (struct _GpgCtx *gpg,
const gchar *keyid)
{
gchar *safe_keyid;
if (gpg->mode != GPG_CTX_MODE_ENCRYPT && gpg->mode != GPG_CTX_MODE_EXPORT)
return;
if (!gpg->recipients)
gpg->recipients = g_ptr_array_new ();
g_return_if_fail (keyid != NULL);
/* If the recipient looks like an email address,
* enclose it in brackets to ensure an exact match. */
if (strchr (keyid, '@') != NULL) {
safe_keyid = g_strdup_printf ("<%s>", keyid);
} else {
safe_keyid = g_strdup (keyid);
}
g_ptr_array_add (gpg->recipients, safe_keyid);
}
|
104115978280820788064995186839232167760
|
None
|
CWE-200
|
CVE-2013-4166
|
The gpg_ctx_add_recipient function in camel/camel-gpg-context.c in GNOME Evolution 3.8.4 and earlier and Evolution Data Server 3.9.5 and earlier does not properly select the GPG key to use for email encryption, which might cause the email to be encrypted with the wrong key and allow remote attackers to obtain sensitive information.
|
https://nvd.nist.gov/vuln/detail/CVE-2013-4166
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.