func
string
target
string
cwe
list
project
string
commit_id
string
hash
string
size
int64
message
string
vul
int64
static ssize_t aac_show_max_id(struct device *device, struct device_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE, "%d\n", class_to_shost(device)->max_id); }
Safe
[ "CWE-284", "CWE-264" ]
linux
f856567b930dfcdbc3323261bf77240ccdde01f5
2.995871638492904e+38
6
aacraid: missing capable() check in compat ioctl In commit d496f94d22d1 ('[SCSI] aacraid: fix security weakness') we added a check on CAP_SYS_RAWIO to the ioctl. The compat ioctls need the check as well. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
static int engine_setup_common(struct intel_engine_cs *engine) { int err; init_llist_head(&engine->barrier_tasks); err = init_status_page(engine); if (err) return err; engine->breadcrumbs = intel_breadcrumbs_create(engine); if (!engine->breadcrumbs) { err = -ENOMEM; goto err_status; } intel_engine_init_active(engine, ENGINE_PHYSICAL); intel_engine_init_execlists(engine); intel_engine_init_cmd_parser(engine); intel_engine_init__pm(engine); intel_engine_init_retire(engine); /* Use the whole device by default */ engine->sseu = intel_sseu_from_device_info(&engine->gt->info.sseu); intel_engine_init_workarounds(engine); intel_engine_init_whitelist(engine); intel_engine_init_ctx_wa(engine); return 0; err_status: cleanup_status_page(engine); return err; }
Safe
[ "CWE-20", "CWE-190" ]
linux
c784e5249e773689e38d2bc1749f08b986621a26
3.6963473674244554e+35
36
drm/i915/guc: Update to use firmware v49.0.1 The latest GuC firmware includes a number of interface changes that require driver updates to match. * Starting from Gen11, the ID to be provided to GuC needs to contain the engine class in bits [0..2] and the instance in bits [3..6]. NOTE: this patch breaks pointer dereferences in some existing GuC functions that use the guc_id to dereference arrays but these functions are not used for now as we have GuC submission disabled and we will update these functions in follow up patch which requires new IDs. * The new GuC requires the additional data structure (ADS) and associated 'private_data' pointer to be setup. This is basically a scratch area of memory that the GuC owns. The size is read from the CSS header. * There is now a physical to logical engine mapping table in the ADS which needs to be configured in order for the firmware to load. For now, the table is initialised with a 1 to 1 mapping. * GUC_CTL_CTXINFO has been removed from the initialization params. * reg_state_buffer is maintained internally by the GuC as part of the private data. * The ADS layout has changed significantly. This patch updates the shared structure and also adds better documentation of the layout. * While i915 does not use GuC doorbells, the firmware now requires that some initialisation is done. * The number of engine classes and instances supported in the ADS has been increased. Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Signed-off-by: Michel Thierry <michel.thierry@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Michal Winiarski <michal.winiarski@intel.com> Cc: Tomasz Lis <tomasz.lis@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20201028145826.2949180-2-John.C.Harrison@Intel.com
0
static notrace __kprobes void default_do_nmi(struct pt_regs *regs) { unsigned char reason = 0; /* * CPU-specific NMI must be processed before non-CPU-specific * NMI, otherwise we may lose it, because the CPU-specific * NMI can not be detected/processed on other CPUs. */ if (notify_die(DIE_NMI, "nmi", regs, 0, 2, SIGINT) == NOTIFY_STOP) return; /* Non-CPU-specific NMI: NMI sources can be processed on any CPU */ raw_spin_lock(&nmi_reason_lock); reason = get_nmi_reason(); if (reason & NMI_REASON_MASK) { if (reason & NMI_REASON_SERR) pci_serr_error(reason, regs); else if (reason & NMI_REASON_IOCHK) io_check_error(reason, regs); #ifdef CONFIG_X86_32 /* * Reassert NMI in case it became active * meanwhile as it's edge-triggered: */ reassert_nmi(); #endif raw_spin_unlock(&nmi_reason_lock); return; } raw_spin_unlock(&nmi_reason_lock); unknown_nmi_error(reason, regs); }
Safe
[ "CWE-400" ]
linux-stable-rt
e5d4e1c3ccee18c68f23d62ba77bda26e893d4f0
2.6033768198948866e+37
35
x86: Do not disable preemption in int3 on 32bit Preemption must be disabled before enabling interrupts in do_trap on x86_64 because the stack in use for int3 and debug is a per CPU stack set by th IST. But 32bit does not have an IST and the stack still belongs to the current task and there is no problem in scheduling out the task. Keep preemption enabled on X86_32 when enabling interrupts for do_trap(). The name of the function is changed from preempt_conditional_sti/cli() to conditional_sti/cli_ist(), to annotate that this function is used when the stack is on the IST. Cc: stable-rt@vger.kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
0
static int set_supply(struct regulator_dev *rdev, struct regulator_dev *supply_rdev) { int err; rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev)); rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY"); if (rdev->supply == NULL) { err = -ENOMEM; return err; } supply_rdev->open_count++; return 0; }
Safe
[ "CWE-416" ]
linux
60a2362f769cf549dc466134efe71c8bf9fbaaba
3.3679238637795253e+38
16
regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeing After freeing pin from regulator_ena_gpio_free, loop can access the pin. So this patch fixes not to access pin after freeing. Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
0
Status RoleGraph::removeRoleFromRole(const RoleName& recipient, const RoleName& role) { if (!roleExists(recipient)) { return Status(ErrorCodes::RoleNotFound, str::stream() << "Role: " << recipient.getFullName() << " does not exist"); } if (isBuiltinRole(recipient)) { return Status(ErrorCodes::InvalidRoleModification, str::stream() << "Cannot remove roles from built-in role: " << role.getFullName()); } if (!roleExists(role)) { return Status(ErrorCodes::RoleNotFound, str::stream() << "Role: " << role.getFullName() << " does not exist"); } std::vector<RoleName>::iterator itToRm = std::find(_roleToMembers[role].begin(), _roleToMembers[role].end(), recipient); if (itToRm != _roleToMembers[role].end()) { _roleToMembers[role].erase(itToRm); } else { return Status(ErrorCodes::RolesNotRelated, str::stream() << recipient.getFullName() << " is not a member" " of " << role.getFullName()); } itToRm = std::find( _roleToSubordinates[recipient].begin(), _roleToSubordinates[recipient].end(), role); fassert(16827, itToRm != _roleToSubordinates[recipient].end()); _roleToSubordinates[recipient].erase(itToRm); return Status::OK(); }
Safe
[ "CWE-863" ]
mongo
521e56b407ac72bc69a97a24d1253f51a5b6e81b
1.251960684985016e+38
33
SERVER-45472 Ensure RoleGraph can serialize authentication restrictions to BSON
0
void Http2Handler::start_settings_timer() { ev_timer_start(sessions_->get_loop(), &settings_timerev_); }
Safe
[]
nghttp2
95efb3e19d174354ca50c65d5d7227d92bcd60e1
1.906180439630562e+38
3
Don't read too greedily
0
on_screen_monitors_changed (GdkScreen *screen, GSManager *manager) { GSList *l; int n_monitors; int n_windows; int i; n_monitors = gdk_screen_get_n_monitors (screen); n_windows = g_slist_length (manager->priv->windows); gs_debug ("Monitors changed for screen %d: num=%d", gdk_screen_get_number (screen), n_monitors); if (n_monitors > n_windows) { /* Tear down unlock dialog in case we want to move it * to a new monitor */ l = manager->priv->windows; while (l != NULL) { gs_window_cancel_unlock_request (GS_WINDOW (l->data)); l = l->next; } /* add more windows */ for (i = n_windows; i < n_monitors; i++) { gs_manager_create_window_for_monitor (manager, screen, i); } /* And put unlock dialog up where ever it's supposed to be */ gs_manager_request_unlock (manager); } else { gdk_x11_grab_server (); /* remove the extra windows */ l = manager->priv->windows; while (l != NULL) { GdkScreen *this_screen; int this_monitor; GSList *next = l->next; this_screen = gs_window_get_screen (GS_WINDOW (l->data)); this_monitor = gs_window_get_monitor (GS_WINDOW (l->data)); if (this_screen == screen && this_monitor >= n_monitors) { manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data)); g_hash_table_remove (manager->priv->jobs, l->data); gs_window_destroy (GS_WINDOW (l->data)); manager->priv->windows = g_slist_delete_link (manager->priv->windows, l); } l = next; } /* make sure there is a lock dialog on a connected monitor, * and that the keyboard is still properly grabbed after all * the windows above got destroyed*/ if (n_windows > n_monitors) { gs_manager_request_unlock (manager); } gdk_flush (); gdk_x11_ungrab_server (); } }
Safe
[]
gnome-screensaver
d4dcbd65a2df3c093c4e3a74bbbc75383eb9eadb
2.870405124033192e+38
67
Update which monitor the unlock dialog is on when layout changes Before we were moving the grabs but not the unlock dialog. Everything needs to be in lock step, otherwise: 1) The unlock dialog won't get focus and will fail to work generally 2) Assumptions in the code about the two being in lock-step will prove incorrect leading to the grabs getting dropped entirely. Part of fix for https://bugzilla.gnome.org/show_bug.cgi?id=609789 CVE-2010-0422
0
virtual void parse( const UnicodeString& , Formattable& , UErrorCode& ) const {}
Safe
[ "CWE-190" ]
icu
53d8c8f3d181d87a6aa925b449b51c4a2c922a51
1.3120420724126165e+38
3
ICU-20246 Fixing another integer overflow in number parsing.
0
int main(int argc, char **argv) { l_int32 w, h; PIX *pixs, *pixg, *pixim, *pixgm, *pixmi, *pix1, *pix2; PIX *pixmr, *pixmg, *pixmb, *pixmri, *pixmgi, *pixmbi; PIXA *pixa; L_REGPARAMS *rp; if (regTestSetup(argc, argv, &rp)) return 1; lept_mkdir("lept/adapt"); // REMOVE? pixs = pixRead("wet-day.jpg"); pixa = pixaCreate(0); pixg = pixConvertRGBToGray(pixs, 0.33, 0.34, 0.33); pixaAddPix(pixa, pixs, L_INSERT); pixaAddPix(pixa, pixg, L_INSERT); pixGetDimensions(pixs, &w, &h, NULL); /* Process in grayscale */ startTimer(); pixim = pixCreate(w, h, 1); pixRasterop(pixim, XS, YS, WS, HS, PIX_SET, NULL, 0, 0); pixGetBackgroundGrayMap(pixg, pixim, SIZE_X, SIZE_Y, BINTHRESH, MINCOUNT, &pixgm); fprintf(stderr, "Time for gray adaptmap gen: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pixgm, IFF_PNG); /* 0 */ pixaAddPix(pixa, pixgm, L_INSERT); startTimer(); pixmi = pixGetInvBackgroundMap(pixgm, BGVAL, SMOOTH_X, SMOOTH_Y); fprintf(stderr, "Time for gray inv map generation: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pixmi, IFF_PNG); /* 1 */ pixaAddPix(pixa, pixmi, L_INSERT); startTimer(); pix1 = pixApplyInvBackgroundGrayMap(pixg, pixmi, SIZE_X, SIZE_Y); fprintf(stderr, "Time to apply gray inv map: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 2 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixGammaTRCMasked(NULL, pix1, pixim, 1.0, 0, 190); pixInvert(pixim, pixim); pixGammaTRCMasked(pix2, pix2, pixim, 1.0, 60, 190); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 3 */ pixaAddPix(pixa, pix2, L_INSERT); pixDestroy(&pixim); /* Process in color */ startTimer(); pixim = pixCreate(w, h, 1); pixRasterop(pixim, XS, YS, WS, HS, PIX_SET, NULL, 0, 0); pixGetBackgroundRGBMap(pixs, pixim, NULL, SIZE_X, SIZE_Y, BINTHRESH, MINCOUNT, &pixmr, &pixmg, &pixmb); fprintf(stderr, "Time for color adaptmap gen: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pixmr, IFF_PNG); /* 4 */ regTestWritePixAndCheck(rp, pixmg, IFF_PNG); /* 5 */ regTestWritePixAndCheck(rp, pixmb, IFF_PNG); /* 6 */ pixaAddPix(pixa, pixmr, L_INSERT); pixaAddPix(pixa, pixmg, L_INSERT); pixaAddPix(pixa, pixmb, L_INSERT); startTimer(); pixmri = pixGetInvBackgroundMap(pixmr, BGVAL, SMOOTH_X, SMOOTH_Y); pixmgi = pixGetInvBackgroundMap(pixmg, BGVAL, SMOOTH_X, SMOOTH_Y); pixmbi = pixGetInvBackgroundMap(pixmb, BGVAL, SMOOTH_X, SMOOTH_Y); fprintf(stderr, "Time for color inv map generation: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pixmri, IFF_PNG); /* 7 */ regTestWritePixAndCheck(rp, pixmgi, IFF_PNG); /* 8 */ regTestWritePixAndCheck(rp, pixmbi, IFF_PNG); /* 9 */ pixaAddPix(pixa, pixmri, L_INSERT); pixaAddPix(pixa, pixmgi, L_INSERT); pixaAddPix(pixa, pixmbi, L_INSERT); startTimer(); pix1 = pixApplyInvBackgroundRGBMap(pixs, pixmri, pixmgi, pixmbi, SIZE_X, SIZE_Y); fprintf(stderr, "Time to apply color inv maps: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 10 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixGammaTRCMasked(NULL, pix1, pixim, 1.0, 0, 190); pixInvert(pixim, pixim); pixGammaTRCMasked(pix2, pix2, pixim, 1.0, 60, 190); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 11 */ pixaAddPix(pixa, pix2, L_INSERT); pixDestroy(&pixim); /* Process at higher level in color */ startTimer(); pixim = pixCreate(w, h, 1); pixRasterop(pixim, XS, YS, WS, HS, PIX_SET, NULL, 0, 0); pix1 = pixBackgroundNorm(pixs, pixim, NULL, 5, 10, BINTHRESH, 20, BGVAL, SMOOTH_X, SMOOTH_Y); fprintf(stderr, "Time for bg normalization: %7.3f\n", stopTimer()); regTestWritePixAndCheck(rp, pix1, IFF_JFIF_JPEG); /* 12 */ pixaAddPix(pixa, pix1, L_INSERT); pix2 = pixGammaTRCMasked(NULL, pix1, pixim, 1.0, 0, 190); pixInvert(pixim, pixim); pixGammaTRCMasked(pix2, pix2, pixim, 1.0, 60, 190); regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); /* 13 */ pixaAddPix(pixa, pix2, L_INSERT); pixDestroy(&pixim); /* Display results */ pix1 = pixaDisplayTiledAndScaled(pixa, 32, 400, 4, 0, 20, 2); pixWrite("/tmp/lept/adapt/results.jpg", pix1, IFF_JFIF_JPEG); pixDisplayWithTitle(pix1, 100, 0, NULL, rp->display); pixDestroy(&pix1); pixaDestroy(&pixa); return regTestCleanup(rp); }
Vulnerable
[ "CWE-125" ]
leptonica
3c18c43b6a3f753f0dfff99610d46ad46b8bfac4
1.483004950287671e+38
117
Fixing oss-fuzz issue 22512: Heap-buffer-overflow in rasteropGeneralLow() * Simplified the hole-filling function `
1
flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, int force, int width) { TextLineList *buf = h_env->buf; FILE *f = h_env->f; Str line = obuf->line, pass = NULL; char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL, *hidden_under = NULL, *hidden_italic = NULL, *hidden_strike = NULL, *hidden_ins = NULL, *hidden_input = NULL, *hidden = NULL; #ifdef DEBUG if (w3m_debug) { FILE *df = fopen("zzzproc1", "a"); fprintf(df, "flushline(%s,%d,%d,%d)\n", obuf->line->ptr, indent, force, width); if (buf) { TextLineListItem *p; for (p = buf->first; p; p = p->next) { fprintf(df, "buf=\"%s\"\n", p->ptr->line->ptr); } } fclose(df); } #endif if (!(obuf->flag & (RB_SPECIAL & ~RB_NOBR)) && Strlastchar(line) == ' ') { Strshrink(line, 1); obuf->pos--; } append_tags(obuf); if (obuf->anchor.url) hidden = hidden_anchor = has_hidden_link(obuf, HTML_A); if (obuf->img_alt) { if ((hidden_img = has_hidden_link(obuf, HTML_IMG_ALT)) != NULL) { if (!hidden || hidden_img < hidden) hidden = hidden_img; } } if (obuf->input_alt.in) { if ((hidden_input = has_hidden_link(obuf, HTML_INPUT_ALT)) != NULL) { if (!hidden || hidden_input < hidden) hidden = hidden_input; } } if (obuf->in_bold) { if ((hidden_bold = has_hidden_link(obuf, HTML_B)) != NULL) { if (!hidden || hidden_bold < hidden) hidden = hidden_bold; } } if (obuf->in_italic) { if ((hidden_italic = has_hidden_link(obuf, HTML_I)) != NULL) { if (!hidden || hidden_italic < hidden) hidden = hidden_italic; } } if (obuf->in_under) { if ((hidden_under = has_hidden_link(obuf, HTML_U)) != NULL) { if (!hidden || hidden_under < hidden) hidden = hidden_under; } } if (obuf->in_strike) { if ((hidden_strike = has_hidden_link(obuf, HTML_S)) != NULL) { if (!hidden || hidden_strike < hidden) hidden = hidden_strike; } } if (obuf->in_ins) { if ((hidden_ins = has_hidden_link(obuf, HTML_INS)) != NULL) { if (!hidden || hidden_ins < hidden) hidden = hidden_ins; } } if (hidden) { pass = Strnew_charp(hidden); Strshrink(line, line->ptr + line->length - hidden); } if (!(obuf->flag & (RB_SPECIAL & ~RB_NOBR)) && obuf->pos > width) { char *tp = &line->ptr[obuf->bp.len - obuf->bp.tlen]; char *ep = &line->ptr[line->length]; if (obuf->bp.pos == obuf->pos && tp <= ep && tp > line->ptr && tp[-1] == ' ') { bcopy(tp, tp - 1, ep - tp + 1); line->length--; obuf->pos--; } } if (obuf->anchor.url && !hidden_anchor) Strcat_charp(line, "</a>"); if (obuf->img_alt && !hidden_img) Strcat_charp(line, "</img_alt>"); if (obuf->input_alt.in && !hidden_input) Strcat_charp(line, "</input_alt>"); if (obuf->in_bold && !hidden_bold) Strcat_charp(line, "</b>"); if (obuf->in_italic && !hidden_italic) Strcat_charp(line, "</i>"); if (obuf->in_under && !hidden_under) Strcat_charp(line, "</u>"); if (obuf->in_strike && !hidden_strike) Strcat_charp(line, "</s>"); if (obuf->in_ins && !hidden_ins) Strcat_charp(line, "</ins>"); if (obuf->top_margin > 0) { int i; struct html_feed_environ h; struct readbuffer o; struct environment e[1]; init_henv(&h, &o, e, 1, NULL, width, indent); o.line = Strnew_size(width + 20); o.pos = obuf->pos; o.flag = obuf->flag; o.top_margin = -1; o.bottom_margin = -1; Strcat_charp(o.line, "<pre_int>"); for (i = 0; i < o.pos; i++) Strcat_char(o.line, ' '); Strcat_charp(o.line, "</pre_int>"); for (i = 0; i < obuf->top_margin; i++) flushline(h_env, &o, indent, force, width); } if (force == 1 || obuf->flag & RB_NFLUSHED) { TextLine *lbuf = newTextLine(line, obuf->pos); if (RB_GET_ALIGN(obuf) == RB_CENTER) { align(lbuf, width, ALIGN_CENTER); } else if (RB_GET_ALIGN(obuf) == RB_RIGHT) { align(lbuf, width, ALIGN_RIGHT); } else if (RB_GET_ALIGN(obuf) == RB_LEFT && obuf->flag & RB_INTABLE) { align(lbuf, width, ALIGN_LEFT); } #ifdef FORMAT_NICE else if (obuf->flag & RB_FILL) { char *p; int rest, rrest; int nspace, d, i; rest = width - get_Str_strwidth(line); if (rest > 1) { nspace = 0; for (p = line->ptr + indent; *p; p++) { if (*p == ' ') nspace++; } if (nspace > 0) { int indent_here = 0; d = rest / nspace; p = line->ptr; while (IS_SPACE(*p)) { p++; indent_here++; } rrest = rest - d * nspace; line = Strnew_size(width + 1); for (i = 0; i < indent_here; i++) Strcat_char(line, ' '); for (; *p; p++) { Strcat_char(line, *p); if (*p == ' ') { for (i = 0; i < d; i++) Strcat_char(line, ' '); if (rrest > 0) { Strcat_char(line, ' '); rrest--; } } } lbuf = newTextLine(line, width); } } } #endif /* FORMAT_NICE */ #ifdef TABLE_DEBUG if (w3m_debug) { FILE *f = fopen("zzzproc1", "a"); fprintf(f, "pos=%d,%d, maxlimit=%d\n", visible_length(lbuf->line->ptr), lbuf->pos, h_env->maxlimit); fclose(f); } #endif if (lbuf->pos > h_env->maxlimit) h_env->maxlimit = lbuf->pos; if (buf) pushTextLine(buf, lbuf); else if (f) { Strfputs(Str_conv_to_halfdump(lbuf->line), f); fputc('\n', f); } if (obuf->flag & RB_SPECIAL || obuf->flag & RB_NFLUSHED) h_env->blank_lines = 0; else h_env->blank_lines++; } else { char *p = line->ptr, *q; Str tmp = Strnew(), tmp2 = Strnew(); #define APPEND(str) \ if (buf) \ appendTextLine(buf,(str),0); \ else if (f) \ Strfputs((str),f) while (*p) { q = p; if (sloppy_parse_line(&p)) { Strcat_charp_n(tmp, q, p - q); if (force == 2) { APPEND(tmp); } else Strcat(tmp2, tmp); Strclear(tmp); } } if (force == 2) { if (pass) { APPEND(pass); } pass = NULL; } else { if (pass) Strcat(tmp2, pass); pass = tmp2; } } if (obuf->bottom_margin > 0) { int i; struct html_feed_environ h; struct readbuffer o; struct environment e[1]; init_henv(&h, &o, e, 1, NULL, width, indent); o.line = Strnew_size(width + 20); o.pos = obuf->pos; o.flag = obuf->flag; o.top_margin = -1; o.bottom_margin = -1; Strcat_charp(o.line, "<pre_int>"); for (i = 0; i < o.pos; i++) Strcat_char(o.line, ' '); Strcat_charp(o.line, "</pre_int>"); for (i = 0; i < obuf->bottom_margin; i++) flushline(h_env, &o, indent, force, width); } if (obuf->top_margin < 0 || obuf->bottom_margin < 0) return; obuf->line = Strnew_size(256); obuf->pos = 0; obuf->top_margin = 0; obuf->bottom_margin = 0; set_space_to_prevchar(obuf->prevchar); obuf->bp.init_flag = 1; obuf->flag &= ~RB_NFLUSHED; set_breakpoint(obuf, 0); obuf->prev_ctype = PC_ASCII; link_stack = NULL; fillline(obuf, indent); if (pass) passthrough(obuf, pass->ptr, 0); if (!hidden_anchor && obuf->anchor.url) { Str tmp; if (obuf->anchor.hseq > 0) obuf->anchor.hseq = -obuf->anchor.hseq; tmp = Sprintf("<A HSEQ=\"%d\" HREF=\"", obuf->anchor.hseq); Strcat_charp(tmp, html_quote(obuf->anchor.url)); if (obuf->anchor.target) { Strcat_charp(tmp, "\" TARGET=\""); Strcat_charp(tmp, html_quote(obuf->anchor.target)); } if (obuf->anchor.referer) { Strcat_charp(tmp, "\" REFERER=\""); Strcat_charp(tmp, html_quote(obuf->anchor.referer)); } if (obuf->anchor.title) { Strcat_charp(tmp, "\" TITLE=\""); Strcat_charp(tmp, html_quote(obuf->anchor.title)); } if (obuf->anchor.accesskey) { char *c = html_quote_char(obuf->anchor.accesskey); Strcat_charp(tmp, "\" ACCESSKEY=\""); if (c) Strcat_charp(tmp, c); else Strcat_char(tmp, obuf->anchor.accesskey); } Strcat_charp(tmp, "\">"); push_tag(obuf, tmp->ptr, HTML_A); } if (!hidden_img && obuf->img_alt) { Str tmp = Strnew_charp("<IMG_ALT SRC=\""); Strcat_charp(tmp, html_quote(obuf->img_alt->ptr)); Strcat_charp(tmp, "\">"); push_tag(obuf, tmp->ptr, HTML_IMG_ALT); } if (!hidden_input && obuf->input_alt.in) { Str tmp; if (obuf->input_alt.hseq > 0) obuf->input_alt.hseq = - obuf->input_alt.hseq; tmp = Sprintf("<INPUT_ALT hseq=\"%d\" fid=\"%d\" name=\"%s\" type=\"%s\" value=\"%s\">", obuf->input_alt.hseq, obuf->input_alt.fid, obuf->input_alt.name ? obuf->input_alt.name->ptr : "", obuf->input_alt.type ? obuf->input_alt.type->ptr : "", obuf->input_alt.value ? obuf->input_alt.value->ptr : ""); push_tag(obuf, tmp->ptr, HTML_INPUT_ALT); } if (!hidden_bold && obuf->in_bold) push_tag(obuf, "<B>", HTML_B); if (!hidden_italic && obuf->in_italic) push_tag(obuf, "<I>", HTML_I); if (!hidden_under && obuf->in_under) push_tag(obuf, "<U>", HTML_U); if (!hidden_strike && obuf->in_strike) push_tag(obuf, "<S>", HTML_S); if (!hidden_ins && obuf->in_ins) push_tag(obuf, "<INS>", HTML_INS); }
Safe
[ "CWE-20", "CWE-476" ]
w3m
33509cc81ec5f2ba44eb6fd98bd5c1b5873e46bd
3.2767632525029524e+38
332
Fix uninitialised values for <i> and <dd> Bug-Debian: https://github.com/tats/w3m/issues/16
0
static inline void free_signal_struct(struct signal_struct *sig) { taskstats_tgid_free(sig); kmem_cache_free(signal_cachep, sig); }
Safe
[ "CWE-20" ]
linux
f106eee10038c2ee5b6056aaf3f6d5229be6dcdd
2.123642177888835e+38
5
pids: fix fork_idle() to setup ->pids correctly copy_process(pid => &init_struct_pid) doesn't do attach_pid/etc. It shouldn't, but this means that the idle threads run with the wrong pids copied from the caller's task_struct. In x86 case the caller is either kernel_init() thread or keventd. In particular, this means that after the series of cpu_up/cpu_down an idle thread (which never exits) can run with .pid pointing to nowhere. Change fork_idle() to initialize idle->pids[] correctly. We only set .pid = &init_struct_pid but do not add .node to list, INIT_TASK() does the same for the boot-cpu idle thread (swapper). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Mathias Krause <Mathias.Krause@secunet.com> Acked-by: Roland McGrath <roland@redhat.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned char *limit) { int extdatalen=0; unsigned char *ret = p; /* don't add extensions for SSLv3 unless doing secure renegotiation */ if (s->client_version == SSL3_VERSION && !s->s3->send_connection_binding) return p; ret+=2; if (ret>=limit) return NULL; /* this really never occurs, but ... */ if (s->tlsext_hostname != NULL) { /* Add TLS extension servername to the Client Hello message */ unsigned long size_str; long lenmax; /* check for enough space. 4 for the servername type and entension length 2 for servernamelist length 1 for the hostname type 2 for hostname length + hostname length */ if ((lenmax = limit - ret - 9) < 0 || (size_str = strlen(s->tlsext_hostname)) > (unsigned long)lenmax) return NULL; /* extension type and length */ s2n(TLSEXT_TYPE_server_name,ret); s2n(size_str+5,ret); /* length of servername list */ s2n(size_str+3,ret); /* hostname type, length and hostname */ *(ret++) = (unsigned char) TLSEXT_NAMETYPE_host_name; s2n(size_str,ret); memcpy(ret, s->tlsext_hostname, size_str); ret+=size_str; } /* Add RI if renegotiating */ if (s->renegotiate) { int el; if(!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0)) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } if((limit - p - 4 - el) < 0) return NULL; s2n(TLSEXT_TYPE_renegotiate,ret); s2n(el,ret); if(!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el)) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } ret += el; } #ifndef OPENSSL_NO_SRP #define MIN(x,y) (((x)<(y))?(x):(y)) /* we add SRP username the first time only if we have one! */ if (s->srp_ctx.login != NULL) {/* Add TLS extension SRP username to the Client Hello message */ int login_len = MIN(strlen(s->srp_ctx.login) + 1, 255); long lenmax; if ((lenmax = limit - ret - 5) < 0) return NULL; if (login_len > lenmax) return NULL; if (login_len > 255) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_srp,ret); s2n(login_len+1,ret); (*ret++) = (unsigned char) MIN(strlen(s->srp_ctx.login), 254); memcpy(ret, s->srp_ctx.login, MIN(strlen(s->srp_ctx.login), 254)); ret+=login_len; } #endif #ifndef OPENSSL_NO_EC if (s->tlsext_ecpointformatlist != NULL && s->version != DTLS1_VERSION) { /* Add TLS extension ECPointFormats to the ClientHello message */ long lenmax; if ((lenmax = limit - ret - 5) < 0) return NULL; if (s->tlsext_ecpointformatlist_length > (unsigned long)lenmax) return NULL; if (s->tlsext_ecpointformatlist_length > 255) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_ec_point_formats,ret); s2n(s->tlsext_ecpointformatlist_length + 1,ret); *(ret++) = (unsigned char) s->tlsext_ecpointformatlist_length; memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length); ret+=s->tlsext_ecpointformatlist_length; } if (s->tlsext_ellipticcurvelist != NULL && s->version != DTLS1_VERSION) { /* Add TLS extension EllipticCurves to the ClientHello message */ long lenmax; if ((lenmax = limit - ret - 6) < 0) return NULL; if (s->tlsext_ellipticcurvelist_length > (unsigned long)lenmax) return NULL; if (s->tlsext_ellipticcurvelist_length > 65532) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } s2n(TLSEXT_TYPE_elliptic_curves,ret); s2n(s->tlsext_ellipticcurvelist_length + 2, ret); /* NB: draft-ietf-tls-ecc-12.txt uses a one-byte prefix for * elliptic_curve_list, but the examples use two bytes. * http://www1.ietf.org/mail-archive/web/tls/current/msg00538.html * resolves this to two bytes. */ s2n(s->tlsext_ellipticcurvelist_length, ret); memcpy(ret, s->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist_length); ret+=s->tlsext_ellipticcurvelist_length; } #endif /* OPENSSL_NO_EC */ if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)) { int ticklen; if (!s->new_session && s->session && s->session->tlsext_tick) ticklen = s->session->tlsext_ticklen; else if (s->session && s->tlsext_session_ticket && s->tlsext_session_ticket->data) { ticklen = s->tlsext_session_ticket->length; s->session->tlsext_tick = OPENSSL_malloc(ticklen); if (!s->session->tlsext_tick) return NULL; memcpy(s->session->tlsext_tick, s->tlsext_session_ticket->data, ticklen); s->session->tlsext_ticklen = ticklen; } else ticklen = 0; if (ticklen == 0 && s->tlsext_session_ticket && s->tlsext_session_ticket->data == NULL) goto skip_ext; /* Check for enough room 2 for extension type, 2 for len * rest for ticket */ if ((long)(limit - ret - 4 - ticklen) < 0) return NULL; s2n(TLSEXT_TYPE_session_ticket,ret); s2n(ticklen,ret); if (ticklen) { memcpy(ret, s->session->tlsext_tick, ticklen); ret += ticklen; } } skip_ext: #ifdef TLSEXT_TYPE_opaque_prf_input if (s->s3->client_opaque_prf_input != NULL && s->version != DTLS1_VERSION) { size_t col = s->s3->client_opaque_prf_input_len; if ((long)(limit - ret - 6 - col < 0)) return NULL; if (col > 0xFFFD) /* can't happen */ return NULL; s2n(TLSEXT_TYPE_opaque_prf_input, ret); s2n(col + 2, ret); s2n(col, ret); memcpy(ret, s->s3->client_opaque_prf_input, col); ret += col; } #endif if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp && s->version != DTLS1_VERSION) { int i; long extlen, idlen, itmp; OCSP_RESPID *id; idlen = 0; for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); itmp = i2d_OCSP_RESPID(id, NULL); if (itmp <= 0) return NULL; idlen += itmp + 2; } if (s->tlsext_ocsp_exts) { extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); if (extlen < 0) return NULL; } else extlen = 0; if ((long)(limit - ret - 7 - extlen - idlen) < 0) return NULL; s2n(TLSEXT_TYPE_status_request, ret); if (extlen + idlen > 0xFFF0) return NULL; s2n(extlen + idlen + 5, ret); *(ret++) = TLSEXT_STATUSTYPE_ocsp; s2n(idlen, ret); for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { /* save position of id len */ unsigned char *q = ret; id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); /* skip over id len */ ret += 2; itmp = i2d_OCSP_RESPID(id, &ret); /* write id len */ s2n(itmp, q); } s2n(extlen, ret); if (extlen > 0) i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret); } #ifndef OPENSSL_NO_NEXTPROTONEG if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len) { /* The client advertises an emtpy extension to indicate its * support for Next Protocol Negotiation */ if (limit - ret - 4 < 0) return NULL; s2n(TLSEXT_TYPE_next_proto_neg,ret); s2n(0,ret); } #endif if ((extdatalen = ret-p-2)== 0) return p; s2n(extdatalen,p); return ret; }
Safe
[]
openssl
edc032b5e3f3ebb1006a9c89e0ae00504f47966f
1.3139302412778194e+38
266
Add SRP support.
0
static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def, const struct netlbl_lsm_secattr *secattr, unsigned char *net_cat, u32 net_cat_len) { int host_spot = -1; u32 net_spot = CIPSO_V4_INV_CAT; u32 net_spot_max = 0; u32 net_clen_bits = net_cat_len * 8; u32 host_cat_size = 0; u32 *host_cat_array = NULL; if (doi_def->type == CIPSO_V4_MAP_TRANS) { host_cat_size = doi_def->map.std->cat.local_size; host_cat_array = doi_def->map.std->cat.local; } for (;;) { host_spot = netlbl_catmap_walk(secattr->attr.mls.cat, host_spot + 1); if (host_spot < 0) break; switch (doi_def->type) { case CIPSO_V4_MAP_PASS: net_spot = host_spot; break; case CIPSO_V4_MAP_TRANS: if (host_spot >= host_cat_size) return -EPERM; net_spot = host_cat_array[host_spot]; if (net_spot >= CIPSO_V4_INV_CAT) return -EPERM; break; } if (net_spot >= net_clen_bits) return -ENOSPC; netlbl_bitmap_setbit(net_cat, net_spot, 1); if (net_spot > net_spot_max) net_spot_max = net_spot; } if (++net_spot_max % 8) return net_spot_max / 8 + 1; return net_spot_max / 8; }
Safe
[ "CWE-835" ]
linux
40413955ee265a5e42f710940ec78f5450d49149
1.0567257196069405e+38
47
Cipso: cipso_v4_optptr enter infinite loop in for(),if((optlen > 0) && (optptr[1] == 0)), enter infinite loop. Test: receive a packet which the ip length > 20 and the first byte of ip option is 0, produce this issue Signed-off-by: yujuan.qi <yujuan.qi@mediatek.com> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
shutdown_mib(void) { unload_all_mibs(); if (tree_top) { if (tree_top->label) SNMP_FREE(tree_top->label); SNMP_FREE(tree_top); } tree_head = NULL; Mib = NULL; if (Prefix != NULL && Prefix != &Standard_Prefix[0]) SNMP_FREE(Prefix); if (Prefix) Prefix = NULL; SNMP_FREE(confmibs); SNMP_FREE(confmibdir); }
Safe
[ "CWE-59", "CWE-61" ]
net-snmp
4fd9a450444a434a993bc72f7c3486ccce41f602
3.3394290132356444e+38
17
CHANGES: snmpd: Stop reading and writing the mib_indexes/* files Caching directory contents is something the operating system should do and is not something Net-SNMP should do. Instead of storing a copy of the directory contents in ${tmp_dir}/mib_indexes/${n}, always scan a MIB directory.
0
__acquires(RCU) { rcu_read_lock(); return *pos ? igmp6_mcf_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; }
Safe
[ "CWE-703" ]
linux
2d3916f3189172d5c69d33065c3c21119fe539fc
1.1749444670131299e+38
5
ipv6: fix skb drops in igmp6_event_query() and igmp6_event_report() While investigating on why a synchronize_net() has been added recently in ipv6_mc_down(), I found that igmp6_event_query() and igmp6_event_report() might drop skbs in some cases. Discussion about removing synchronize_net() from ipv6_mc_down() will happen in a different thread. Fixes: f185de28d9ae ("mld: add new workqueues for process mld events") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Taehee Yoo <ap420073@gmail.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20220303173728.937869-1-eric.dumazet@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
0
void cil_destroy_catorder(struct cil_catorder *catorder) { if (catorder == NULL) { return; } if (catorder->cat_list_str != NULL) { cil_list_destroy(&catorder->cat_list_str, 1); } free(catorder); }
Safe
[ "CWE-125" ]
selinux
340f0eb7f3673e8aacaf0a96cbfcd4d12a405521
6.682224967895836e+37
12
libsepol/cil: Check for statements not allowed in optional blocks While there are some checks for invalid statements in an optional block when resolving the AST, there are no checks when building the AST. OSS-Fuzz found the following policy which caused a null dereference in cil_tree_get_next_path(). (blockinherit b3) (sid SID) (sidorder(SID)) (optional o (ibpkeycon :(1 0)s) (block b3 (filecon""block()) (filecon""block()))) The problem is that the blockinherit copies block b3 before the optional block is disabled. When the optional is disabled, block b3 is deleted along with everything else in the optional. Later, when filecon statements with the same path are found an error message is produced and in trying to find out where the block was copied from, the reference to the deleted block is used. The error handling code assumes (rightly) that if something was copied from a block then that block should still exist. It is clear that in-statements, blocks, and macros cannot be in an optional, because that allows nodes to be copied from the optional block to somewhere outside even though the optional could be disabled later. When optionals are disabled the AST is reset and the resolution is restarted at the point of resolving macro calls, so anything resolved before macro calls will never be re-resolved. This includes tunableifs, in-statements, blockinherits, blockabstracts, and macro definitions. Tunable declarations also cannot be in an optional block because they are needed to resolve tunableifs. It should be fine to allow blockinherit statements in an optional, because that is copying nodes from outside the optional to the optional and if the optional is later disabled, everything will be deleted anyway. Check and quit with an error if a tunable declaration, in-statement, block, blockabstract, or macro definition is found within an optional when either building or resolving the AST. Signed-off-by: James Carter <jwcart2@gmail.com>
0
ZEND_VM_COLD_CONST_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY) { USE_OPLINE zval *value; zend_free_op free_op1; SAVE_OPLINE(); value = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); do { if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) { if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); if (EXPECTED(Z_TYPE_P(value) == IS_OBJECT)) { break; } } if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { ZVAL_UNDEFINED_OP1(); if (UNEXPECTED(EG(exception) != NULL)) { HANDLE_EXCEPTION(); } } zend_throw_error(NULL, "Can only throw objects"); FREE_OP1(); HANDLE_EXCEPTION(); } } while (0); zend_exception_save(); if (OP1_TYPE != IS_TMP_VAR) { Z_TRY_ADDREF_P(value); } zend_throw_exception_object(value); zend_exception_restore(); FREE_OP1_IF_VAR(); HANDLE_EXCEPTION(); }
Safe
[ "CWE-787" ]
php-src
f1ce8d5f5839cb2069ea37ff424fb96b8cd6932d
9.947369414976466e+37
39
Fix #73122: Integer Overflow when concatenating strings We must avoid integer overflows in memory allocations, so we introduce an additional check in the VM, and bail out in the rare case of an overflow. Since the recent fix for bug #74960 still doesn't catch all possible overflows, we fix that right away.
0
cmsPipeline* _cmsReadFloatDevicelinkTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat) { cmsContext ContextID = cmsGetProfileContextID(hProfile); cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat)); cmsColorSpaceSignature PCS = cmsGetPCS(hProfile); cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile); if (Lut == NULL) return NULL; if (spc == cmsSigLabData) { cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)); } else if (spc == cmsSigXYZData) { cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)); } if (PCS == cmsSigLabData) { cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)); } else if (PCS == cmsSigXYZData) { cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)); } return Lut; }
Vulnerable
[]
Little-CMS
41d222df1bc6188131a8f46c32eab0a4d4cdf1b6
1.950252824896966e+38
31
Memory squeezing fix: lcms2 cmsPipeline construction When creating a new pipeline, lcms would often try to allocate a stage and pass it to cmsPipelineInsertStage without checking whether the allocation succeeded. cmsPipelineInsertStage would then assert (or crash) if it had not. The fix here is to change cmsPipelineInsertStage to check and return an error value. All calling code is then checked to test this return value and cope.
1
switch (yych) { case 'a': goto yy25; default: goto yy24; }
Vulnerable
[ "CWE-787" ]
re2c
039c18949190c5de5397eba504d2c75dad2ea9ca
1.9435426909660684e+38
4
Emit an error when repetition lower bound exceeds upper bound. Historically this was allowed and re2c swapped the bounds. However, it most likely indicates an error in user code and there is only a single occurrence in the tests (and the test in an artificial one), so although the change is backwards incompatible there is low chance of breaking real-world code. This fixes second test case in the bug #394 "Stack overflow due to recursion in src/dfa/dead_rules.cc" (the actual fix is to limit DFA size but the test also has counted repetition with swapped bounds).
1
void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) { unsigned long host_cr4_mce = cr4_read_shadow() & X86_CR4_MCE; unsigned long old_cr4 = vcpu->arch.cr4; if (npt_enabled && ((old_cr4 ^ cr4) & X86_CR4_PGE)) svm_flush_tlb(vcpu); vcpu->arch.cr4 = cr4; if (!npt_enabled) cr4 |= X86_CR4_PAE; cr4 |= host_cr4_mce; to_svm(vcpu)->vmcb->save.cr4 = cr4; vmcb_mark_dirty(to_svm(vcpu)->vmcb, VMCB_CR); if ((cr4 ^ old_cr4) & (X86_CR4_OSXSAVE | X86_CR4_PKE)) kvm_update_cpuid_runtime(vcpu); }
Safe
[ "CWE-862" ]
kvm
0f923e07124df069ba68d8bb12324398f4b6b709
2.3165832915495576e+38
18
KVM: nSVM: avoid picking up unsupported bits from L2 in int_ctl (CVE-2021-3653) * Invert the mask of bits that we pick from L2 in nested_vmcb02_prepare_control * Invert and explicitly use VIRQ related bits bitmask in svm_clear_vintr This fixes a security issue that allowed a malicious L1 to run L2 with AVIC enabled, which allowed the L2 to exploit the uninitialized and enabled AVIC to read/write the host physical memory at some offsets. Fixes: 3d6368ef580a ("KVM: SVM: Add VMRUN handler") Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0
ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); }
Safe
[]
php-src
2bcf69d073190e4f032d883f3416dea1b027a39e
1.8938507943361524e+38
9
Fixed bug #68676 (Explicit Double Free)
0
BOOL security_fips_decrypt(BYTE* data, int length, rdpRdp* rdp) { crypto_des3_decrypt(rdp->fips_decrypt, length, data, data); return TRUE; }
Safe
[ "CWE-476" ]
FreeRDP
7d58aac24fe20ffaad7bd9b40c9ddf457c1b06e7
2.1140847591158587e+38
5
security: add a NULL pointer check to fix a server crash.
0
tor_tls_context_init_one(tor_tls_context_t **ppcontext, crypto_pk_env_t *identity, unsigned int key_lifetime) { tor_tls_context_t *new_ctx = tor_tls_context_new(identity, key_lifetime); tor_tls_context_t *old_ctx = *ppcontext; if (new_ctx != NULL) { *ppcontext = new_ctx; /* Free the old context if one existed. */ if (old_ctx != NULL) { /* This is safe even if there are open connections: we reference- * count tor_tls_context_t objects. */ tor_tls_context_decref(old_ctx); } } return ((new_ctx != NULL) ? 0 : -1); }
Vulnerable
[ "CWE-264" ]
tor
638fdedcf16cf7d6f7c586d36f7ef335c1c9714f
2.6565578931535756e+38
21
Don't send a certificate chain on outgoing TLS connections from non-relays
1
static ssize_t ucma_write(struct file *filp, const char __user *buf, size_t len, loff_t *pos) { struct ucma_file *file = filp->private_data; struct rdma_ucm_cmd_hdr hdr; ssize_t ret; if (!ib_safe_file_access(filp)) { pr_err_once("ucma_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n", task_tgid_vnr(current), current->comm); return -EACCES; } if (len < sizeof(hdr)) return -EINVAL; if (copy_from_user(&hdr, buf, sizeof(hdr))) return -EFAULT; if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table)) return -EINVAL; if (hdr.in + sizeof(hdr) > len) return -EINVAL; if (!ucma_cmd_table[hdr.cmd]) return -ENOSYS; ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out); if (!ret) ret = len; return ret; }
Safe
[ "CWE-416", "CWE-703" ]
linux
cb2595c1393b4a5211534e6f0a0fbad369e21ad8
1.8451961761398033e+38
34
infiniband: fix a possible use-after-free bug ucma_process_join() will free the new allocated "mc" struct, if there is any error after that, especially the copy_to_user(). But in parallel, ucma_leave_multicast() could find this "mc" through idr_find() before ucma_process_join() frees it, since it is already published. So "mc" could be used in ucma_leave_multicast() after it is been allocated and freed in ucma_process_join(), since we don't refcnt it. Fix this by separating "publish" from ID allocation, so that we can get an ID first and publish it later after copy_to_user(). Fixes: c8f6a362bf3e ("RDMA/cma: Add multicast communication support") Reported-by: Noam Rathaus <noamr@beyondsecurity.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
0
static ssize_t disk_ext_range_show(struct device *dev, struct device_attribute *attr, char *buf) { struct gendisk *disk = dev_to_disk(dev); return sprintf(buf, "%d\n", disk_max_parts(disk)); }
Safe
[ "CWE-416" ]
linux-stable
77da160530dd1dc94f6ae15a981f24e5f0021e84
3.024716886430531e+38
7
block: fix use-after-free in seq file I got a KASAN report of use-after-free: ================================================================== BUG: KASAN: use-after-free in klist_iter_exit+0x61/0x70 at addr ffff8800b6581508 Read of size 8 by task trinity-c1/315 ============================================================================= BUG kmalloc-32 (Not tainted): kasan: bad access detected ----------------------------------------------------------------------------- Disabling lock debugging due to kernel taint INFO: Allocated in disk_seqf_start+0x66/0x110 age=144 cpu=1 pid=315 ___slab_alloc+0x4f1/0x520 __slab_alloc.isra.58+0x56/0x80 kmem_cache_alloc_trace+0x260/0x2a0 disk_seqf_start+0x66/0x110 traverse+0x176/0x860 seq_read+0x7e3/0x11a0 proc_reg_read+0xbc/0x180 do_loop_readv_writev+0x134/0x210 do_readv_writev+0x565/0x660 vfs_readv+0x67/0xa0 do_preadv+0x126/0x170 SyS_preadv+0xc/0x10 do_syscall_64+0x1a1/0x460 return_from_SYSCALL_64+0x0/0x6a INFO: Freed in disk_seqf_stop+0x42/0x50 age=160 cpu=1 pid=315 __slab_free+0x17a/0x2c0 kfree+0x20a/0x220 disk_seqf_stop+0x42/0x50 traverse+0x3b5/0x860 seq_read+0x7e3/0x11a0 proc_reg_read+0xbc/0x180 do_loop_readv_writev+0x134/0x210 do_readv_writev+0x565/0x660 vfs_readv+0x67/0xa0 do_preadv+0x126/0x170 SyS_preadv+0xc/0x10 do_syscall_64+0x1a1/0x460 return_from_SYSCALL_64+0x0/0x6a CPU: 1 PID: 315 Comm: trinity-c1 Tainted: G B 4.7.0+ #62 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014 ffffea0002d96000 ffff880119b9f918 ffffffff81d6ce81 ffff88011a804480 ffff8800b6581500 ffff880119b9f948 ffffffff8146c7bd ffff88011a804480 ffffea0002d96000 ffff8800b6581500 fffffffffffffff4 ffff880119b9f970 Call Trace: [<ffffffff81d6ce81>] dump_stack+0x65/0x84 [<ffffffff8146c7bd>] print_trailer+0x10d/0x1a0 [<ffffffff814704ff>] object_err+0x2f/0x40 [<ffffffff814754d1>] kasan_report_error+0x221/0x520 [<ffffffff8147590e>] __asan_report_load8_noabort+0x3e/0x40 [<ffffffff83888161>] klist_iter_exit+0x61/0x70 [<ffffffff82404389>] class_dev_iter_exit+0x9/0x10 [<ffffffff81d2e8ea>] disk_seqf_stop+0x3a/0x50 [<ffffffff8151f812>] seq_read+0x4b2/0x11a0 [<ffffffff815f8fdc>] proc_reg_read+0xbc/0x180 [<ffffffff814b24e4>] do_loop_readv_writev+0x134/0x210 [<ffffffff814b4c45>] do_readv_writev+0x565/0x660 [<ffffffff814b8a17>] vfs_readv+0x67/0xa0 [<ffffffff814b8de6>] do_preadv+0x126/0x170 [<ffffffff814b92ec>] SyS_preadv+0xc/0x10 This problem can occur in the following situation: open() - pread() - .seq_start() - iter = kmalloc() // succeeds - seqf->private = iter - .seq_stop() - kfree(seqf->private) - pread() - .seq_start() - iter = kmalloc() // fails - .seq_stop() - class_dev_iter_exit(seqf->private) // boom! old pointer As the comment in disk_seqf_stop() says, stop is called even if start failed, so we need to reinitialise the private pointer to NULL when seq iteration stops. An alternative would be to set the private pointer to NULL when the kmalloc() in disk_seqf_start() fails. Cc: stable@vger.kernel.org Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@fb.com>
0
relpTcpSetGnuTLSPriString(relpTcp_t *pThis, char *pristr) { ENTER_RELPFUNC; RELPOBJ_assert(pThis, Tcp); free(pThis->pristring); if(pristr == NULL) { pThis->pristring = NULL; } else { if((pThis->pristring = strdup(pristr)) == NULL) ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); } finalize_it: LEAVE_RELPFUNC; }
Safe
[ "CWE-787" ]
librelp
2cfe657672636aa5d7d2a14cfcb0a6ab9d1f00cf
2.2464303411441248e+38
15
unify error message generation
0
void fp_init(fp_int *a) { #if defined(ALT_ECC_SIZE) || defined(HAVE_WOLF_BIGINT) a->size = FP_SIZE; #endif #ifdef HAVE_WOLF_BIGINT wc_bigint_init(&a->raw); #endif fp_zero(a); }
Safe
[ "CWE-326", "CWE-203" ]
wolfssl
1de07da61f0c8e9926dcbd68119f73230dae283f
9.842060614167902e+37
10
Constant time EC map to affine for private operations For fast math, use a constant time modular inverse when mapping to affine when operation involves a private key - key gen, calc shared secret, sign.
0
Value ExpressionSwitch::evaluate(const Document& root, Variables* variables) const { for (auto&& branch : _branches) { Value caseExpression(branch.first->evaluate(root, variables)); if (caseExpression.coerceToBool()) { return branch.second->evaluate(root, variables); } } uassert(40066, "$switch could not find a matching branch for an input, and no default was specified.", _default); return _default->evaluate(root, variables); }
Safe
[]
mongo
1772b9a0393b55e6a280a35e8f0a1f75c014f301
7.362996713745313e+37
15
SERVER-49404 Enforce additional checks in $arrayToObject
0
static void youngcollection (lua_State *L, global_State *g) { GCObject **psurvival; /* to point to first non-dead survival object */ lua_assert(g->gcstate == GCSpropagate); markold(g, g->allgc, g->reallyold); markold(g, g->finobj, g->finobjrold); atomic(L); /* sweep nursery and get a pointer to its last live element */ psurvival = sweepgen(L, g, &g->allgc, g->survival); /* sweep 'survival' and 'old' */ sweepgen(L, g, psurvival, g->reallyold); g->reallyold = g->old; g->old = *psurvival; /* 'survival' survivals are old now */ g->survival = g->allgc; /* all news are survivals */ /* repeat for 'finobj' lists */ psurvival = sweepgen(L, g, &g->finobj, g->finobjsur); /* sweep 'survival' and 'old' */ sweepgen(L, g, psurvival, g->finobjrold); g->finobjrold = g->finobjold; g->finobjold = *psurvival; /* 'survival' survivals are old now */ g->finobjsur = g->finobj; /* all news are survivals */ sweepgen(L, g, &g->tobefnz, NULL); finishgencycle(L, g); }
Vulnerable
[ "CWE-763" ]
lua
a6da1472c0c5e05ff249325f979531ad51533110
2.5459394477875204e+38
27
Fixed bug: barriers cannot be active during sweep Barriers cannot be active during sweep, even in generational mode. (Although gen. mode is not incremental, it can hit a barrier when deleting a thread and closing its upvalues.) The colors of objects are being changed during sweep and, therefore, cannot be trusted.
1
AvahiSServiceBrowser *avahi_s_service_browser_new( AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const char *service_type, const char *domain, AvahiLookupFlags flags, AvahiSServiceBrowserCallback callback, void* userdata) { AvahiSServiceBrowser *b; b = avahi_s_service_browser_prepare(server, interface, protocol, service_type, domain, flags, callback, userdata); avahi_s_service_browser_start(b); return b; }
Vulnerable
[]
avahi
9d31939e55280a733d930b15ac9e4dda4497680c
6.532674823648339e+35
16
Fix NULL pointer crashes from #175 avahi-daemon is crashing when running "ping .local". The crash is due to failing assertion from NULL pointer. Add missing NULL pointer checks to fix it. Introduced in #175 - merge commit 8f75a045709a780c8cf92a6a21e9d35b593bdecd
1
flatpak_dir_modify_remote (FlatpakDir *self, const char *remote_name, GKeyFile *config, GBytes *gpg_data, GCancellable *cancellable, GError **error) { g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote_name); g_autofree char *url = NULL; g_autofree char *metalink = NULL; g_autoptr(GKeyFile) new_config = NULL; g_autofree gchar *filter_path = NULL; gboolean has_remote; if (strchr (remote_name, '/') != NULL) return flatpak_fail_error (error, FLATPAK_ERROR_REMOTE_NOT_FOUND, _("Invalid character '/' in remote name: %s"), remote_name); has_remote = flatpak_dir_has_remote (self, remote_name, NULL); if (!g_key_file_has_group (config, group)) return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("No configuration for remote %s specified"), remote_name); if (!flatpak_dir_check_add_remotes_config_dir (self, error)) return FALSE; if (flatpak_dir_use_system_helper (self, NULL)) { g_autofree char *config_data = g_key_file_to_data (config, NULL, NULL); g_autoptr(GVariant) gpg_data_v = NULL; const char *installation = flatpak_dir_get_id (self); if (gpg_data != NULL) gpg_data_v = variant_new_ay_bytes (gpg_data); else gpg_data_v = g_variant_ref_sink (g_variant_new_from_data (G_VARIANT_TYPE ("ay"), "", 0, TRUE, NULL, NULL)); if (!flatpak_dir_system_helper_call_configure_remote (self, 0, remote_name, config_data, gpg_data_v, installation ? installation : "", cancellable, error)) return FALSE; /* If we e.g. changed url or gpg config the cached summary may be invalid */ if (!flatpak_dir_remote_clear_cached_summary (self, remote_name, cancellable, error)) return FALSE; return TRUE; } metalink = g_key_file_get_string (config, group, "metalink", NULL); if (metalink != NULL && *metalink != 0) url = g_strconcat ("metalink=", metalink, NULL); else url = g_key_file_get_string (config, group, "url", NULL); /* No url => disabled */ if (url == NULL) url = g_strdup (""); if (!flatpak_dir_cleanup_remote_for_url_change (self, remote_name, url, cancellable, error)) return FALSE; /* Add it if its not there yet */ if (!ostree_repo_remote_change (self->repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS, remote_name, url, NULL, cancellable, error)) return FALSE; new_config = ostree_repo_copy_config (self->repo); copy_remote_config (new_config, config, remote_name); if (!ostree_repo_write_config (self->repo, new_config, error)) return FALSE; if (gpg_data != NULL) { g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_bytes (gpg_data); guint imported = 0; if (!ostree_repo_remote_gpg_import (self->repo, remote_name, input_stream, NULL, &imported, cancellable, error)) return FALSE; /* XXX If we ever add internationalization, use ngettext() here. */ g_debug ("Imported %u GPG key%s to remote \"%s\"", imported, (imported == 1) ? "" : "s", remote_name); } filter_path = g_key_file_get_value (new_config, group, "xa.filter", NULL); if (filter_path && *filter_path && g_file_test (filter_path, G_FILE_TEST_EXISTS)) { /* Make a backup filter copy in case it goes away later */ g_autofree char *filter_name = g_strconcat (remote_name, ".filter", NULL); g_autoptr(GFile) filter_file = g_file_new_for_path (filter_path); g_autoptr(GFile) filter_copy = flatpak_build_file (self->basedir, "repo", filter_name, NULL); g_autoptr(GError) local_error = NULL; g_autofree char *backup_data = NULL; gsize backup_data_size; if (g_file_load_contents (filter_file, cancellable, &backup_data, &backup_data_size, NULL, &local_error)) { g_autofree char *backup_data_copy = g_strdup_printf ("# backup copy of %s, do not edit!\n%s", filter_path, backup_data); if (!g_file_replace_contents (filter_copy, backup_data_copy, strlen (backup_data_copy), NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, cancellable, &local_error)) g_debug ("Failed to save backup copy of filter file %s: %s\n", filter_path, local_error->message); } else { g_debug ("Failed to read filter %s file while making a backup copy: %s\n", filter_path, local_error->message); } } /* If we e.g. changed url or gpg config the cached summary may be invalid */ if (!flatpak_dir_remote_clear_cached_summary (self, remote_name, cancellable, error)) return FALSE; if (!flatpak_dir_mark_changed (self, error)) return FALSE; if (has_remote) flatpak_dir_log (self, "modify remote", remote_name, NULL, NULL, NULL, url, "Modified remote %s to %s", remote_name, url); else flatpak_dir_log (self, "add remote", remote_name, NULL, NULL, NULL, url, "Added remote %s to %s", remote_name, url); return TRUE; }
Safe
[ "CWE-74" ]
flatpak
fb473cad801c6b61706353256cab32330557374a
2.3873650368554567e+38
136
dir: Pass environment via bwrap --setenv when running apply_extra This means we can systematically pass the environment variables through bwrap(1), even if it is setuid and thus is filtering out security-sensitive environment variables. bwrap ends up being run with an empty environment instead. As with the previous commit, this regressed while fixing CVE-2021-21261. Fixes: 6d1773d2 "run: Convert all environment variables into bwrap arguments" Signed-off-by: Simon McVittie <smcv@collabora.com>
0
void comps_objrtree_unite(COMPS_ObjRTree *rt1, COMPS_ObjRTree *rt2) { COMPS_HSList *tmplist, *tmp_subnodes; COMPS_HSListItem *it; struct Pair { COMPS_HSList * subnodes; char * key; } *pair, *parent_pair; pair = malloc(sizeof(struct Pair)); pair->subnodes = rt2->subnodes; pair->key = NULL; tmplist = comps_hslist_create(); comps_hslist_init(tmplist, NULL, NULL, &free); comps_hslist_append(tmplist, pair, 0); while (tmplist->first != NULL) { it = tmplist->first; comps_hslist_remove(tmplist, tmplist->first); tmp_subnodes = ((struct Pair*)it->data)->subnodes; parent_pair = (struct Pair*) it->data; //printf("key-part:%s\n", parent_pair->key); free(it); for (it = tmp_subnodes->first; it != NULL; it=it->next) { pair = malloc(sizeof(struct Pair)); pair->subnodes = ((COMPS_ObjRTreeData*)it->data)->subnodes; if (parent_pair->key != NULL) { pair->key = malloc(sizeof(char) * (strlen(((COMPS_ObjRTreeData*)it->data)->key) + strlen(parent_pair->key) + 1)); memcpy(pair->key, parent_pair->key, sizeof(char) * strlen(parent_pair->key)); memcpy(pair->key + strlen(parent_pair->key), ((COMPS_ObjRTreeData*)it->data)->key, sizeof(char)*(strlen(((COMPS_ObjRTreeData*)it->data)->key)+1)); } else { pair->key = malloc(sizeof(char)* (strlen(((COMPS_ObjRTreeData*)it->data)->key) +1)); memcpy(pair->key, ((COMPS_ObjRTreeData*)it->data)->key, sizeof(char)*(strlen(((COMPS_ObjRTreeData*)it->data)->key)+1)); } /* current node has data */ if (((COMPS_ObjRTreeData*)it->data)->data != NULL) { comps_objrtree_set(rt1, pair->key, (((COMPS_ObjRTreeData*)it->data)->data)); } if (((COMPS_ObjRTreeData*)it->data)->subnodes->first) { comps_hslist_append(tmplist, pair, 0); } else { free(pair->key); free(pair); } } free(parent_pair->key); free(parent_pair); } comps_hslist_destroy(&tmplist); }
Safe
[ "CWE-416", "CWE-862" ]
libcomps
e3a5d056633677959ad924a51758876d415e7046
1.100215186191286e+38
60
Fix UAF in comps_objmrtree_unite function The added field is not used at all in many places and it is probably the left-over of some copy-paste.
0
int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) { if (!file) return HA_ADMIN_INTERNAL_ERROR; int error; MI_CHECK param; MYISAM_SHARE* share = file->s; const char *old_proc_info=thd->proc_info; thd_proc_info(thd, "Checking table"); myisamchk_init(&param); param.thd = thd; param.op_name = "check"; param.db_name= table->s->db.str; param.table_name= table->alias; param.testflag = check_opt->flags | T_CHECK | T_SILENT; param.stats_method= (enum_mi_stats_method)THDVAR(thd, stats_method); if (!(table->db_stat & HA_READ_ONLY)) param.testflag|= T_STATISTICS; param.using_global_keycache = 1; if (!mi_is_crashed(file) && (((param.testflag & T_CHECK_ONLY_CHANGED) && !(share->state.changed & (STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR)) && share->state.open_count == 0) || ((param.testflag & T_FAST) && (share->state.open_count == (uint) (share->global_changed ? 1 : 0))))) return HA_ADMIN_ALREADY_DONE; error = chk_status(&param, file); // Not fatal error = chk_size(&param, file); if (!error) error |= chk_del(&param, file, param.testflag); if (!error) error = chk_key(&param, file); if (!error) { if ((!(param.testflag & T_QUICK) && ((share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) || (param.testflag & (T_EXTEND | T_MEDIUM)))) || mi_is_crashed(file)) { uint old_testflag=param.testflag; param.testflag|=T_MEDIUM; if (!(error= init_io_cache(&param.read_cache, file->dfile, my_default_record_cache_size, READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)))) { error= chk_data_link(&param, file, param.testflag & T_EXTEND); end_io_cache(&(param.read_cache)); } param.testflag= old_testflag; } } if (!error) { if ((share->state.changed & (STATE_CHANGED | STATE_CRASHED_ON_REPAIR | STATE_CRASHED | STATE_NOT_ANALYZED)) || (param.testflag & T_STATISTICS) || mi_is_crashed(file)) { file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; mysql_mutex_lock(&share->intern_lock); share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR); if (!(table->db_stat & HA_READ_ONLY)) error=update_state_info(&param,file,UPDATE_TIME | UPDATE_OPEN_COUNT | UPDATE_STAT); mysql_mutex_unlock(&share->intern_lock); info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | HA_STATUS_CONST); } } else if (!mi_is_crashed(file) && !thd->killed) { mi_mark_crashed(file); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; } thd_proc_info(thd, old_proc_info); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; }
Safe
[ "CWE-362" ]
mysql-server
4e5473862e6852b0f3802b0cd0c6fa10b5253291
5.341366245706559e+37
85
Bug#24388746: PRIVILEGE ESCALATION AND RACE CONDITION USING CREATE TABLE During REPAIR TABLE of a MyISAM table, a temporary data file (.TMD) is created. When repair finishes, this file is renamed to the original .MYD file. The problem was that during this rename, we copied the stats from the old file to the new file with chmod/chown. If a user managed to replace the temporary file before chmod/chown was executed, it was possible to get an arbitrary file with the privileges of the mysql user. This patch fixes the problem by not copying stats from the old file to the new file. This is not needed as the new file was created with the correct stats. This fix only changes server behavior - external utilities such as myisamchk still does chmod/chown. No test case provided since the problem involves synchronization with file system operations.
0
pfm_context_unload(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) { struct task_struct *task = PFM_CTX_TASK(ctx); struct pt_regs *tregs; int prev_state, is_system; int ret; DPRINT(("ctx_state=%d task [%d]\n", ctx->ctx_state, task ? task->pid : -1)); prev_state = ctx->ctx_state; is_system = ctx->ctx_fl_system; /* * unload only when necessary */ if (prev_state == PFM_CTX_UNLOADED) { DPRINT(("ctx_state=%d, nothing to do\n", prev_state)); return 0; } /* * clear psr and dcr bits */ ret = pfm_stop(ctx, NULL, 0, regs); if (ret) return ret; ctx->ctx_state = PFM_CTX_UNLOADED; /* * in system mode, we need to update the PMU directly * and the user level state of the caller, which may not * necessarily be the creator of the context. */ if (is_system) { /* * Update cpuinfo * * local PMU is taken care of in pfm_stop() */ PFM_CPUINFO_CLEAR(PFM_CPUINFO_SYST_WIDE); PFM_CPUINFO_CLEAR(PFM_CPUINFO_EXCL_IDLE); /* * save PMDs in context * release ownership */ pfm_flush_pmds(current, ctx); /* * at this point we are done with the PMU * so we can unreserve the resource. */ if (prev_state != PFM_CTX_ZOMBIE) pfm_unreserve_session(ctx, 1 , ctx->ctx_cpu); /* * disconnect context from task */ task->thread.pfm_context = NULL; /* * disconnect task from context */ ctx->ctx_task = NULL; /* * There is nothing more to cleanup here. */ return 0; } /* * per-task mode */ tregs = task == current ? regs : task_pt_regs(task); if (task == current) { /* * cancel user level control */ ia64_psr(regs)->sp = 1; DPRINT(("setting psr.sp for [%d]\n", task->pid)); } /* * save PMDs to context * release ownership */ pfm_flush_pmds(task, ctx); /* * at this point we are done with the PMU * so we can unreserve the resource. * * when state was ZOMBIE, we have already unreserved. */ if (prev_state != PFM_CTX_ZOMBIE) pfm_unreserve_session(ctx, 0 , ctx->ctx_cpu); /* * reset activation counter and psr */ ctx->ctx_last_activation = PFM_INVALID_ACTIVATION; SET_LAST_CPU(ctx, -1); /* * PMU state will not be restored */ task->thread.flags &= ~IA64_THREAD_PM_VALID; /* * break links between context and task */ task->thread.pfm_context = NULL; ctx->ctx_task = NULL; PFM_SET_WORK_PENDING(task, 0); ctx->ctx_fl_trap_reason = PFM_TRAP_REASON_NONE; ctx->ctx_fl_can_restart = 0; ctx->ctx_fl_going_zombie = 0; DPRINT(("disconnected [%d] from context\n", task->pid)); return 0; }
Safe
[]
linux-2.6
41d5e5d73ecef4ef56b7b4cde962929a712689b4
1.3758594538190809e+38
126
[IA64] permon use-after-free fix Perfmon associates vmalloc()ed memory with a file descriptor, and installs a vma mapping that memory. Unfortunately, the vm_file field is not filled in, so processes with mappings to that memory do not prevent the file from being closed and the memory freed. This results in use-after-free bugs and multiple freeing of pages, etc. I saw this bug on an Altix on SLES9. Haven't reproduced upstream but it looks like the same issue is there. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Stephane Eranian <eranian@hpl.hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Tony Luck <tony.luck@intel.com>
0
AlterForeignServerOwner(const char *name, Oid newOwnerId) { Oid servOid; HeapTuple tup; Relation rel; ObjectAddress address; Form_pg_foreign_server form; rel = table_open(ForeignServerRelationId, RowExclusiveLock); tup = SearchSysCacheCopy1(FOREIGNSERVERNAME, CStringGetDatum(name)); if (!HeapTupleIsValid(tup)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("server \"%s\" does not exist", name))); form = (Form_pg_foreign_server) GETSTRUCT(tup); servOid = form->oid; AlterForeignServerOwner_internal(rel, tup, newOwnerId); ObjectAddressSet(address, ForeignServerRelationId, servOid); heap_freetuple(tup); table_close(rel, RowExclusiveLock); return address; }
Safe
[ "CWE-94" ]
postgres
b9b21acc766db54d8c337d508d0fe2f5bf2daab0
1.6999836042145469e+38
30
In extensions, don't replace objects not belonging to the extension. Previously, if an extension script did CREATE OR REPLACE and there was an existing object not belonging to the extension, it would overwrite the object and adopt it into the extension. This is problematic, first because the overwrite is probably unintentional, and second because we didn't change the object's ownership. Thus a hostile user could create an object in advance of an expected CREATE EXTENSION command, and would then have ownership rights on an extension object, which could be modified for trojan-horse-type attacks. Hence, forbid CREATE OR REPLACE of an existing object unless it already belongs to the extension. (Note that we've always forbidden replacing an object that belongs to some other extension; only the behavior for previously-free-standing objects changes here.) For the same reason, also fail CREATE IF NOT EXISTS when there is an existing object that doesn't belong to the extension. Our thanks to Sven Klemm for reporting this problem. Security: CVE-2022-2625
0
encode_LEARN(const struct ofpact_learn *learn, enum ofp_version ofp_version OVS_UNUSED, struct ofpbuf *out) { const struct ofpact_learn_spec *spec; struct nx_action_learn *nal; size_t start_ofs; start_ofs = out->size; if (learn->ofpact.raw == NXAST_RAW_LEARN2 || learn->limit != 0 || learn->flags & NX_LEARN_F_WRITE_RESULT) { struct nx_action_learn2 *nal2; nal2 = put_NXAST_LEARN2(out); nal2->limit = htonl(learn->limit); nal2->result_dst_ofs = htons(learn->result_dst.ofs); nal = &nal2->up; } else { nal = put_NXAST_LEARN(out); } nal->idle_timeout = htons(learn->idle_timeout); nal->hard_timeout = htons(learn->hard_timeout); nal->fin_idle_timeout = htons(learn->fin_idle_timeout); nal->fin_hard_timeout = htons(learn->fin_hard_timeout); nal->priority = htons(learn->priority); nal->cookie = learn->cookie; nal->flags = htons(learn->flags); nal->table_id = learn->table_id; if (learn->flags & NX_LEARN_F_WRITE_RESULT) { nx_put_header(out, learn->result_dst.field->id, 0, false); } OFPACT_LEARN_SPEC_FOR_EACH (spec, learn) { put_u16(out, spec->n_bits | spec->dst_type | spec->src_type); if (spec->src_type == NX_LEARN_SRC_FIELD) { put_u32(out, nxm_header_from_mff(spec->src.field)); put_u16(out, spec->src.ofs); } else { size_t n_dst_bytes = 2 * DIV_ROUND_UP(spec->n_bits, 16); uint8_t *bits = ofpbuf_put_zeros(out, n_dst_bytes); unsigned int n_bytes = DIV_ROUND_UP(spec->n_bits, 8); memcpy(bits + n_dst_bytes - n_bytes, ofpact_learn_spec_imm(spec), n_bytes); } if (spec->dst_type == NX_LEARN_DST_MATCH || spec->dst_type == NX_LEARN_DST_LOAD) { put_u32(out, nxm_header_from_mff(spec->dst.field)); put_u16(out, spec->dst.ofs); } } pad_ofpat(out, start_ofs); }
Safe
[ "CWE-416" ]
ovs
77cccc74deede443e8b9102299efc869a52b65b2
1.546968932688727e+38
58
ofp-actions: Fix use-after-free while decoding RAW_ENCAP. While decoding RAW_ENCAP action, decode_ed_prop() might re-allocate ofpbuf if there is no enough space left. However, function 'decode_NXAST_RAW_ENCAP' continues to use old pointer to 'encap' structure leading to write-after-free and incorrect decoding. ==3549105==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600000011a at pc 0x0000005f6cc6 bp 0x7ffc3a2d4410 sp 0x7ffc3a2d4408 WRITE of size 2 at 0x60600000011a thread T0 #0 0x5f6cc5 in decode_NXAST_RAW_ENCAP lib/ofp-actions.c:4461:20 #1 0x5f0551 in ofpact_decode ./lib/ofp-actions.inc2:4777:16 #2 0x5ed17c in ofpacts_decode lib/ofp-actions.c:7752:21 #3 0x5eba9a in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7791:13 #4 0x5eb9fc in ofpacts_pull_openflow_actions lib/ofp-actions.c:7835:12 #5 0x64bb8b in ofputil_decode_packet_out lib/ofp-packet.c:1113:17 #6 0x65b6f4 in ofp_print_packet_out lib/ofp-print.c:148:13 #7 0x659e3f in ofp_to_string__ lib/ofp-print.c:1029:16 #8 0x659b24 in ofp_to_string lib/ofp-print.c:1244:21 #9 0x65a28c in ofp_print lib/ofp-print.c:1288:28 #10 0x540d11 in ofctl_ofp_parse utilities/ovs-ofctl.c:2814:9 #11 0x564228 in ovs_cmdl_run_command__ lib/command-line.c:247:17 #12 0x56408a in ovs_cmdl_run_command lib/command-line.c:278:5 #13 0x5391ae in main utilities/ovs-ofctl.c:179:9 #14 0x7f6911ce9081 in __libc_start_main (/lib64/libc.so.6+0x27081) #15 0x461fed in _start (utilities/ovs-ofctl+0x461fed) Fix that by getting a new pointer before using. Credit to OSS-Fuzz. Fuzzer regression test will fail only with AddressSanitizer enabled. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27851 Fixes: f839892a206a ("OF support and translation of generic encap and decap") Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
0
mount_callback_data_notify (gpointer data, GObject *object) { GMountOperation *mount_op; mount_op = G_MOUNT_OPERATION (data); g_object_set_data (G_OBJECT (mount_op), "mount-callback", NULL); g_object_set_data (G_OBJECT (mount_op), "mount-callback-data", NULL); }
Safe
[]
nautilus
ca2fd475297946f163c32dcea897f25da892b89d
2.536331285050778e+38
9
Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if 2009-02-24 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-file-operations.c: * libnautilus-private/nautilus-file-operations.h: Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if there is none as well as makes the file executable. * libnautilus-private/nautilus-mime-actions.c: Use nautilus_file_mark_desktop_file_trusted() instead of just setting the permissions. svn path=/trunk/; revision=15006
0
move_job_done (gpointer user_data) { CopyMoveJob *job; job = user_data; if (job->done_callback) { job->done_callback (job->debuting_files, job->done_callback_data); } eel_g_object_list_free (job->files); g_object_unref (job->destination); g_hash_table_unref (job->debuting_files); g_free (job->icon_positions); finalize_common ((CommonJob *)job); nautilus_file_changes_consume_changes (TRUE); return FALSE; }
Safe
[]
nautilus
ca2fd475297946f163c32dcea897f25da892b89d
8.098451535109108e+37
19
Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if 2009-02-24 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-file-operations.c: * libnautilus-private/nautilus-file-operations.h: Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if there is none as well as makes the file executable. * libnautilus-private/nautilus-mime-actions.c: Use nautilus_file_mark_desktop_file_trusted() instead of just setting the permissions. svn path=/trunk/; revision=15006
0
SendGradientRect(rfbClientPtr cl, int w, int h) { int streamId = 3; int len; if (cl->format.bitsPerPixel == 8) return SendFullColorRect(cl, w, h); if (cl->ublen + TIGHT_MIN_TO_COMPRESS + 2 > UPDATE_BUF_SIZE) { if (!rfbSendUpdateBuf(cl)) return FALSE; } if (prevRowBuf == NULL) prevRowBuf = (int *)malloc(2048 * 3 * sizeof(int)); cl->updateBuf[cl->ublen++] = (streamId | rfbTightExplicitFilter) << 4; cl->updateBuf[cl->ublen++] = rfbTightFilterGradient; rfbStatRecordEncodingSentAdd(cl, rfbEncodingTight, 2); if (usePixelFormat24) { FilterGradient24(cl, tightBeforeBuf, &cl->format, w, h); len = 3; } else if (cl->format.bitsPerPixel == 32) { FilterGradient32(cl, (uint32_t *)tightBeforeBuf, &cl->format, w, h); len = 4; } else { FilterGradient16(cl, (uint16_t *)tightBeforeBuf, &cl->format, w, h); len = 2; } return CompressData(cl, streamId, w * h * len, tightConf[compressLevel].gradientZlibLevel, Z_FILTERED); }
Safe
[]
libvncserver
804335f9d296440bb708ca844f5d89b58b50b0c6
9.926821396597274e+37
37
Thread safety for zrle, zlib, tight. Proposed tight security type fix for debian bug 517422.
0
sparse_extract_file (int fd, struct tar_stat_info *st, off_t *size) { bool rc = true; struct tar_sparse_file file; size_t i; if (!tar_sparse_init (&file)) return dump_status_not_implemented; file.stat_info = st; file.fd = fd; file.seekable = lseek (fd, 0, SEEK_SET) == 0; file.offset = 0; rc = tar_sparse_decode_header (&file); for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++) rc = tar_sparse_extract_region (&file, i); *size = file.stat_info->archive_file_size - file.dumped_size; return (tar_sparse_done (&file) && rc) ? dump_status_ok : dump_status_short; }
Safe
[]
tar
c15c42ccd1e2377945fd0414eca1a49294bff454
2.542446058421514e+38
20
Fix CVE-2018-20482 * NEWS: Update. * src/sparse.c (sparse_dump_region): Handle short read condition. (sparse_extract_region,check_data_region): Fix dumped_size calculation. Handle short read condition. (pax_decode_header): Fix dumped_size calculation. * tests/Makefile.am: Add new testcases. * tests/testsuite.at: Likewise. * tests/sptrcreat.at: New file. * tests/sptrdiff00.at: New file. * tests/sptrdiff01.at: New file.
0
long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, unsigned long shmlba) { struct shmid_kernel *shp; unsigned long addr; unsigned long size; struct file * file; int err; unsigned long flags; unsigned long prot; int acc_mode; struct ipc_namespace *ns; struct shm_file_data *sfd; struct path path; fmode_t f_mode; unsigned long populate = 0; err = -EINVAL; if (shmid < 0) goto out; else if ((addr = (ulong)shmaddr)) { if (addr & (shmlba - 1)) { if (shmflg & SHM_RND) addr &= ~(shmlba - 1); /* round down */ else #ifndef __ARCH_FORCE_SHMLBA if (addr & ~PAGE_MASK) #endif goto out; } flags = MAP_SHARED | MAP_FIXED; } else { if ((shmflg & SHM_REMAP)) goto out; flags = MAP_SHARED; } if (shmflg & SHM_RDONLY) { prot = PROT_READ; acc_mode = S_IRUGO; f_mode = FMODE_READ; } else { prot = PROT_READ | PROT_WRITE; acc_mode = S_IRUGO | S_IWUGO; f_mode = FMODE_READ | FMODE_WRITE; } if (shmflg & SHM_EXEC) { prot |= PROT_EXEC; acc_mode |= S_IXUGO; } /* * We cannot rely on the fs check since SYSV IPC does have an * additional creator id... */ ns = current->nsproxy->ipc_ns; rcu_read_lock(); shp = shm_obtain_object_check(ns, shmid); if (IS_ERR(shp)) { err = PTR_ERR(shp); goto out_unlock; } err = -EACCES; if (ipcperms(ns, &shp->shm_perm, acc_mode)) goto out_unlock; err = security_shm_shmat(shp, shmaddr, shmflg); if (err) goto out_unlock; ipc_lock_object(&shp->shm_perm); /* check if shm_destroy() is tearing down shp */ if (shp->shm_file == NULL) { ipc_unlock_object(&shp->shm_perm); err = -EIDRM; goto out_unlock; } path = shp->shm_file->f_path; path_get(&path); shp->shm_nattch++; size = i_size_read(path.dentry->d_inode); ipc_unlock_object(&shp->shm_perm); rcu_read_unlock(); err = -ENOMEM; sfd = kzalloc(sizeof(*sfd), GFP_KERNEL); if (!sfd) { path_put(&path); goto out_nattch; } file = alloc_file(&path, f_mode, is_file_hugepages(shp->shm_file) ? &shm_file_operations_huge : &shm_file_operations); err = PTR_ERR(file); if (IS_ERR(file)) { kfree(sfd); path_put(&path); goto out_nattch; } file->private_data = sfd; file->f_mapping = shp->shm_file->f_mapping; sfd->id = shp->shm_perm.id; sfd->ns = get_ipc_ns(ns); sfd->file = shp->shm_file; sfd->vm_ops = NULL; err = security_mmap_file(file, prot, flags); if (err) goto out_fput; down_write(&current->mm->mmap_sem); if (addr && !(shmflg & SHM_REMAP)) { err = -EINVAL; if (find_vma_intersection(current->mm, addr, addr + size)) goto invalid; /* * If shm segment goes below stack, make sure there is some * space left for the stack to grow (at least 4 pages). */ if (addr < current->mm->start_stack && addr > current->mm->start_stack - size - PAGE_SIZE * 5) goto invalid; } addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate); *raddr = addr; err = 0; if (IS_ERR_VALUE(addr)) err = (long)addr; invalid: up_write(&current->mm->mmap_sem); if (populate) mm_populate(addr, populate); out_fput: fput(file); out_nattch: down_write(&shm_ids(ns).rwsem); shp = shm_lock(ns, shmid); BUG_ON(IS_ERR(shp)); shp->shm_nattch--; if (shm_may_destroy(ns, shp)) shm_destroy(ns, shp); else shm_unlock(shp); up_write(&shm_ids(ns).rwsem); return err; out_unlock: rcu_read_unlock(); out: return err; }
Safe
[ "CWE-362" ]
linux
a399b29dfbaaaf91162b2dc5a5875dd51bbfa2a1
2.1870318206302963e+38
161
ipc,shm: fix shm_file deletion races When IPC_RMID races with other shm operations there's potential for use-after-free of the shm object's associated file (shm_file). Here's the race before this patch: TASK 1 TASK 2 ------ ------ shm_rmid() ipc_lock_object() shmctl() shp = shm_obtain_object_check() shm_destroy() shum_unlock() fput(shp->shm_file) ipc_lock_object() shmem_lock(shp->shm_file) <OOPS> The oops is caused because shm_destroy() calls fput() after dropping the ipc_lock. fput() clears the file's f_inode, f_path.dentry, and f_path.mnt, which causes various NULL pointer references in task 2. I reliably see the oops in task 2 if with shmlock, shmu This patch fixes the races by: 1) set shm_file=NULL in shm_destroy() while holding ipc_object_lock(). 2) modify at risk operations to check shm_file while holding ipc_object_lock(). Example workloads, which each trigger oops... Workload 1: while true; do id=$(shmget 1 4096) shm_rmid $id & shmlock $id & wait done The oops stack shows accessing NULL f_inode due to racing fput: _raw_spin_lock shmem_lock SyS_shmctl Workload 2: while true; do id=$(shmget 1 4096) shmat $id 4096 & shm_rmid $id & wait done The oops stack is similar to workload 1 due to NULL f_inode: touch_atime shmem_mmap shm_mmap mmap_region do_mmap_pgoff do_shmat SyS_shmat Workload 3: while true; do id=$(shmget 1 4096) shmlock $id shm_rmid $id & shmunlock $id & wait done The oops stack shows second fput tripping on an NULL f_inode. The first fput() completed via from shm_destroy(), but a racing thread did a get_file() and queued this fput(): locks_remove_flock __fput ____fput task_work_run do_notify_resume int_signal Fixes: c2c737a0461e ("ipc,shm: shorten critical region for shmat") Fixes: 2caacaa82a51 ("ipc,shm: shorten critical region for shmctl") Signed-off-by: Greg Thelen <gthelen@google.com> Cc: Davidlohr Bueso <davidlohr@hp.com> Cc: Rik van Riel <riel@redhat.com> Cc: Manfred Spraul <manfred@colorfullife.com> Cc: <stable@vger.kernel.org> # 3.10.17+ 3.11.6+ Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
int JBIG2Stream::getChar() { if (dataPtr && dataPtr < dataEnd) { return (*dataPtr++ ^ 0xff) & 0xff; } return EOF; }
Safe
[ "CWE-476", "CWE-190" ]
poppler
27354e9d9696ee2bc063910a6c9a6b27c5184a52
2.221871478347834e+38
7
JBIG2Stream: Fix crash on broken file https://github.com/jeffssh/CVE-2021-30860 Thanks to David Warren for the heads up
0
PHP_FUNCTION(openssl_x509_fingerprint) { X509 *cert; zval **zcert; long certresource; zend_bool raw_output = 0; char *method = "sha1"; int method_len; char *fingerprint; int fingerprint_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|sb", &zcert, &method, &method_len, &raw_output) == FAILURE) { return; } cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1"); RETURN_FALSE; } if (php_openssl_x509_fingerprint(cert, method, raw_output, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) { RETVAL_STRINGL(fingerprint, fingerprint_len, 0); } else { RETVAL_FALSE; } if (certresource == -1 && cert) { X509_free(cert); } }
Safe
[ "CWE-754" ]
php-src
89637c6b41b510c20d262c17483f582f115c66d6
2.3819922720324674e+37
32
Fix bug #74651 - check EVP_SealInit as it can return -1
0
GGadget *GListFieldCreate(struct gwindow *base, GGadgetData *gd,void *data) { GListField *ge = calloc(1,sizeof(GCompletionField)); ge->gt.listfield = true; if ( gd->u.list!=NULL ) ge->ti = GTextInfoArrayFromList(gd->u.list,&ge->ltot); ge->gt.accepts_tabs = true; ge->gt.completionfield = true; /* ge->gt.was_completing = true; */ ((GCompletionField *) ge)->completion = GListField_NameCompletion; _GTextFieldCreate(&ge->gt,base,gd,data,&_GGadget_gtextfield_box); ge->gt.g.funcs = &glistfield_funcs; return( &ge->gt.g ); }
Safe
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
2.7202495171224375e+38
14
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
0
GF_HEVCConfig *gf_isom_lhvc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex) { GF_HEVCConfig *lhvc; GF_OperatingPointsInformation *oinf=NULL; GF_TrackBox *trak; GF_MPEGVisualSampleEntryBox *entry; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !DescriptionIndex) return NULL; if (gf_isom_get_hevc_lhvc_type(the_file, trackNumber, DescriptionIndex)==GF_ISOM_HEVCTYPE_NONE) return NULL; entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex-1); if (!entry) return NULL; if (!entry->lhvc_config) return NULL; lhvc = HEVC_DuplicateConfig(entry->lhvc_config->config); if (!lhvc) return NULL; gf_isom_get_oinf_info(the_file, trackNumber, &oinf); if (oinf) { LHEVC_ProfileTierLevel *ptl = (LHEVC_ProfileTierLevel *)gf_list_last(oinf->profile_tier_levels); if (ptl) { lhvc->profile_space = ptl->general_profile_space; lhvc->tier_flag = ptl->general_tier_flag; lhvc->profile_idc = ptl->general_profile_idc; lhvc->general_profile_compatibility_flags = ptl->general_profile_compatibility_flags; lhvc->constraint_indicator_flags = ptl->general_constraint_indicator_flags; } } return lhvc; }
Safe
[ "CWE-401" ]
gpac
0a85029d694f992f3631e2f249e4999daee15cbf
7.378797707269462e+37
29
fixed #1785 (fuzz)
0
static void nfs4_construct_boot_verifier(struct nfs_client *clp, nfs4_verifier *bootverf) { __be32 verf[2]; verf[0] = htonl((u32)clp->cl_boot_time.tv_sec); verf[1] = htonl((u32)clp->cl_boot_time.tv_nsec); memcpy(bootverf->data, verf, sizeof(bootverf->data)); }
Safe
[ "CWE-703", "CWE-189" ]
linux
20e0fa98b751facf9a1101edaefbc19c82616a68
2.3599787746677107e+38
9
Fix length of buffer copied in __nfs4_get_acl_uncached _copy_from_pages() used to copy data from the temporary buffer to the user passed buffer is passed the wrong size parameter when copying data. res.acl_len contains both the bitmap and acl lenghts while acl_len contains the acl length after adjusting for the bitmap size. Signed-off-by: Sachin Prabhu <sprabhu@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0
static int send_request(GDHCPClient *dhcp_client) { struct dhcp_packet packet; debug(dhcp_client, "sending DHCP request (state %d)", dhcp_client->state); init_packet(dhcp_client, &packet, DHCPREQUEST); packet.xid = dhcp_client->xid; packet.secs = dhcp_attempt_secs(dhcp_client); if (dhcp_client->state == REQUESTING || dhcp_client->state == REBOOTING) dhcp_add_option_uint32(&packet, DHCP_REQUESTED_IP, dhcp_client->requested_ip); if (dhcp_client->state == REQUESTING) dhcp_add_option_uint32(&packet, DHCP_SERVER_ID, dhcp_client->server_ip); dhcp_add_option_uint16(&packet, DHCP_MAX_SIZE, 576); add_request_options(dhcp_client, &packet); add_send_options(dhcp_client, &packet); if (dhcp_client->state == RENEWING || dhcp_client->state == REBINDING) packet.ciaddr = htonl(dhcp_client->requested_ip); if (dhcp_client->state == RENEWING) return dhcp_send_kernel_packet(&packet, dhcp_client->requested_ip, CLIENT_PORT, dhcp_client->server_ip, SERVER_PORT, dhcp_client->interface); return dhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, dhcp_client->ifindex, dhcp_client->request_bcast); }
Safe
[]
connman
a74524b3e3fad81b0fd1084ffdf9f2ea469cd9b1
1.8134913179687784e+38
40
gdhcp: Avoid leaking stack data via unitiialized variable Fixes: CVE-2021-26676
0
int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask) { struct dentry *parent; struct inode *p_inode; int ret = 0; if (!dentry) dentry = path->dentry; if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED)) return 0; parent = dget_parent(dentry); p_inode = parent->d_inode; if (unlikely(!fsnotify_inode_watches_children(p_inode))) __fsnotify_update_child_dentry_flags(p_inode); else if (p_inode->i_fsnotify_mask & mask) { /* we are notifying a parent so come up with the new mask which * specifies these are events which came from a child. */ mask |= FS_EVENT_ON_CHILD; if (path) ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH, dentry->d_name.name, 0); else ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); } dput(parent); return ret; }
Vulnerable
[ "CWE-362", "CWE-399" ]
linux
49d31c2f389acfe83417083e1208422b4091cd9e
1.6068490113876438e+38
34
dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1
int nl_dump_ext_ack(const struct nlmsghdr *nlh, nl_ext_ack_fn_t errfn) { return 0; }
Safe
[]
iproute2
8c50b728b226f6254251282697ce38a72639a6fc
1.4700870814162943e+38
4
libnetlink: fix use-after-free of message buf In __rtnl_talk_iov() main loop, err is a pointer to memory in dynamically allocated 'buf' that is used to store netlink messages. If netlink message is an error message, buf is deallocated before returning with error code. However, on return err->error code is checked one more time to generate return value, after memory which err points to has already been freed. Save error code in temporary variable and use the variable to generate return value. Fixes: c60389e4f9ea ("libnetlink: fix leak and using unused memory on error") Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
0
BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags) { int i, inf; INT16 lsi16; const GLYPH_DATA* glyph; inf = update_approximate_cache_glyph_order(cache_glyph, flags); if (!Stream_EnsureRemainingCapacity(s, inf)) return FALSE; Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */ Stream_Write_UINT8(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ for (i = 0; i < (int)cache_glyph->cGlyphs; i++) { UINT32 cb; glyph = &cache_glyph->glyphData[i]; Stream_Write_UINT16(s, glyph->cacheIndex); /* cacheIndex (2 bytes) */ lsi16 = glyph->x; Stream_Write_UINT16(s, lsi16); /* x (2 bytes) */ lsi16 = glyph->y; Stream_Write_UINT16(s, lsi16); /* y (2 bytes) */ Stream_Write_UINT16(s, glyph->cx); /* cx (2 bytes) */ Stream_Write_UINT16(s, glyph->cy); /* cy (2 bytes) */ cb = ((glyph->cx + 7) / 8) * glyph->cy; cb += ((cb % 4) > 0) ? 4 - (cb % 4) : 0; Stream_Write(s, glyph->aj, cb); } if (*flags & CG_GLYPH_UNICODE_PRESENT) { Stream_Zero(s, cache_glyph->cGlyphs * 2); } return TRUE; }
Safe
[ "CWE-415" ]
FreeRDP
67c2aa52b2ae0341d469071d1bc8aab91f8d2ed8
2.462044273466417e+38
36
Fixed #6013: Check new length is > 0
0
static void test_bug11183() { int rc; MYSQL_STMT *stmt; char bug_statement[]= "insert into t1 values (1)"; myheader("test_bug11183"); mysql_query(mysql, "drop table t1 if exists"); mysql_query(mysql, "create table t1 (a int)"); stmt= mysql_stmt_init(mysql); DIE_UNLESS(stmt != 0); rc= mysql_stmt_prepare(stmt, bug_statement, strlen(bug_statement)); check_execute(stmt, rc); rc= mysql_query(mysql, "drop table t1"); myquery(rc); /* Trying to execute statement that should fail on execute stage */ rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc); mysql_stmt_reset(stmt); DIE_UNLESS(mysql_stmt_errno(stmt) == 0); mysql_query(mysql, "create table t1 (a int)"); /* Trying to execute statement that should pass ok */ if (mysql_stmt_execute(stmt)) { mysql_stmt_reset(stmt); DIE_UNLESS(mysql_stmt_errno(stmt) == 0); } mysql_stmt_close(stmt); rc= mysql_query(mysql, "drop table t1"); myquery(rc); }
Safe
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
1.1308466114399155e+38
41
WL#6791 : Redefine client --ssl option to imply enforced encryption # Changed the meaning of the --ssl=1 option of all client binaries to mean force ssl, not try ssl and fail over to eunecrypted # Added a new MYSQL_OPT_SSL_ENFORCE mysql_options() option to specify that an ssl connection is required. # Added a new macro SSL_SET_OPTIONS() to the client SSL handling headers that sets all the relevant SSL options at once. # Revamped all of the current native clients to use the new macro # Removed some Windows line endings. # Added proper handling of the new option into the ssl helper headers. # If SSL is mandatory assume that the media is secure enough for the sha256 plugin to do unencrypted password exchange even before establishing a connection. # Set the default ssl cipher to DHE-RSA-AES256-SHA if none is specified. # updated test cases that require a non-default cipher to spawn a mysql command line tool binary since mysqltest has no support for specifying ciphers. # updated the replication slave connection code to always enforce SSL if any of the SSL config options is present. # test cases added and updated. # added a mysql_get_option() API to return mysql_options() values. Used the new API inside the sha256 plugin. # Fixed compilation warnings because of unused variables. # Fixed test failures (mysql_ssl and bug13115401) # Fixed whitespace issues. # Fully implemented the mysql_get_option() function. # Added a test case for mysql_get_option() # fixed some trailing whitespace issues # fixed some uint/int warnings in mysql_client_test.c # removed shared memory option from non-windows get_options tests # moved MYSQL_OPT_LOCAL_INFILE to the uint options
0
int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) { struct iphdr *iph; int ptr; struct net_device *dev; struct sk_buff *skb2; unsigned int mtu, hlen, left, len, ll_rs; int offset; __be16 not_last_frag; struct rtable *rt = skb_rtable(skb); int err = 0; dev = rt->dst.dev; /* * Point into the IP datagram header. */ iph = ip_hdr(skb); if (unlikely((iph->frag_off & htons(IP_DF)) && !skb->local_df)) { IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(ip_skb_dst_mtu(skb))); kfree_skb(skb); return -EMSGSIZE; } /* * Setup starting values. */ hlen = iph->ihl * 4; mtu = dst_mtu(&rt->dst) - hlen; /* Size of data space */ #ifdef CONFIG_BRIDGE_NETFILTER if (skb->nf_bridge) mtu -= nf_bridge_mtu_reduction(skb); #endif IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; /* When frag_list is given, use it. First, check its validity: * some transformers could create wrong frag_list or break existing * one, it is not prohibited. In this case fall back to copying. * * LATER: this step can be merged to real generation of fragments, * we can switch to copy when see the first bad fragment. */ if (skb_has_frag_list(skb)) { struct sk_buff *frag, *frag2; int first_len = skb_pagelen(skb); if (first_len - hlen > mtu || ((first_len - hlen) & 7) || (iph->frag_off & htons(IP_MF|IP_OFFSET)) || skb_cloned(skb)) goto slow_path; skb_walk_frags(skb, frag) { /* Correct geometry. */ if (frag->len > mtu || ((frag->len & 7) && frag->next) || skb_headroom(frag) < hlen) goto slow_path_clean; /* Partially cloned skb? */ if (skb_shared(frag)) goto slow_path_clean; BUG_ON(frag->sk); if (skb->sk) { frag->sk = skb->sk; frag->destructor = sock_wfree; } skb->truesize -= frag->truesize; } /* Everything is OK. Generate! */ err = 0; offset = 0; frag = skb_shinfo(skb)->frag_list; skb_frag_list_init(skb); skb->data_len = first_len - skb_headlen(skb); skb->len = first_len; iph->tot_len = htons(first_len); iph->frag_off = htons(IP_MF); ip_send_check(iph); for (;;) { /* Prepare header of the next frame, * before previous one went down. */ if (frag) { frag->ip_summed = CHECKSUM_NONE; skb_reset_transport_header(frag); __skb_push(frag, hlen); skb_reset_network_header(frag); memcpy(skb_network_header(frag), iph, hlen); iph = ip_hdr(frag); iph->tot_len = htons(frag->len); ip_copy_metadata(frag, skb); if (offset == 0) ip_options_fragment(frag); offset += skb->len - hlen; iph->frag_off = htons(offset>>3); if (frag->next != NULL) iph->frag_off |= htons(IP_MF); /* Ready, complete checksum */ ip_send_check(iph); } err = output(skb); if (!err) IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES); if (err || !frag) break; skb = frag; frag = skb->next; skb->next = NULL; } if (err == 0) { IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS); return 0; } while (frag) { skb = frag->next; kfree_skb(frag); frag = skb; } IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); return err; slow_path_clean: skb_walk_frags(skb, frag2) { if (frag2 == frag) break; frag2->sk = NULL; frag2->destructor = NULL; skb->truesize += frag2->truesize; } } slow_path: left = skb->len - hlen; /* Space per frame */ ptr = hlen; /* Where to start from */ /* for bridged IP traffic encapsulated inside f.e. a vlan header, * we need to make room for the encapsulating header */ ll_rs = LL_RESERVED_SPACE_EXTRA(rt->dst.dev, nf_bridge_pad(skb)); /* * Fragment the datagram. */ offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; not_last_frag = iph->frag_off & htons(IP_MF); /* * Keep copying data until we run out. */ while (left > 0) { len = left; /* IF: it doesn't fit, use 'mtu' - the data space left */ if (len > mtu) len = mtu; /* IF: we are not sending up to and including the packet end then align the next start on an eight byte boundary */ if (len < left) { len &= ~7; } /* * Allocate buffer. */ if ((skb2 = alloc_skb(len+hlen+ll_rs, GFP_ATOMIC)) == NULL) { NETDEBUG(KERN_INFO "IP: frag: no memory for new fragment!\n"); err = -ENOMEM; goto fail; } /* * Set up data on packet */ ip_copy_metadata(skb2, skb); skb_reserve(skb2, ll_rs); skb_put(skb2, len + hlen); skb_reset_network_header(skb2); skb2->transport_header = skb2->network_header + hlen; /* * Charge the memory for the fragment to any owner * it might possess */ if (skb->sk) skb_set_owner_w(skb2, skb->sk); /* * Copy the packet header into the new buffer. */ skb_copy_from_linear_data(skb, skb_network_header(skb2), hlen); /* * Copy a block of the IP datagram. */ if (skb_copy_bits(skb, ptr, skb_transport_header(skb2), len)) BUG(); left -= len; /* * Fill in the new header fields. */ iph = ip_hdr(skb2); iph->frag_off = htons((offset >> 3)); /* ANK: dirty, but effective trick. Upgrade options only if * the segment to be fragmented was THE FIRST (otherwise, * options are already fixed) and make it ONCE * on the initial skb, so that all the following fragments * will inherit fixed options. */ if (offset == 0) ip_options_fragment(skb); /* * Added AC : If we are fragmenting a fragment that's not the * last fragment then keep MF on each bit */ if (left > 0 || not_last_frag) iph->frag_off |= htons(IP_MF); ptr += len; offset += len; /* * Put this fragment into the sending queue. */ iph->tot_len = htons(len + hlen); ip_send_check(iph); err = output(skb2); if (err) goto fail; IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES); } kfree_skb(skb); IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS); return err; fail: kfree_skb(skb); IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); return err; }
Safe
[ "CWE-362" ]
linux-2.6
f6d8bd051c391c1c0458a30b2a7abcd939329259
3.01441019789843e+38
262
inet: add RCU protection to inet->opt We lack proper synchronization to manipulate inet->opt ip_options Problem is ip_make_skb() calls ip_setup_cork() and ip_setup_cork() possibly makes a copy of ipc->opt (struct ip_options), without any protection against another thread manipulating inet->opt. Another thread can change inet->opt pointer and free old one under us. Use RCU to protect inet->opt (changed to inet->inet_opt). Instead of handling atomic refcounts, just copy ip_options when necessary, to avoid cache line dirtying. We cant insert an rcu_head in struct ip_options since its included in skb->cb[], so this patch is large because I had to introduce a new ip_options_rcu structure. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static void wmi_evt_tx_mgmt(struct wil6210_priv *wil, int id, void *d, int len) { struct wmi_tx_mgmt_packet_event *data = d; struct ieee80211_mgmt *mgmt_frame = (struct ieee80211_mgmt *)data->payload; int flen = len - offsetof(struct wmi_tx_mgmt_packet_event, payload); wil_hex_dump_wmi("MGMT Tx ", DUMP_PREFIX_OFFSET, 16, 1, mgmt_frame, flen, true); }
Safe
[ "CWE-119" ]
linux
b5a8ffcae4103a9d823ea3aa3a761f65779fbe2a
1.47366104160713e+38
10
wil6210: missing length check in wmi_set_ie Add a length check in wmi_set_ie to detect unsigned integer overflow. Signed-off-by: Lior David <qca_liord@qca.qualcomm.com> Signed-off-by: Maya Erez <qca_merez@qca.qualcomm.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
0
static int fix_hostname(request_rec *r, const char *host_header, unsigned http_conformance) { const char *src; char *host, *scope_id; apr_port_t port; apr_status_t rv; const char *c; int is_v6literal = 0; int strict = (http_conformance != AP_HTTP_CONFORMANCE_UNSAFE); src = host_header ? host_header : r->hostname; /* According to RFC 2616, Host header field CAN be blank */ if (!*src) { return is_v6literal; } /* apr_parse_addr_port will interpret a bare integer as a port * which is incorrect in this context. So treat it separately. */ for (c = src; apr_isdigit(*c); ++c); if (!*c) { /* pure integer */ if (strict) { /* RFC 3986 7.4 */ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02416) "[strict] purely numeric host names not allowed: %s", src); goto bad_nolog; } r->hostname = src; return is_v6literal; } if (host_header) { rv = apr_parse_addr_port(&host, &scope_id, &port, src, r->pool); if (rv != APR_SUCCESS || scope_id) goto bad; if (port) { /* Don't throw the Host: header's port number away: save it in parsed_uri -- ap_get_server_port() needs it! */ /* @@@ XXX there should be a better way to pass the port. * Like r->hostname, there should be a r->portno */ r->parsed_uri.port = port; r->parsed_uri.port_str = apr_itoa(r->pool, (int)port); } if (host_header[0] == '[') is_v6literal = 1; } else { /* * Already parsed, surrounding [ ] (if IPv6 literal) and :port have * already been removed. */ host = apr_pstrdup(r->pool, r->hostname); if (ap_strchr(host, ':') != NULL) is_v6literal = 1; } if (is_v6literal) { rv = fix_hostname_v6_literal(r, host); } else { rv = fix_hostname_non_v6(r, host); if (strict && rv == APR_SUCCESS) rv = strict_hostname_check(r, host); } if (rv != APR_SUCCESS) goto bad; r->hostname = host; return is_v6literal; bad: ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00550) "Client sent malformed Host header: %s", src); bad_nolog: r->status = HTTP_BAD_REQUEST; return is_v6literal; }
Safe
[]
httpd
ecebcc035ccd8d0e2984fe41420d9e944f456b3c
9.97880706537483e+36
83
Merged r1734009,r1734231,r1734281,r1838055,r1838079,r1840229,r1876664,r1876674,r1876784,r1879078,r1881620,r1887311,r1888871 from trunk: *) core: Split ap_create_request() from ap_read_request(). [Graham Leggett] *) core, h2: common ap_parse_request_line() and ap_check_request_header() code. [Yann Ylavic] *) core: Add StrictHostCheck to allow unconfigured hostnames to be rejected. [Eric Covener] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1890245 13f79535-47bb-0310-9956-ffa450edef68
0
QPDF::writeHPageOffset(BitWriter& w) { HPageOffset& t = this->m->page_offset_hints; w.writeBitsInt(t.min_nobjects, 32); // 1 w.writeBitsInt(toI(t.first_page_offset), 32); // 2 w.writeBitsInt(t.nbits_delta_nobjects, 16); // 3 w.writeBitsInt(t.min_page_length, 32); // 4 w.writeBitsInt(t.nbits_delta_page_length, 16); // 5 w.writeBitsInt(t.min_content_offset, 32); // 6 w.writeBitsInt(t.nbits_delta_content_offset, 16); // 7 w.writeBitsInt(t.min_content_length, 32); // 8 w.writeBitsInt(t.nbits_delta_content_length, 16); // 9 w.writeBitsInt(t.nbits_nshared_objects, 16); // 10 w.writeBitsInt(t.nbits_shared_identifier, 16); // 11 w.writeBitsInt(t.nbits_shared_numerator, 16); // 12 w.writeBitsInt(t.shared_denominator, 16); // 13 int nitems = toI(getAllPages().size()); std::vector<HPageOffsetEntry>& entries = t.entries; write_vector_int(w, nitems, entries, t.nbits_delta_nobjects, &HPageOffsetEntry::delta_nobjects); write_vector_int(w, nitems, entries, t.nbits_delta_page_length, &HPageOffsetEntry::delta_page_length); write_vector_int(w, nitems, entries, t.nbits_nshared_objects, &HPageOffsetEntry::nshared_objects); write_vector_vector(w, nitems, entries, &HPageOffsetEntry::nshared_objects, t.nbits_shared_identifier, &HPageOffsetEntry::shared_identifiers); write_vector_vector(w, nitems, entries, &HPageOffsetEntry::nshared_objects, t.nbits_shared_numerator, &HPageOffsetEntry::shared_numerators); write_vector_int(w, nitems, entries, t.nbits_delta_content_offset, &HPageOffsetEntry::delta_content_offset); write_vector_int(w, nitems, entries, t.nbits_delta_content_length, &HPageOffsetEntry::delta_content_length); }
Safe
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
3.2610166155759785e+38
45
Fix sign and conversion warnings (major) This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
0
xfs_flush_inodes( struct xfs_mount *mp) { struct super_block *sb = mp->m_super; if (down_read_trylock(&sb->s_umount)) { sync_inodes_sb(sb); up_read(&sb->s_umount); } }
Safe
[ "CWE-416" ]
linux
c9fbd7bbc23dbdd73364be4d045e5d3612cf6e82
2.8035997867973344e+38
10
xfs: clear sb->s_fs_info on mount failure We recently had an oops reported on a 4.14 kernel in xfs_reclaim_inodes_count() where sb->s_fs_info pointed to garbage and so the m_perag_tree lookup walked into lala land. Essentially, the machine was under memory pressure when the mount was being run, xfs_fs_fill_super() failed after allocating the xfs_mount and attaching it to sb->s_fs_info. It then cleaned up and freed the xfs_mount, but the sb->s_fs_info field still pointed to the freed memory. Hence when the superblock shrinker then ran it fell off the bad pointer. With the superblock shrinker problem fixed at teh VFS level, this stale s_fs_info pointer is still a problem - we use it unconditionally in ->put_super when the superblock is being torn down, and hence we can still trip over it after a ->fill_super call failure. Hence we need to clear s_fs_info if xfs-fs_fill_super() fails, and we need to check if it's valid in the places it can potentially be dereferenced after a ->fill_super failure. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
0
dns_zone_next(dns_zone_t *zone, dns_zone_t **next) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(next != NULL && *next == NULL); *next = ISC_LIST_NEXT(zone, link); if (*next == NULL) return (ISC_R_NOMORE); else return (ISC_R_SUCCESS); }
Safe
[ "CWE-327" ]
bind9
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
1.0632971370534757e+38
10
Update keyfetch_done compute_tag check If in keyfetch_done the compute_tag fails (because for example the algorithm is not supported), don't crash, but instead ignore the key.
0
static int sctp_rcv_ootb(struct sk_buff *skb) { sctp_chunkhdr_t *ch; __u8 *ch_end; sctp_errhdr_t *err; ch = (sctp_chunkhdr_t *) skb->data; /* Scan through all the chunks in the packet. */ do { /* Break out if chunk length is less then minimal. */ if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) break; ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); if (ch_end > skb_tail_pointer(skb)) break; /* RFC 8.4, 2) If the OOTB packet contains an ABORT chunk, the * receiver MUST silently discard the OOTB packet and take no * further action. */ if (SCTP_CID_ABORT == ch->type) goto discard; /* RFC 8.4, 6) If the packet contains a SHUTDOWN COMPLETE * chunk, the receiver should silently discard the packet * and take no further action. */ if (SCTP_CID_SHUTDOWN_COMPLETE == ch->type) goto discard; /* RFC 4460, 2.11.2 * This will discard packets with INIT chunk bundled as * subsequent chunks in the packet. When INIT is first, * the normal INIT processing will discard the chunk. */ if (SCTP_CID_INIT == ch->type && (void *)ch != skb->data) goto discard; /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR * or a COOKIE ACK the SCTP Packet should be silently * discarded. */ if (SCTP_CID_COOKIE_ACK == ch->type) goto discard; if (SCTP_CID_ERROR == ch->type) { sctp_walk_errors(err, ch) { if (SCTP_ERROR_STALE_COOKIE == err->cause) goto discard; } } ch = (sctp_chunkhdr_t *) ch_end; } while (ch_end < skb_tail_pointer(skb)); return 0; discard: return 1; }
Safe
[]
linux
bbd0d59809f923ea2b540cbd781b32110e249f6e
1.49849720192457e+37
62
[SCTP]: Implement the receive and verification of AUTH chunk This patch implements the receive path needed to process authenticated chunks. Add ability to process the AUTH chunk and handle edge cases for authenticated COOKIE-ECHO as well. Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
onig_names_free(regex_t* reg) { int r; NameTable* t; r = names_clear(reg); if (r != 0) return r; t = (NameTable* )reg->name_table; if (IS_NOT_NULL(t)) xfree(t); reg->name_table = NULL; return 0; }
Safe
[ "CWE-400", "CWE-399", "CWE-674" ]
oniguruma
4097828d7cc87589864fecf452f2cd46c5f37180
2.08494895941207e+38
13
fix #147: Stack Exhaustion Problem caused by some parsing functions in regcomp.c making recursive calls to themselves.
0
gpk_erase_card(sc_card_t *card) { struct gpk_private_data *priv = DRVDATA(card); sc_apdu_t apdu; u8 offset; int r; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); switch (card->type) { case SC_CARD_TYPE_GPK_GPK4000_su256: case SC_CARD_TYPE_GPK_GPK4000_sdo: offset = 0x6B; /* courtesy gemplus hotline */ break; case SC_CARD_TYPE_GPK_GPK4000_s: offset = 7; break; case SC_CARD_TYPE_GPK_GPK8000: case SC_CARD_TYPE_GPK_GPK8000_8K: case SC_CARD_TYPE_GPK_GPK8000_16K: case SC_CARD_TYPE_GPK_GPK16000: offset = 0; break; default: return SC_ERROR_NOT_SUPPORTED; } memset(&apdu, 0, sizeof(apdu)); apdu.cse = SC_APDU_CASE_1; apdu.cla = 0xDB; apdu.ins = 0xDE; apdu.p2 = offset; r = sc_transmit_apdu(card, &apdu); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); r = sc_check_sw(card, apdu.sw1, apdu.sw2); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Card returned error"); priv->key_set = 0; SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r); }
Safe
[ "CWE-125" ]
OpenSC
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
1.002068117481775e+38
43
fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
0
void queue_for_scrub(PG *pg, bool with_high_priority) { unsigned scrub_queue_priority = pg->scrubber.priority; if (with_high_priority && scrub_queue_priority < cct->_conf->osd_client_op_priority) { scrub_queue_priority = cct->_conf->osd_client_op_priority; } enqueue_back( pg->info.pgid, PGQueueable( PGScrub(pg->get_osdmap()->get_epoch()), cct->_conf->osd_scrub_cost, scrub_queue_priority, ceph_clock_now(), entity_inst_t(), pg->get_osdmap()->get_epoch())); }
Safe
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
2.8223893656253994e+38
15
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <sage@redhat.com> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
0
make_tabpages(int maxcount) { int count = maxcount; int todo; // Limit to 'tabpagemax' tabs. if (count > p_tpm) count = p_tpm; /* * Don't execute autocommands while creating the tab pages. Must do that * when putting the buffers in the windows. */ block_autocmds(); for (todo = count - 1; todo > 0; --todo) if (win_new_tabpage(0) == FAIL) break; unblock_autocmds(); // return actual number of tab pages return (count - todo); }
Safe
[ "CWE-476" ]
vim
0f6e28f686dbb59ab3b562408ab9b2234797b9b1
4.955056719366039e+37
24
patch 8.2.4428: crash when switching tabpage while in the cmdline window Problem: Crash when switching tabpage while in the cmdline window. Solution: Disallow switching tabpage when in the cmdline window.
0
static int n_hdlc_tty_open (struct tty_struct *tty) { struct n_hdlc *n_hdlc = tty2n_hdlc (tty); if (debuglevel >= DEBUG_LEVEL_INFO) printk("%s(%d)n_hdlc_tty_open() called (device=%s)\n", __FILE__,__LINE__, tty->name); /* There should not be an existing table for this slot. */ if (n_hdlc) { printk (KERN_ERR"n_hdlc_tty_open:tty already associated!\n" ); return -EEXIST; } n_hdlc = n_hdlc_alloc(); if (!n_hdlc) { printk (KERN_ERR "n_hdlc_alloc failed\n"); return -ENFILE; } tty->disc_data = n_hdlc; n_hdlc->tty = tty; tty->receive_room = 65536; #if defined(TTY_NO_WRITE_SPLIT) /* change tty_io write() to not split large writes into 8K chunks */ set_bit(TTY_NO_WRITE_SPLIT,&tty->flags); #endif /* flush receive data from driver */ tty_driver_flush_buffer(tty); if (debuglevel >= DEBUG_LEVEL_INFO) printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__); return 0; } /* end of n_tty_hdlc_open() */
Safe
[ "CWE-362" ]
tty
82f2341c94d270421f383641b7cd670e474db56b
2.8742740216763073e+38
39
tty: n_hdlc: get rid of racy n_hdlc.tbuf Currently N_HDLC line discipline uses a self-made singly linked list for data buffers and has n_hdlc.tbuf pointer for buffer retransmitting after an error. The commit be10eb7589337e5defbe214dae038a53dd21add8 ("tty: n_hdlc add buffer flushing") introduced racy access to n_hdlc.tbuf. After tx error concurrent flush_tx_queue() and n_hdlc_send_frames() can put one data buffer to tx_free_buf_list twice. That causes double free in n_hdlc_release(). Let's use standard kernel linked list and get rid of n_hdlc.tbuf: in case of tx error put current data buffer after the head of tx_buf_list. Signed-off-by: Alexander Popov <alex.popov@linux.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0
f_funcref(typval_T *argvars, typval_T *rettv) { common_function(argvars, rettv, TRUE); }
Safe
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
1.7199683438842347e+38
4
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
0
uint get_errcode_from_name(const char *error_name, const char *error_end, st_error *e) { DBUG_ENTER("get_errcode_from_name"); DBUG_PRINT("enter", ("error_name: %s", error_name)); /* Loop through the array of known error names */ for (; e->name; e++) { /* If we get a match, we need to check the length of the name we matched against in case it was longer than what we are checking (as in ER_WRONG_VALUE vs. ER_WRONG_VALUE_COUNT). */ if (!strncmp(error_name, e->name, (int) (error_end - error_name)) && (uint) strlen(e->name) == (uint) (error_end - error_name)) { DBUG_RETURN(e->code); } } DBUG_RETURN(0); }
Safe
[]
server
01b39b7b0730102b88d8ea43ec719a75e9316a1e
3.2133831344700795e+38
22
mysqltest: don't eat new lines in --exec pass them through as is
0
f_pathshorten(typval_T *argvars, typval_T *rettv) { char_u *p; int trim_len = 1; if (in_vim9script() && (check_for_string_arg(argvars, 0) == FAIL || check_for_opt_number_arg(argvars, 1) == FAIL)) return; if (argvars[1].v_type != VAR_UNKNOWN) { trim_len = (int)tv_get_number(&argvars[1]); if (trim_len < 1) trim_len = 1; } rettv->v_type = VAR_STRING; p = tv_get_string_chk(&argvars[0]); if (p == NULL) rettv->vval.v_string = NULL; else { p = vim_strsave(p); rettv->vval.v_string = p; if (p != NULL) shorten_dir_len(p, trim_len); } }
Safe
[ "CWE-823", "CWE-703" ]
vim
5921aeb5741fc6e84c870d68c7c35b93ad0c9f87
3.3440031171644844e+38
30
patch 8.2.4418: crash when using special multi-byte character Problem: Crash when using special multi-byte character. Solution: Don't use isalpha() for an arbitrary character.
0
static void StringStart(enum string_t type) { curr->w_StringType = type; curr->w_stringp = curr->w_string; curr->w_state = ASTR; }
Safe
[ "CWE-119" ]
screen
c336a32a1dcd445e6b83827f83531d4c6414e2cd
1.2447325439525695e+38
6
Fix stack overflow due to too deep recursion Bug: 45713 How to reproduce: Run this command inside screen $ printf '\x1b[10000000T' screen will recursively call MScrollV to depth n/256. This is time consuming and will overflow stack if n is huge.
0
static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, RMDemuxContext *rm, RMStream *vst, AVPacket *pkt, int len, int *pseq, int64_t *timestamp) { int hdr; int seq = 0, pic_num = 0, len2 = 0, pos = 0; //init to silence compiler warning int type; int ret; hdr = avio_r8(pb); len--; type = hdr >> 6; if(type != 3){ // not frame as a part of packet seq = avio_r8(pb); len--; } if(type != 1){ // not whole frame len2 = get_num(pb, &len); pos = get_num(pb, &len); pic_num = avio_r8(pb); len--; } if(len<0) { av_log(s, AV_LOG_ERROR, "Insufficient data\n"); return -1; } rm->remaining_len = len; if(type&1){ // frame, not slice if(type == 3){ // frame as a part of packet len= len2; *timestamp = pos; } if(rm->remaining_len < len) { av_log(s, AV_LOG_ERROR, "Insufficient remaining len\n"); return -1; } rm->remaining_len -= len; if(av_new_packet(pkt, len + 9) < 0) return AVERROR(EIO); pkt->data[0] = 0; AV_WL32(pkt->data + 1, 1); AV_WL32(pkt->data + 5, 0); if ((ret = avio_read(pb, pkt->data + 9, len)) != len) { av_packet_unref(pkt); av_log(s, AV_LOG_ERROR, "Failed to read %d bytes\n", len); return ret < 0 ? ret : AVERROR(EIO); } return 0; } //now we have to deal with single slice *pseq = seq; if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){ if (len2 > ffio_limit(pb, len2)) { av_log(s, AV_LOG_ERROR, "Impossibly sized packet\n"); return AVERROR_INVALIDDATA; } vst->slices = ((hdr & 0x3F) << 1) + 1; vst->videobufsize = len2 + 8*vst->slices + 1; av_packet_unref(&vst->pkt); //FIXME this should be output. if(av_new_packet(&vst->pkt, vst->videobufsize) < 0) return AVERROR(ENOMEM); memset(vst->pkt.data, 0, vst->pkt.size); vst->videobufpos = 8*vst->slices + 1; vst->cur_slice = 0; vst->curpic_num = pic_num; vst->pktpos = avio_tell(pb); } if(type == 2) len = FFMIN(len, pos); if(++vst->cur_slice > vst->slices) { av_log(s, AV_LOG_ERROR, "cur slice %d, too large\n", vst->cur_slice); return 1; } if(!vst->pkt.data) return AVERROR(ENOMEM); AV_WL32(vst->pkt.data - 7 + 8*vst->cur_slice, 1); AV_WL32(vst->pkt.data - 3 + 8*vst->cur_slice, vst->videobufpos - 8*vst->slices - 1); if(vst->videobufpos + len > vst->videobufsize) { av_log(s, AV_LOG_ERROR, "outside videobufsize\n"); return 1; } if (avio_read(pb, vst->pkt.data + vst->videobufpos, len) != len) return AVERROR(EIO); vst->videobufpos += len; rm->remaining_len-= len; if (type == 2 || vst->videobufpos == vst->videobufsize) { vst->pkt.data[0] = vst->cur_slice-1; *pkt= vst->pkt; vst->pkt.data= NULL; vst->pkt.size= 0; vst->pkt.buf = NULL; if(vst->slices != vst->cur_slice) //FIXME find out how to set slices correct from the begin memmove(pkt->data + 1 + 8*vst->cur_slice, pkt->data + 1 + 8*vst->slices, vst->videobufpos - 1 - 8*vst->slices); pkt->size = vst->videobufpos + 8*(vst->cur_slice - vst->slices); pkt->pts = AV_NOPTS_VALUE; pkt->pos = vst->pktpos; vst->slices = 0; return 0; } return 1; }
Safe
[ "CWE-399", "CWE-834" ]
FFmpeg
124eb202e70678539544f6268efc98131f19fa49
2.8890641961995618e+38
105
avformat/rmdec: Fix DoS due to lack of eof check Fixes: loop.ivr Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
0
int mutt_socket_open(struct Connection *conn) { int rc; if (socket_preconnect()) return -1; rc = conn->open(conn); mutt_debug(LL_DEBUG2, "Connected to %s:%d on fd=%d\n", conn->account.host, conn->account.port, conn->fd); return rc; }
Safe
[ "CWE-94", "CWE-74" ]
neomutt
fb013ec666759cb8a9e294347c7b4c1f597639cc
2.6841435298428346e+38
14
tls: clear data after a starttls acknowledgement After a starttls acknowledgement message, clear the buffers of any incoming data / commands. This will ensure that all future data is handled securely. Co-authored-by: Pietro Cerutti <gahr@gahr.ch>
0
static int relocating_repair_kthread(void *data) { struct btrfs_block_group *cache = (struct btrfs_block_group *)data; struct btrfs_fs_info *fs_info = cache->fs_info; u64 target; int ret = 0; target = cache->start; btrfs_put_block_group(cache); if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) { btrfs_info(fs_info, "zoned: skip relocating block group %llu to repair: EBUSY", target); return -EBUSY; } mutex_lock(&fs_info->reclaim_bgs_lock); /* Ensure block group still exists */ cache = btrfs_lookup_block_group(fs_info, target); if (!cache) goto out; if (!cache->relocating_repair) goto out; ret = btrfs_may_alloc_data_chunk(fs_info, target); if (ret < 0) goto out; btrfs_info(fs_info, "zoned: relocating block group %llu to repair IO failure", target); ret = btrfs_relocate_chunk(fs_info, target); out: if (cache) btrfs_put_block_group(cache); mutex_unlock(&fs_info->reclaim_bgs_lock); btrfs_exclop_finish(fs_info); return ret; }
Safe
[ "CWE-476", "CWE-703" ]
linux
e4571b8c5e9ffa1e85c0c671995bd4dcc5c75091
3.3162804126113264e+38
44
btrfs: fix NULL pointer dereference when deleting device by invalid id [BUG] It's easy to trigger NULL pointer dereference, just by removing a non-existing device id: # mkfs.btrfs -f -m single -d single /dev/test/scratch1 \ /dev/test/scratch2 # mount /dev/test/scratch1 /mnt/btrfs # btrfs device remove 3 /mnt/btrfs Then we have the following kernel NULL pointer dereference: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 9 PID: 649 Comm: btrfs Not tainted 5.14.0-rc3-custom+ #35 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:btrfs_rm_device+0x4de/0x6b0 [btrfs] btrfs_ioctl+0x18bb/0x3190 [btrfs] ? lock_is_held_type+0xa5/0x120 ? find_held_lock.constprop.0+0x2b/0x80 ? do_user_addr_fault+0x201/0x6a0 ? lock_release+0xd2/0x2d0 ? __x64_sys_ioctl+0x83/0xb0 __x64_sys_ioctl+0x83/0xb0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae [CAUSE] Commit a27a94c2b0c7 ("btrfs: Make btrfs_find_device_by_devspec return btrfs_device directly") moves the "missing" device path check into btrfs_rm_device(). But btrfs_rm_device() itself can have case where it only receives @devid, with NULL as @device_path. In that case, calling strcmp() on NULL will trigger the NULL pointer dereference. Before that commit, we handle the "missing" case inside btrfs_find_device_by_devspec(), which will not check @device_path at all if @devid is provided, thus no way to trigger the bug. [FIX] Before calling strcmp(), also make sure @device_path is not NULL. Fixes: a27a94c2b0c7 ("btrfs: Make btrfs_find_device_by_devspec return btrfs_device directly") CC: stable@vger.kernel.org # 5.4+ Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
0
void CLASS Canon_CameraSettings() { fseek(ifp, 10, SEEK_CUR); imgdata.shootinginfo.DriveMode = get2(); get2(); imgdata.shootinginfo.FocusMode = get2(); fseek(ifp, 18, SEEK_CUR); imgdata.shootinginfo.MeteringMode = get2(); get2(); imgdata.shootinginfo.AFPoint = get2(); imgdata.shootinginfo.ExposureMode = get2(); get2(); imgdata.lens.makernotes.LensID = get2(); imgdata.lens.makernotes.MaxFocal = get2(); imgdata.lens.makernotes.MinFocal = get2(); imgdata.lens.makernotes.CanonFocalUnits = get2(); if (imgdata.lens.makernotes.CanonFocalUnits > 1) { imgdata.lens.makernotes.MaxFocal /= (float)imgdata.lens.makernotes.CanonFocalUnits; imgdata.lens.makernotes.MinFocal /= (float)imgdata.lens.makernotes.CanonFocalUnits; } imgdata.lens.makernotes.MaxAp = _CanonConvertAperture(get2()); imgdata.lens.makernotes.MinAp = _CanonConvertAperture(get2()); fseek(ifp, 12, SEEK_CUR); imgdata.shootinginfo.ImageStabilization = get2(); }
Safe
[ "CWE-400" ]
LibRaw
e67a9862d10ebaa97712f532eca1eb5e2e410a22
5.392810529180092e+37
25
Fixed Secunia Advisory SA86384 - possible infinite loop in unpacked_load_raw() - possible infinite loop in parse_rollei() - possible infinite loop in parse_sinar_ia() Credits: Laurent Delosieres, Secunia Research at Flexera
0
policy_write_item(char *buf, size_t buflen, addr_policy_t *policy, int format_for_desc) { size_t written = 0; char addrbuf[TOR_ADDR_BUF_LEN]; const char *addrpart; int result; const int is_accept = policy->policy_type == ADDR_POLICY_ACCEPT; const int is_ip6 = tor_addr_family(&policy->addr) == AF_INET6; tor_addr_to_str(addrbuf, &policy->addr, sizeof(addrbuf), 1); /* write accept/reject 1.2.3.4 */ if (policy->is_private) addrpart = "private"; else if (policy->maskbits == 0) addrpart = "*"; else addrpart = addrbuf; result = tor_snprintf(buf, buflen, "%s%s%s %s", (is_ip6&&format_for_desc)?"opt ":"", is_accept ? "accept" : "reject", (is_ip6&&format_for_desc)?"6":"", addrpart); if (result < 0) return -1; written += strlen(buf); /* If the maskbits is 32 we don't need to give it. If the mask is 0, * we already wrote "*". */ if (policy->maskbits < 32 && policy->maskbits > 0) { if (tor_snprintf(buf+written, buflen-written, "/%d", policy->maskbits)<0) return -1; written += strlen(buf+written); } if (policy->prt_min <= 1 && policy->prt_max == 65535) { /* There is no port set; write ":*" */ if (written+4 > buflen) return -1; strlcat(buf+written, ":*", buflen-written); written += 2; } else if (policy->prt_min == policy->prt_max) { /* There is only one port; write ":80". */ result = tor_snprintf(buf+written, buflen-written, ":%d", policy->prt_min); if (result<0) return -1; written += result; } else { /* There is a range of ports; write ":79-80". */ result = tor_snprintf(buf+written, buflen-written, ":%d-%d", policy->prt_min, policy->prt_max); if (result<0) return -1; written += result; } if (written < buflen) buf[written] = '\0'; else return -1; return (int)written; }
Safe
[ "CWE-119" ]
tor
43414eb98821d3b5c6c65181d7545ce938f82c8e
3.193764928099895e+38
62
Fix bounds-checking in policy_summarize Found by piebeer.
0
append_with_tabs(StringInfo buf, const char *str) { char ch; while ((ch = *str++) != '\0') { appendStringInfoCharMacro(buf, ch); if (ch == '\n') appendStringInfoCharMacro(buf, '\t'); } }
Safe
[ "CWE-89" ]
postgres
2b3a8b20c2da9f39ffecae25ab7c66974fbc0d3b
6.790825325861957e+37
11
Be more careful to not lose sync in the FE/BE protocol. If any error occurred while we were in the middle of reading a protocol message from the client, we could lose sync, and incorrectly try to interpret a part of another message as a new protocol message. That will usually lead to an "invalid frontend message" error that terminates the connection. However, this is a security issue because an attacker might be able to deliberately cause an error, inject a Query message in what's supposed to be just user data, and have the server execute it. We were quite careful to not have CHECK_FOR_INTERRUPTS() calls or other operations that could ereport(ERROR) in the middle of processing a message, but a query cancel interrupt or statement timeout could nevertheless cause it to happen. Also, the V2 fastpath and COPY handling were not so careful. It's very difficult to recover in the V2 COPY protocol, so we will just terminate the connection on error. In practice, that's what happened previously anyway, as we lost protocol sync. To fix, add a new variable in pqcomm.c, PqCommReadingMsg, that is set whenever we're in the middle of reading a message. When it's set, we cannot safely ERROR out and continue running, because we might've read only part of a message. PqCommReadingMsg acts somewhat similarly to critical sections in that if an error occurs while it's set, the error handler will force the connection to be terminated, as if the error was FATAL. It's not implemented by promoting ERROR to FATAL in elog.c, like ERROR is promoted to PANIC in critical sections, because we want to be able to use PG_TRY/CATCH to recover and regain protocol sync. pq_getmessage() takes advantage of that to prevent an OOM error from terminating the connection. To prevent unnecessary connection terminations, add a holdoff mechanism similar to HOLD/RESUME_INTERRUPTS() that can be used hold off query cancel interrupts, but still allow die interrupts. The rules on which interrupts are processed when are now a bit more complicated, so refactor ProcessInterrupts() and the calls to it in signal handlers so that the signal handlers always call it if ImmediateInterruptOK is set, and ProcessInterrupts() can decide to not do anything if the other conditions are not met. Reported by Emil Lenngren. Patch reviewed by Noah Misch and Andres Freund. Backpatch to all supported versions. Security: CVE-2015-0244
0
_XimProtoGetICValues( XIC xic, XIMArg *arg) { Xic ic = (Xic)xic; Xim im = (Xim)ic->core.im; register XIMArg *p; register XIMArg *pp; register int n; CARD8 *buf; CARD16 *buf_s; INT16 len; CARD32 reply32[BUFSIZE/4]; char *reply = (char *)reply32; XPointer preply = NULL; int buf_size; int ret_code; char *makeid_name; char *decode_name; CARD16 *data = NULL; INT16 data_len = 0; #ifndef XIM_CONNECTABLE if (!IS_IC_CONNECTED(ic)) return arg->name; #else if (!IS_IC_CONNECTED(ic)) { if (IS_CONNECTABLE(im)) { if (_XimConnectServer(im)) { if (!_XimReCreateIC(ic)) { _XimDelayModeSetAttr(im); return _XimDelayModeGetICValues(ic, arg); } } else { return _XimDelayModeGetICValues(ic, arg); } } else { return arg->name; } } #endif /* XIM_CONNECTABLE */ for (n = 0, p = arg; p && p->name; p++) { n++; if ((strcmp(p->name, XNPreeditAttributes) == 0) || (strcmp(p->name, XNStatusAttributes) == 0)) { n++; for (pp = (XIMArg *)p->value; pp && pp->name; pp++) n++; } } if (!n) return (char *)NULL; buf_size = sizeof(CARD16) * n; buf_size += XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(CARD16) + sizeof(INT16) + XIM_PAD(2 + buf_size); if (!(buf = Xcalloc(buf_size, 1))) return arg->name; buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE]; makeid_name = _XimMakeICAttrIDList(ic, ic->private.proto.ic_resources, ic->private.proto.ic_num_resources, arg, &buf_s[3], &len, XIM_GETICVALUES); if (len > 0) { buf_s[0] = im->private.proto.imid; /* imid */ buf_s[1] = ic->private.proto.icid; /* icid */ buf_s[2] = len; /* length of ic-attr-id */ len += sizeof(INT16); /* sizeof length of attr */ XIM_SET_PAD(&buf_s[2], len); /* pad */ len += sizeof(CARD16) /* sizeof imid */ + sizeof(CARD16); /* sizeof icid */ _XimSetHeader((XPointer)buf, XIM_GET_IC_VALUES, 0, &len); if (!(_XimWrite(im, len, (XPointer)buf))) { Xfree(buf); return arg->name; } _XimFlush(im); Xfree(buf); buf_size = BUFSIZE; ret_code = _XimRead(im, &len, (XPointer)reply, buf_size, _XimGetICValuesCheck, (XPointer)ic); if (ret_code == XIM_TRUE) { preply = reply; } else if (ret_code == XIM_OVERFLOW) { if (len <= 0) { preply = reply; } else { buf_size = (int)len; preply = Xmalloc(len); ret_code = _XimRead(im, &len, preply, buf_size, _XimGetICValuesCheck, (XPointer)ic); if (ret_code != XIM_TRUE) { if (preply != reply) Xfree(preply); return arg->name; } } } else { return arg->name; } buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE); if (*((CARD8 *)preply) == XIM_ERROR) { _XimProcError(im, 0, (XPointer)&buf_s[3]); if (reply != preply) Xfree(preply); return arg->name; } data = &buf_s[4]; data_len = buf_s[2]; } else if (len < 0) { return arg->name; } decode_name = _XimDecodeICATTRIBUTE(ic, ic->private.proto.ic_resources, ic->private.proto.ic_num_resources, data, data_len, arg, XIM_GETICVALUES); if (reply != preply) Xfree(preply); if (decode_name) return decode_name; else return makeid_name; }
Safe
[ "CWE-190" ]
libx11
1a566c9e00e5f35c1f9e7f3d741a02e5170852b2
1.2931140264956524e+38
133
Zero out buffers in functions It looks like uninitialized stack or heap memory can leak out via padding bytes. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
0
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, Field **default_field, bool group, bool modify_item, bool table_cant_handle_bit_fields, bool make_copy_field) { Field *result; Item::Type orig_type= type; Item *orig_item= 0; if (type != Item::FIELD_ITEM && item->real_item()->type() == Item::FIELD_ITEM) { orig_item= item; item= item->real_item(); type= Item::FIELD_ITEM; } switch (type) { case Item::SUM_FUNC_ITEM: { result= item->create_tmp_field(group, table); if (!result) my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR)); return result; } case Item::FIELD_ITEM: case Item::DEFAULT_VALUE_ITEM: case Item::INSERT_VALUE_ITEM: case Item::TRIGGER_FIELD_ITEM: { Item_field *field= (Item_field*) item; bool orig_modify= modify_item; if (orig_type == Item::REF_ITEM) modify_item= 0; /* If item have to be able to store NULLs but underlaid field can't do it, create_tmp_field_from_field() can't be used for tmp field creation. */ if (((field->maybe_null && field->in_rollup) || (thd->create_tmp_table_for_derived && /* for mat. view/dt */ orig_item && orig_item->maybe_null)) && !field->field->maybe_null()) { bool save_maybe_null= FALSE; /* The item the ref points to may have maybe_null flag set while the ref doesn't have it. This may happen for outer fields when the outer query decided at some point after name resolution phase that this field might be null. Take this into account here. */ if (orig_item) { save_maybe_null= item->maybe_null; item->maybe_null= orig_item->maybe_null; } result= create_tmp_field_from_item(thd, item, table, NULL, modify_item); *from_field= field->field; if (result && modify_item) field->result_field= result; if (orig_item) item->maybe_null= save_maybe_null; } else if (table_cant_handle_bit_fields && field->field->type() == MYSQL_TYPE_BIT) { *from_field= field->field; result= create_tmp_field_from_item(thd, item, table, copy_func, modify_item); if (result && modify_item) field->result_field= result; } else result= create_tmp_field_from_field(thd, (*from_field= field->field), orig_item ? orig_item->name : item->name, table, modify_item ? field : NULL); if (orig_type == Item::REF_ITEM && orig_modify) ((Item_ref*)orig_item)->set_result_field(result); /* Fields that are used as arguments to the DEFAULT() function already have their data pointers set to the default value during name resolution. See Item_default_value::fix_fields. */ if (orig_type != Item::DEFAULT_VALUE_ITEM && field->field->eq_def(result)) *default_field= field->field; return result; } /* Fall through */ case Item::FUNC_ITEM: if (((Item_func *) item)->functype() == Item_func::FUNC_SP) { Item_func_sp *item_func_sp= (Item_func_sp *) item; Field *sp_result_field= item_func_sp->get_sp_result_field(); if (make_copy_field) { DBUG_ASSERT(item_func_sp->result_field); *from_field= item_func_sp->result_field; } else { *((*copy_func)++)= item; } Field *result_field= create_tmp_field_from_field(thd, sp_result_field, item_func_sp->name, table, NULL); if (modify_item) item->set_result_field(result_field); return result_field; } /* Fall through */ case Item::COND_ITEM: case Item::SUBSELECT_ITEM: case Item::REF_ITEM: case Item::EXPR_CACHE_ITEM: if (make_copy_field) { DBUG_ASSERT(((Item_result_field*)item)->result_field); *from_field= ((Item_result_field*)item)->result_field; } /* Fall through */ case Item::FIELD_AVG_ITEM: case Item::FIELD_STD_ITEM: case Item::PROC_ITEM: case Item::INT_ITEM: case Item::REAL_ITEM: case Item::DECIMAL_ITEM: case Item::STRING_ITEM: case Item::DATE_ITEM: case Item::NULL_ITEM: case Item::VARBIN_ITEM: case Item::CACHE_ITEM: case Item::WINDOW_FUNC_ITEM: // psergey-winfunc: case Item::PARAM_ITEM: return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 : copy_func), modify_item); case Item::TYPE_HOLDER: result= ((Item_type_holder *)item)->make_field_by_type(table); result->set_derivation(item->collation.derivation, item->collation.repertoire); return result; default: // Dosen't have to be stored return 0; } }
Safe
[ "CWE-89" ]
server
5ba77222e9fe7af8ff403816b5338b18b342053c
8.243823655399187e+37
158
MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view if the view has algorithm=temptable it is not updatable, so DEFAULT() for its fields is meaningless, and thus it's NULL or 0/'' for NOT NULL columns.
0
struct page *dma_alloc_from_contiguous(struct device *dev, int count, unsigned int align) { if (align > CONFIG_CMA_ALIGNMENT) align = CONFIG_CMA_ALIGNMENT; return cma_alloc(dev_get_cma_area(dev), count, align); }
Vulnerable
[ "CWE-682" ]
linux
67a2e213e7e937c41c52ab5bc46bf3f4de469f6e
1.0752448708989794e+38
8
mm: cma: fix incorrect type conversion for size during dma allocation This was found during userspace fuzzing test when a large size dma cma allocation is made by driver(like ion) through userspace. show_stack+0x10/0x1c dump_stack+0x74/0xc8 kasan_report_error+0x2b0/0x408 kasan_report+0x34/0x40 __asan_storeN+0x15c/0x168 memset+0x20/0x44 __dma_alloc_coherent+0x114/0x18c Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1
static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) { unsigned bio_bytes = bio_cur_bytes(bio); char *data = bio_data(bio); /* * Overwrite the Nth byte of the data returned. */ if (data && bio_bytes >= fc->corrupt_bio_byte) { data[fc->corrupt_bio_byte - 1] = fc->corrupt_bio_value; DMDEBUG("Corrupting data bio=%p by writing %u to byte %u " "(rw=%c bi_rw=%lu bi_sector=%llu cur_bytes=%u)\n", bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, (bio_data_dir(bio) == WRITE) ? 'w' : 'r', bio->bi_rw, (unsigned long long)bio->bi_sector, bio_bytes); } }
Safe
[ "CWE-284", "CWE-264" ]
linux
ec8013beddd717d1740cfefb1a9b900deef85462
2.5780998985662415e+38
18
dm: do not forward ioctls from logical volumes to the underlying device A logical volume can map to just part of underlying physical volume. In this case, it must be treated like a partition. Based on a patch from Alasdair G Kergon. Cc: Alasdair G Kergon <agk@redhat.com> Cc: dm-devel@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
directory_fetches_from_authorities(const or_options_t *options) { const routerinfo_t *me; uint32_t addr; int refuseunknown; if (options->FetchDirInfoEarly) return 1; if (options->BridgeRelay == 1) return 0; if (server_mode(options) && router_pick_published_address(options, &addr, 1) < 0) return 1; /* we don't know our IP address; ask an authority. */ refuseunknown = ! router_my_exit_policy_is_reject_star() && should_refuse_unknown_exits(options); if (!dir_server_mode(options) && !refuseunknown) return 0; if (!server_mode(options) || !advertised_server_mode()) return 0; me = router_get_my_routerinfo(); if (!me || (!me->supports_tunnelled_dir_requests && !refuseunknown)) return 0; /* if we don't service directory requests, return 0 too */ return 1; }
Safe
[]
tor
02e05bd74dbec614397b696cfcda6525562a4675
1.2688119741569282e+38
23
When examining descriptors as a dirserver, reject ones with bad versions This is an extra fix for bug 21278: it ensures that these descriptors and platforms will never be listed in a legit consensus.
0
static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l) { php_stream * stream = (php_stream *)ctx->data; TSRMLS_FETCH(); return php_stream_write(stream, (void *)buf, l); }
Safe
[ "CWE-20" ]
php-src
1daa4c0090b7cd8178dcaa96287234c69ac6ca18
1.1163073542776465e+38
6
Fix bug #67730 - Null byte injection possible with imagexxx functions
0
int main(int argc, char **argv) { int i, n_valid, do_write, do_scrub; char *c, *dname, *name; DIR *dir; FILE *fp; pdf_t *pdf; pdf_flag_t flags; if (argc < 2) usage(); /* Args */ do_write = do_scrub = flags = 0; name = NULL; for (i=1; i<argc; i++) { if (strncmp(argv[i], "-w", 2) == 0) do_write = 1; else if (strncmp(argv[i], "-i", 2) == 0) flags |= PDF_FLAG_DISP_CREATOR; else if (strncmp(argv[i], "-q", 2) == 0) flags |= PDF_FLAG_QUIET; else if (strncmp(argv[i], "-s", 2) == 0) do_scrub = 1; else if (argv[i][0] != '-') name = argv[i]; else if (argv[i][0] == '-') usage(); } if (!name) usage(); if (!(fp = fopen(name, "r"))) { ERR("Could not open file '%s'\n", argv[1]); return -1; } else if (!pdf_is_pdf(fp)) { ERR("'%s' specified is not a valid PDF\n", name); fclose(fp); return -1; } /* Load PDF */ if (!(pdf = init_pdf(fp, name))) { fclose(fp); return -1; } /* Count valid xrefs */ for (i=0, n_valid=0; i<pdf->n_xrefs; i++) if (pdf->xrefs[i].version) ++n_valid; /* Bail if we only have 1 valid */ if (n_valid < 2) { if (!(flags & (PDF_FLAG_QUIET | PDF_FLAG_DISP_CREATOR))) printf("%s: There is only one version of this PDF\n", pdf->name); if (do_write) { fclose(fp); pdf_delete(pdf); return 0; } } dname = NULL; if (do_write) { /* Create directory to place the various versions in */ if ((c = strrchr(name, '/'))) name = c + 1; if ((c = strrchr(name, '.'))) *c = '\0'; dname = safe_calloc(strlen(name) + 16); sprintf(dname, "%s-versions", name); if (!(dir = opendir(dname))) mkdir(dname, S_IRWXU); else { ERR("This directory already exists, PDF version extraction will " "not occur.\n"); fclose(fp); closedir(dir); free(dname); pdf_delete(pdf); return -1; } /* Write the pdf as a pervious version */ for (i=0; i<pdf->n_xrefs; i++) if (pdf->xrefs[i].version) write_version(fp, name, dname, &pdf->xrefs[i]); } /* Generate a per-object summary */ pdf_summarize(fp, pdf, dname, flags); /* Have we been summoned to scrub history from this PDF */ if (do_scrub) scrub_document(fp, pdf); /* Display extra information */ if (flags & PDF_FLAG_DISP_CREATOR) display_creator(fp, pdf); fclose(fp); free(dname); pdf_delete(pdf); return 0; }
Safe
[ "CWE-787" ]
pdfresurrect
0c4120fffa3dffe97b95c486a120eded82afe8a6
1.1828992764287029e+38
120
Zero and sanity check all dynamic allocs. This addresses the memory issues in Issue #6 expressed in calloc_some.pdf and malloc_some.pdf
0
Error Box_idat::read_data(std::shared_ptr<StreamReader> istr, uint64_t start, uint64_t length, std::vector<uint8_t>& out_data) const { // --- security check that we do not allocate too much data auto curr_size = out_data.size(); if (MAX_MEMORY_BLOCK_SIZE - curr_size < length) { std::stringstream sstr; sstr << "idat box contained " << length << " bytes, total memory size would be " << (curr_size + length) << " bytes, exceeding the security limit of " << MAX_MEMORY_BLOCK_SIZE << " bytes"; return Error(heif_error_Memory_allocation_error, heif_suberror_Security_limit_exceeded, sstr.str()); } // move to start of data if (start > (uint64_t)m_data_start_pos + get_box_size()) { return Error(heif_error_Invalid_input, heif_suberror_End_of_data); } else if (length > get_box_size() || start + length > get_box_size()) { return Error(heif_error_Invalid_input, heif_suberror_End_of_data); } StreamReader::grow_status status = istr->wait_for_file_size((int64_t)m_data_start_pos + start + length); if (status == StreamReader::size_beyond_eof || status == StreamReader::timeout) { // TODO: maybe we should introduce some 'Recoverable error' instead of 'Invalid input' return Error(heif_error_Invalid_input, heif_suberror_End_of_data); } bool success; success = istr->seek(m_data_start_pos + (std::streampos)start); assert(success); (void)success; // reserve space for the data in the output array out_data.resize(static_cast<size_t>(curr_size + length)); uint8_t* data = &out_data[curr_size]; success = istr->read((char*)data, static_cast<size_t>(length)); assert(success); return Error::Ok; }
Safe
[ "CWE-703" ]
libheif
2710c930918609caaf0a664e9c7bc3dce05d5b58
9.518407090067964e+37
52
force fraction to a limited resolution to finally solve those pesky numerical edge cases
0
smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length, struct kvec *iov, unsigned int minbufsize, char *data) { char *begin_of_buf = offset + (char *)iov->iov_base; int rc; if (!data) return -EINVAL; rc = smb2_validate_iov(offset, buffer_length, iov, minbufsize); if (rc) return rc; memcpy(data, begin_of_buf, buffer_length); return 0; }
Safe
[ "CWE-416", "CWE-200" ]
linux
6a3eb3360667170988f8a6477f6686242061488a
1.1769684492198932e+38
18
cifs: Fix use-after-free in SMB2_write There is a KASAN use-after-free: BUG: KASAN: use-after-free in SMB2_write+0x1342/0x1580 Read of size 8 at addr ffff8880b6a8e450 by task ln/4196 Should not release the 'req' because it will use in the trace. Fixes: eccb4422cf97 ("smb3: Add ftrace tracepoints for improved SMB3 debugging") Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com> Signed-off-by: Steve French <stfrench@microsoft.com> CC: Stable <stable@vger.kernel.org> 4.18+ Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
0
_warc_rdver(const char *buf, size_t bsz) { static const char magic[] = "WARC/"; const char *c; unsigned int ver = 0U; unsigned int end = 0U; if (bsz < 12 || memcmp(buf, magic, sizeof(magic) - 1U) != 0) { /* buffer too small or invalid magic */ return ver; } /* looks good so far, read the version number for a laugh */ buf += sizeof(magic) - 1U; if (isdigit((unsigned char)buf[0U]) && (buf[1U] == '.') && isdigit((unsigned char)buf[2U])) { /* we support a maximum of 2 digits in the minor version */ if (isdigit((unsigned char)buf[3U])) end = 1U; /* set up major version */ ver = (buf[0U] - '0') * 10000U; /* set up minor version */ if (end == 1U) { ver += (buf[2U] - '0') * 1000U; ver += (buf[3U] - '0') * 100U; } else ver += (buf[2U] - '0') * 100U; /* * WARC below version 0.12 has a space-separated header * WARC 0.12 and above terminates the version with a CRLF */ c = buf + 3U + end; if (ver >= 1200U) { if (memcmp(c, "\r\n", 2U) != 0) ver = 0U; } else if (ver < 1200U) { if (*c != ' ' && *c != '\t') ver = 0U; } } return ver; }
Safe
[ "CWE-415", "CWE-787" ]
libarchive
9c84b7426660c09c18cc349f6d70b5f8168b5680
9.826997604906837e+37
42
warc: consume data once read The warc decoder only used read ahead, it wouldn't actually consume data that had previously been printed. This means that if you specify an invalid content length, it will just reprint the same data over and over and over again until it hits the desired length. This means that a WARC resource with e.g. Content-Length: 666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666665 but only a few hundred bytes of data, causes a quasi-infinite loop. Consume data in subsequent calls to _warc_read. Found with an AFL + afl-rb + qsym setup.
0
filter_free (struct backend *b) { struct backend_filter *f = container_of (b, struct backend_filter, backend); b->next->free (b->next); backend_unload (b, f->filter.unload); free (f); }
Safe
[ "CWE-406" ]
nbdkit
a6b88b195a959b17524d1c8353fd425d4891dc5f
2.332656434238034e+38
9
server: Fix regression for NBD_OPT_INFO before NBD_OPT_GO Most known NBD clients do not bother with NBD_OPT_INFO (except for clients like 'qemu-nbd --list' that don't ever intend to connect), but go straight to NBD_OPT_GO. However, it's not too hard to hack up qemu to add in an extra client step (whether info on the same name, or more interestingly, info on a different name), as a patch against qemu commit 6f214b30445: | diff --git i/nbd/client.c w/nbd/client.c | index f6733962b49b..425292ac5ea9 100644 | --- i/nbd/client.c | +++ w/nbd/client.c | @@ -1038,6 +1038,14 @@ int nbd_receive_negotiate(AioContext *aio_context, QIOChannel *ioc, | * TLS). If it is not available, fall back to | * NBD_OPT_LIST for nicer error messages about a missing | * export, then use NBD_OPT_EXPORT_NAME. */ | + if (getenv ("HACK")) | + info->name[0]++; | + result = nbd_opt_info_or_go(ioc, NBD_OPT_INFO, info, errp); | + if (getenv ("HACK")) | + info->name[0]--; | + if (result < 0) { | + return -EINVAL; | + } | result = nbd_opt_info_or_go(ioc, NBD_OPT_GO, info, errp); | if (result < 0) { | return -EINVAL; This works just fine in 1.14.0, where we call .open only once (so the INFO and GO repeat calls into the same plugin handle), but in 1.14.1 it regressed into causing an assertion failure: we are now calling .open a second time on a connection that is already opened: $ nbdkit -rfv null & $ hacked-qemu-io -f raw -r nbd://localhost -c quit ... nbdkit: null[1]: debug: null: open readonly=1 nbdkit: backend.c:179: backend_open: Assertion `h->handle == NULL' failed. Worse, on the mainline development, we have recently made it possible for plugins to actively report different information for different export names; for example, a plugin may choose to report different answers for .can_write on export A than for export B; but if we share cached handles, then an NBD_OPT_INFO on one export prevents correct answers for NBD_OPT_GO on the second export name. (The HACK envvar in my qemu modifications can be used to demonstrate cross-name requests, which are even less likely in a real client). The solution is to call .close after NBD_OPT_INFO, coupled with enough glue logic to reset cached connection handles back to the state expected by .open. This in turn means factoring out another backend_* function, but also gives us an opportunity to change backend_set_handle to no longer accept NULL. The assertion failure is, to some extent, a possible denial of service attack (one client can force nbdkit to exit by merely sending OPT_INFO before OPT_GO, preventing the next client from connecting), although this is mitigated by using TLS to weed out untrusted clients. Still, the fact that we introduced a potential DoS attack while trying to fix a traffic amplification security bug is not very nice. Sadly, as there are no known clients that easily trigger this mode of operation (OPT_INFO before OPT_GO), there is no easy way to cover this via a testsuite addition. I may end up hacking something into libnbd. Fixes: c05686f957 Signed-off-by: Eric Blake <eblake@redhat.com>
0
static int proc_fd_permission(struct inode *inode, int mask) { int rv; rv = generic_permission(inode, mask, NULL); if (rv == 0) return 0; if (task_pid(current) == proc_pid(inode)) rv = 0; return rv; }
Safe
[ "CWE-20", "CWE-362", "CWE-416" ]
linux
86acdca1b63e6890540fa19495cfc708beff3d8b
1.4065995125694404e+38
11
fix autofs/afs/etc. magic mountpoint breakage We end up trying to kfree() nd.last.name on open("/mnt/tmp", O_CREAT) if /mnt/tmp is an autofs direct mount. The reason is that nd.last_type is bogus here; we want LAST_BIND for everything of that kind and we get LAST_NORM left over from finding parent directory. So make sure that it *is* set properly; set to LAST_BIND before doing ->follow_link() - for normal symlinks it will be changed by __vfs_follow_link() and everything else needs it set that way. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
0
void set_ndpi_malloc(void *(*__ndpi_malloc)(size_t size)) { _ndpi_malloc = __ndpi_malloc; }
Safe
[ "CWE-416", "CWE-787" ]
nDPI
6a9f5e4f7c3fd5ddab3e6727b071904d76773952
2.1361931090085187e+38
3
Fixed use after free caused by dangling pointer * This fix also improved RCE Injection detection Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
0
close_pb(PG_FUNCTION_ARGS) { Point *pt = PG_GETARG_POINT_P(0); BOX *box = PG_GETARG_BOX_P(1); LSEG lseg, seg; Point point; double dist, d; if (DatumGetBool(DirectFunctionCall2(on_pb, PointPGetDatum(pt), BoxPGetDatum(box)))) PG_RETURN_POINT_P(pt); /* pairwise check lseg distances */ point.x = box->low.x; point.y = box->high.y; statlseg_construct(&lseg, &box->low, &point); dist = dist_ps_internal(pt, &lseg); statlseg_construct(&seg, &box->high, &point); if ((d = dist_ps_internal(pt, &seg)) < dist) { dist = d; memcpy(&lseg, &seg, sizeof(lseg)); } point.x = box->high.x; point.y = box->low.y; statlseg_construct(&seg, &box->low, &point); if ((d = dist_ps_internal(pt, &seg)) < dist) { dist = d; memcpy(&lseg, &seg, sizeof(lseg)); } statlseg_construct(&seg, &box->high, &point); if ((d = dist_ps_internal(pt, &seg)) < dist) { dist = d; memcpy(&lseg, &seg, sizeof(lseg)); } PG_RETURN_DATUM(DirectFunctionCall2(close_ps, PointPGetDatum(pt), LsegPGetDatum(&lseg))); }
Safe
[ "CWE-703", "CWE-189" ]
postgres
31400a673325147e1205326008e32135a78b4d8a
1.988764183711939e+38
48
Predict integer overflow to avoid buffer overruns. Several functions, mostly type input functions, calculated an allocation size such that the calculation wrapped to a small positive value when arguments implied a sufficiently-large requirement. Writes past the end of the inadvertent small allocation followed shortly thereafter. Coverity identified the path_in() vulnerability; code inspection led to the rest. In passing, add check_stack_depth() to prevent stack overflow in related functions. Back-patch to 8.4 (all supported versions). The non-comment hstore changes touch code that did not exist in 8.4, so that part stops at 9.0. Noah Misch and Heikki Linnakangas, reviewed by Tom Lane. Security: CVE-2014-0064
0
get_name( char * diskname, char * exin, time_t t, int n) { char number[NUM_STR_SIZE]; char *filename; char *ts; ts = get_timestamp_from_time(t); if(n == 0) number[0] = '\0'; else g_snprintf(number, SIZEOF(number), "%03d", n - 1); filename = vstralloc(get_pname(), ".", diskname, ".", ts, number, ".", exin, NULL); amfree(ts); return filename; }
Safe
[ "CWE-264" ]
amanda
4bf5b9b356848da98560ffbb3a07a9cb5c4ea6d7
1.466450866925639e+38
21
* Add a /etc/amanda-security.conf file git-svn-id: https://svn.code.sf.net/p/amanda/code/amanda/branches/3_3@6486 a8d146d6-cc15-0410-8900-af154a0219e0
0
static js_Ast *parameters(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(identifier(J)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(identifier(J)); } return jsP_list(head); }
Safe
[ "CWE-674" ]
mujs
4d45a96e57fbabf00a7378b337d0ddcace6f38c1
7.933097243966195e+37
11
Guard binary expressions from too much recursion.
0
static inline struct crypto_shash *crypto_spawn_shash( struct crypto_shash_spawn *spawn) { return crypto_spawn_tfm2(&spawn->base); }
Safe
[ "CWE-835" ]
linux
ef0579b64e93188710d48667cb5e014926af9f1b
2.1669130225455117e+38
5
crypto: ahash - Fix EINPROGRESS notification callback The ahash API modifies the request's callback function in order to clean up after itself in some corner cases (unaligned final and missing finup). When the request is complete ahash will restore the original callback and everything is fine. However, when the request gets an EBUSY on a full queue, an EINPROGRESS callback is made while the request is still ongoing. In this case the ahash API will incorrectly call its own callback. This patch fixes the problem by creating a temporary request object on the stack which is used to relay EINPROGRESS back to the original completion function. This patch also adds code to preserve the original flags value. Fixes: ab6bf4e5e5e4 ("crypto: hash - Fix the pointer voodoo in...") Cc: <stable@vger.kernel.org> Reported-by: Sabrina Dubroca <sd@queasysnail.net> Tested-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
0
on_reauthenticate (GdmSessionWorker *worker, DBusMessage *message) { if (worker->priv->state != GDM_SESSION_WORKER_STATE_SESSION_STARTED) { g_debug ("GdmSessionWorker: ignoring spurious reauthenticate for user while in state %s", get_state_name (worker->priv->state)); return; } queue_state_change (worker); }
Safe
[]
gdm
c25ef9245be4e0be2126ef3d075df4401949b570
1.8795276117084034e+38
10
Store the face and dmrc files in a cache. Refer to bug #565151.
0
Status requireAuthSchemaVersion26Final(OperationContext* txn, AuthorizationManager* authzManager) { int foundSchemaVersion; Status status = authzManager->getAuthorizationVersion(txn, &foundSchemaVersion); if (!status.isOK()) { return status; } if (foundSchemaVersion < AuthorizationManager::schemaVersion26Final) { return Status(ErrorCodes::AuthSchemaIncompatible, str::stream() << "User and role management commands require auth data to have " << "at least schema version " << AuthorizationManager::schemaVersion26Final << " but found " << foundSchemaVersion); } return writeAuthSchemaVersionIfNeeded(txn, authzManager, foundSchemaVersion); }
Safe
[ "CWE-613" ]
mongo
64d8e9e1b12d16b54d6a592bae8110226c491b4e
8.425020978636349e+37
18
SERVER-38984 Validate unique User ID on UserCache hit (cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
0
void handle_incoming_vpn_data(int sock) { vpn_packet_t pkt; char *hostname; sockaddr_t from; socklen_t fromlen = sizeof(from); node_t *n; pkt.len = recvfrom(listen_socket[sock].udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen); if(pkt.len < 0) { if(!sockwouldblock(sockerrno)) logger(LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno)); return; } sockaddrunmap(&from); /* Some braindead IPv6 implementations do stupid things. */ n = lookup_node_udp(&from); if(!n) { n = try_harder(&from, &pkt); if(n) update_node_udp(n, &from); else ifdebug(PROTOCOL) { hostname = sockaddr2hostname(&from); logger(LOG_WARNING, "Received UDP packet from unknown source %s", hostname); free(hostname); return; } else return; } n->sock = sock; receive_udppacket(n, &pkt); }
Safe
[ "CWE-200", "CWE-119" ]
tinc
17a33dfd95b1a29e90db76414eb9622df9632320
1.6189194366569187e+38
37
Drop packets forwarded via TCP if they are too big (CVE-2013-1428). Normally all requests sent via the meta connections are checked so that they cannot be larger than the input buffer. However, when packets are forwarded via meta connections, they are copied into a packet buffer without checking whether it fits into it. Since the packet buffer is allocated on the stack, this in effect allows an authenticated remote node to cause a stack overflow. This issue was found by Martin Schobert.
0
static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, const struct sctp_association *asoc, struct sctp_chunk *chunk, sctp_cmd_seq_t *commands, struct sctp_association *new_asoc) { sctp_init_chunk_t *peer_init; struct sctp_ulpevent *ev; struct sctp_chunk *repl; /* new_asoc is a brand-new association, so these are not yet * side effects--it is safe to run them here. */ peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type, sctp_source(chunk), peer_init, GFP_ATOMIC)) goto nomem; /* Update the content of current association. */ sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, SCTP_STATE(SCTP_STATE_ESTABLISHED)); SCTP_INC_STATS(SCTP_MIB_CURRESTAB); sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); repl = sctp_make_cookie_ack(new_asoc, chunk); if (!repl) goto nomem; sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); sctp_add_cmd_sf(commands, SCTP_CMD_TRANSMIT, SCTP_NULL()); /* RFC 2960 5.1 Normal Establishment of an Association * * D) IMPLEMENTATION NOTE: An implementation may choose to * send the Communication Up notification to the SCTP user * upon reception of a valid COOKIE ECHO chunk. */ ev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_UP, 0, new_asoc->c.sinit_num_ostreams, new_asoc->c.sinit_max_instreams, GFP_ATOMIC); if (!ev) goto nomem_ev; sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); /* Sockets API Draft Section 5.3.1.6 * When a peer sends a Adaption Layer Indication parameter , SCTP * delivers this notification to inform the application that of the * peers requested adaption layer. */ if (asoc->peer.adaption_ind) { ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC); if (!ev) goto nomem_ev; sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); } return SCTP_DISPOSITION_CONSUME; nomem_ev: sctp_chunk_free(repl); nomem: return SCTP_DISPOSITION_NOMEM; }
Safe
[]
linux-2.6
7c3ceb4fb9667f34f1599a062efecf4cdc4a4ce5
8.490218778913392e+37
69
[SCTP]: Allow spillover of receive buffer to avoid deadlock. This patch fixes a deadlock situation in the receive path by allowing temporary spillover of the receive buffer. - If the chunk we receive has a tsn that immediately follows the ctsn, accept it even if we run out of receive buffer space and renege data with higher TSNs. - Once we accept one chunk in a packet, accept all the remaining chunks even if we run out of receive buffer space. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Mark Butler <butlerm@middle.net> Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) { const struct cred *cred = current_cred(); if (!strncmp(name, XATTR_SECURITY_PREFIX, sizeof XATTR_SECURITY_PREFIX - 1)) { if (!strcmp(name, XATTR_NAME_CAPS)) { if (!capable(CAP_SETFCAP)) return -EPERM; } else if (!capable(CAP_SYS_ADMIN)) { /* A different attribute in the security namespace. Restrict to administrator. */ return -EPERM; } } /* Not an attribute we recognize, so just check the ordinary setattr permission. */ return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR); }
Safe
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
3.2928124167015008e+38
20
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
0
WebContents::GetAllSharedWorkers() { std::vector<scoped_refptr<content::DevToolsAgentHost>> shared_workers; if (type_ == Type::REMOTE) return shared_workers; if (!enable_devtools_) return shared_workers; for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) { if (agent_host->GetType() == content::DevToolsAgentHost::kTypeSharedWorker) { shared_workers.push_back(agent_host); } } return shared_workers; }
Safe
[ "CWE-284", "CWE-693" ]
electron
18613925610ba319da7f497b6deed85ad712c59b
3.3992795382905614e+38
17
refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25108) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25065) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL * spec: add test for x-site _top navigation * chore: old code be old
0
proto_register_usb_hid(void) { static hf_register_info hf[] = { { &hf_usb_hid_item_bSize, { "bSize", "usbhid.item.bSize", FT_UINT8, BASE_DEC, VALS(usb_hid_item_bSize_vals), USBHID_SIZE_MASK, NULL, HFILL }}, { &hf_usb_hid_item_bType, { "bType", "usbhid.item.bType", FT_UINT8, BASE_DEC, VALS(usb_hid_item_bType_vals), USBHID_TYPE_MASK, NULL, HFILL }}, { &hf_usb_hid_mainitem_bTag, { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX, VALS(usb_hid_mainitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }}, { &hf_usb_hid_globalitem_bTag, { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX, VALS(usb_hid_globalitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }}, { &hf_usb_hid_localitem_bTag, { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX, VALS(usb_hid_localitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }}, { &hf_usb_hid_longitem_bTag, { "bTag", "usbhid.item.bTag", FT_UINT8, BASE_HEX, VALS(usb_hid_longitem_bTag_vals), USBHID_TAG_MASK, NULL, HFILL }}, { &hf_usb_hid_item_bDataSize, { "bDataSize", "usbhid.item.bDataSize", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_item_bLongItemTag, { "bTag", "usbhid.item.bLongItemTag", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, /* Main-report item data */ { &hf_usb_hid_mainitem_bit0, { "Data/constant", "usbhid.item.main.readonly", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit0), 1<<0, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit1, { "Data type", "usbhid.item.main.variable", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit1), 1<<1, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit2, { "Coordinates", "usbhid.item.main.relative", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit2), 1<<2, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit3, { "Min/max wraparound", "usbhid.item.main.wrap", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit3), 1<<3, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit4, { "Physical relationship to data", "usbhid.item.main.nonlinear", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit4), 1<<4, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit5, { "Preferred state", "usbhid.item.main.no_preferred_state", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit5), 1<<5, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit6, { "Has null position", "usbhid.item.main.nullstate", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit6), 1<<6, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit7, { "(Non)-volatile", "usbhid.item.main.volatile", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit7), 1<<7, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit7_input, { "[Reserved]", "usbhid.item.main.volatile", FT_BOOLEAN, 9, NULL, 1<<7, NULL, HFILL }}, { &hf_usb_hid_mainitem_bit8, { "Bits or bytes", "usbhid.item.main.buffered_bytes", FT_BOOLEAN, 9, TFS(&tfs_mainitem_bit8), 1<<8, NULL, HFILL }}, { &hf_usb_hid_mainitem_colltype, { "Collection type", "usbhid.item.main.colltype", FT_UINT8, BASE_RANGE_STRING|BASE_HEX, RVALS(usb_hid_mainitem_colltype_vals), 0, NULL, HFILL }}, /* Global-report item data */ { &hf_usb_hid_globalitem_usage, { "Usage page", "usbhid.item.global.usage", FT_UINT8, BASE_RANGE_STRING|BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_log_min, { "Logical minimum", "usbhid.item.global.log_min", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_log_max, { "Logical maximum", "usbhid.item.global.log_max", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_phy_min, { "Physical minimum", "usbhid.item.global.phy_min", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_phy_max, { "Physical maximum", "usbhid.item.global.phy_max", FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_exp, { "Unit exponent", "usbhid.item.global.unit_exp", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_sys, { "System", "usbhid.item.global.unit.system", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x0000000F, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_len, { "Length", "usbhid.item.global.unit.length", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x000000F0, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_mass, { "Mass", "usbhid.item.global.unit.mass", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x00000F00, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_time, { "Time", "usbhid.item.global.unit.time", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x0000F000, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_temp, { "Temperature", "usbhid.item.global.unit.temperature", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x000F0000, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_current, { "Current", "usbhid.item.global.unit.current", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x00F00000, NULL, HFILL }}, { &hf_usb_hid_globalitem_unit_brightness, { "Luminous intensity", "usbhid.item.global.unit.brightness", FT_UINT32, BASE_HEX, VALS(usb_hid_globalitem_unit_exp_vals), 0x0F000000, NULL, HFILL }}, { &hf_usb_hid_globalitem_report_size, { "Report size", "usbhid.item.global.report_size", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_report_id, { "Report ID", "usbhid.item.global.report_id", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_report_count, { "Report count", "usbhid.item.global.report_count", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_push, { "Push", "usbhid.item.global.push", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_globalitem_pop, { "Pop", "usbhid.item.global.pop", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, /* Local-report item data */ { &hf_usb_hid_localitem_usage, { "Usage", "usbhid.item.local.usage", FT_UINT8, BASE_RANGE_STRING|BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_usage_min, { "Usage minimum", "usbhid.item.local.usage_min", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, #if 0 { &hf_usb_hid_localitem_usage_max, { "Usage maximum", "usbhid.item.local.usage_max", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, #endif { &hf_usb_hid_localitem_desig_index, { "Designator index", "usbhid.item.local.desig_index", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_desig_min, { "Designator minimum", "usbhid.item.local.desig_min", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_desig_max, { "Designator maximum", "usbhid.item.local.desig_max", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_string_index, { "String index", "usbhid.item.local.string_index", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_string_min, { "String minimum", "usbhid.item.local.string_min", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_string_max, { "String maximum", "usbhid.item.local.string_max", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_localitem_delimiter, { "Delimiter", "usbhid.item.local.delimiter", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }}, { &hf_usb_hid_item_unk_data, { "Item data", "usbhid.item.data", FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }}, /* USB HID specific requests */ { &hf_usb_hid_request, { "bRequest", "usbhid.setup.bRequest", FT_UINT8, BASE_HEX, VALS(setup_request_names_vals), 0x0, NULL, HFILL }}, { &hf_usb_hid_value, { "wValue", "usbhid.setup.wValue", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_index, { "wIndex", "usbhid.setup.wIndex", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_length, { "wLength", "usbhid.setup.wLength", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_report_type, { "ReportType", "usbhid.setup.ReportType", FT_UINT8, BASE_DEC, VALS(usb_hid_report_type_vals), 0x0, NULL, HFILL }}, { &hf_usb_hid_report_id, { "ReportID", "usbhid.setup.ReportID", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_duration, { "Duration", "usbhid.setup.Duration", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_zero, { "(zero)", "usbhid.setup.zero", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, /* components of the HID descriptor */ { &hf_usb_hid_bcdHID, { "bcdHID", "usbhid.descriptor.hid.bcdHID", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_bCountryCode, { "bCountryCode", "usbhid.descriptor.hid.bCountryCode", FT_UINT8, BASE_HEX, VALS(hid_country_code_vals), 0x0, NULL, HFILL }}, { &hf_usb_hid_bNumDescriptors, { "bNumDescriptors", "usbhid.descriptor.hid.bNumDescriptors", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_bDescriptorIndex, { "bDescriptorIndex", "usbhid.descriptor.hid.bDescriptorIndex", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_bDescriptorType, { "bDescriptorType", "usbhid.descriptor.hid.bDescriptorType", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &hid_descriptor_type_vals_ext, 0x00, NULL, HFILL }}, { &hf_usb_hid_wInterfaceNumber, { "wInterfaceNumber", "usbhid.descriptor.hid.wInterfaceNumber", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usb_hid_wDescriptorLength, { "wDescriptorLength", "usbhid.descriptor.hid.wDescriptorLength", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_reserved, { "Reserved", "usbhid.boot_report.keyboard.reserved", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_1, { "Keycode 1", "usbhid.boot_report.keyboard.keycode_1", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_2, { "Keycode 2", "usbhid.boot_report.keyboard.keycode_2", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_3, { "Keycode 3", "usbhid.boot_report.keyboard.keycode_3", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_4, { "Keycode 4", "usbhid.boot_report.keyboard.keycode_4", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_5, { "Keycode 5", "usbhid.boot_report.keyboard.keycode_5", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_keycode_6, { "Keycode 6", "usbhid.boot_report.keyboard.keycode_6", FT_UINT8, BASE_HEX|BASE_EXT_STRING, &keycode_vals_ext, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_right_gui, { "Modifier: RIGHT GUI", "usbhid.boot_report.keyboard.modifier.right_gui", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_right_alt, { "Modifier: RIGHT ALT", "usbhid.boot_report.keyboard.modifier.right_alt", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_right_shift, { "Modifier: RIGHT SHIFT", "usbhid.boot_report.keyboard.modifier.right_shift", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_right_ctrl, { "Modifier: RIGHT CTRL", "usbhid.boot_report.keyboard.modifier.right_ctrl", FT_BOOLEAN, 8, NULL, 0x10,NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_left_gui, { "Modifier: LEFT GUI", "usbhid.boot_report.keyboard.modifier.left_gui", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_left_alt, { "Modifier: LEFT ALT", "usbhid.boot_report.keyboard.modifier.left_alt", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL } }, { &hf_usbhid_boot_report_keyboard_modifier_left_shift, { "Modifier: LEFT SHIFT", "usbhid.boot_report.keyboard.modifier.left_shift", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_modifier_left_ctrl, { "Modifier: LEFT CTRL", "usbhid.boot_report.keyboard.modifier.left_ctrl", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_constants, { "Constants", "usbhid.boot_report.keyboard.leds.constants", FT_UINT8, BASE_HEX, NULL, 0xE0, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_kana, { "KANA", "usbhid.boot_report.keyboard.leds.kana", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_compose, { "COMPOSE", "usbhid.boot_report.keyboard.leds.compose", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_scroll_lock, { "SCROLL LOCK", "usbhid.boot_report.keyboard.leds.scroll_lock", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_caps_lock, { "CAPS LOCK", "usbhid.boot_report.keyboard.leds.caps_lock", FT_BOOLEAN, 8, NULL, 0x02,NULL, HFILL }}, { &hf_usbhid_boot_report_keyboard_leds_num_lock, { "NUM LOCK", "usbhid.boot_report.keyboard.leds.num_lock", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_8, { "Button 8", "usbhid.boot_report.mouse.button.8", FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_7, { "Button 7", "usbhid.boot_report.mouse.button.7", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_6, { "Button 6", "usbhid.boot_report.mouse.button.6", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_5, { "Button 5", "usbhid.boot_report.mouse.button.5", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_4, { "Button 4", "usbhid.boot_report.mouse.button.4", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_middle, { "Button Middle", "usbhid.boot_report.mouse.button.middle", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_right, { "Button Right", "usbhid.boot_report.mouse.button.right", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_button_left, { "Button Left", "usbhid.boot_report.mouse.button.left", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_x_displacement, { "X Displacement", "usbhid.boot_report.mouse.x_displacement", FT_INT8, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_y_displacement, { "Y Displacement", "usbhid.boot_report.mouse.y_displacement", FT_INT8, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_horizontal_scroll_wheel, { "Horizontal Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.horizontal", FT_INT8, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_boot_report_mouse_vertical_scroll_wheel, { "Vertical Scroll Wheel", "usbhid.boot_report.mouse.scroll_wheel.vertical", FT_INT8, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_data, { "HID Data", "usbhid.data", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_unknown_data, { "Unknown", "usbhid.data.unknown", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_vendor_data, { "Vendor Data", "usbhid.data.vendor", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_report_id, { "Report ID", "usbhid.data.report_id", FT_UINT8, BASE_HEX, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_padding, { "Padding", "usbhid.data.padding", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_x, { "X Axis", "usbhid.data.axis.x", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_y, { "Y Axis", "usbhid.data.axis.y", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_z, { "Z Axis", "usbhid.data.axis.z", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_rx, { "Rz Axis", "usbhid.data.axis.rx", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_ry, { "Ry Axis", "usbhid.data.axis.ry", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_rz, { "Rz Axis", "usbhid.data.axis.rz", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_slider, { "Slider Axis", "usbhid.data.axis.slider", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vx, { "Vz Axis", "usbhid.data.axis.vx", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vy, { "Vy Axis", "usbhid.data.axis.vy", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vz, { "Vz Axis", "usbhid.data.axis.vz", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vbrx, { "Vbrz Axis", "usbhid.data.axis.vbrx", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vbry, { "Vbry Axis", "usbhid.data.axis.vbry", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vbrz, { "Vbrz Axis", "usbhid.data.axis.vbrz", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_axis_vno, { "Vno Axis", "usbhid.data.axis.vno", FT_INT32, BASE_DEC, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_button, { "Button", "usbhid.data.button", FT_BOOLEAN, 1, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_key, { "Key", "usbhid.data.key.variable", FT_BOOLEAN, 1, NULL, 0x00, NULL, HFILL }}, { &hf_usbhid_key_array, { "Keys", "usbhid.data.key.array", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }}, }; static gint *usb_hid_subtrees[] = { &ett_usb_hid_report, &ett_usb_hid_item_header, &ett_usb_hid_wValue, &ett_usb_hid_descriptor, &ett_usb_hid_data, &ett_usb_hid_unknown_data, &ett_usb_hid_key_array }; report_descriptors = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope()); proto_usb_hid = proto_register_protocol("USB HID", "USBHID", "usbhid"); proto_register_field_array(proto_usb_hid, hf, array_length(hf)); proto_register_subtree_array(usb_hid_subtrees, array_length(usb_hid_subtrees)); /*usb_hid_boot_keyboard_input_report_handle =*/ register_dissector("usbhid.boot_report.keyboard.input", dissect_usb_hid_boot_keyboard_input_report, proto_usb_hid); /*usb_hid_boot_keyboard_output_report_handle =*/ register_dissector("usbhid.boot_report.keyboard.output", dissect_usb_hid_boot_keyboard_output_report, proto_usb_hid); /*usb_hid_boot_mouse_input_report_handle =*/ register_dissector("usbhid.boot_report.mouse.input", dissect_usb_hid_boot_mouse_input_report, proto_usb_hid); }
Safe
[]
wireshark
0ceb46e1c28d1094a56aefa0ebf7d7c0e00f8849
1.2337717799984493e+38
509
proto: add support for FT_BYTES in proto_tree_add_bits Change-Id: I5030d550bd760953ac84c2700bb0e03cc7a831a1 Signed-off-by: Filipe Laíns <lains@archlinux.org>
0
check_EXIT(const struct ofpact_null *a OVS_UNUSED, const struct ofpact_check_params *cp OVS_UNUSED) { return 0; }
Safe
[ "CWE-416" ]
ovs
77cccc74deede443e8b9102299efc869a52b65b2
3.6331016684115854e+36
5
ofp-actions: Fix use-after-free while decoding RAW_ENCAP. While decoding RAW_ENCAP action, decode_ed_prop() might re-allocate ofpbuf if there is no enough space left. However, function 'decode_NXAST_RAW_ENCAP' continues to use old pointer to 'encap' structure leading to write-after-free and incorrect decoding. ==3549105==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600000011a at pc 0x0000005f6cc6 bp 0x7ffc3a2d4410 sp 0x7ffc3a2d4408 WRITE of size 2 at 0x60600000011a thread T0 #0 0x5f6cc5 in decode_NXAST_RAW_ENCAP lib/ofp-actions.c:4461:20 #1 0x5f0551 in ofpact_decode ./lib/ofp-actions.inc2:4777:16 #2 0x5ed17c in ofpacts_decode lib/ofp-actions.c:7752:21 #3 0x5eba9a in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7791:13 #4 0x5eb9fc in ofpacts_pull_openflow_actions lib/ofp-actions.c:7835:12 #5 0x64bb8b in ofputil_decode_packet_out lib/ofp-packet.c:1113:17 #6 0x65b6f4 in ofp_print_packet_out lib/ofp-print.c:148:13 #7 0x659e3f in ofp_to_string__ lib/ofp-print.c:1029:16 #8 0x659b24 in ofp_to_string lib/ofp-print.c:1244:21 #9 0x65a28c in ofp_print lib/ofp-print.c:1288:28 #10 0x540d11 in ofctl_ofp_parse utilities/ovs-ofctl.c:2814:9 #11 0x564228 in ovs_cmdl_run_command__ lib/command-line.c:247:17 #12 0x56408a in ovs_cmdl_run_command lib/command-line.c:278:5 #13 0x5391ae in main utilities/ovs-ofctl.c:179:9 #14 0x7f6911ce9081 in __libc_start_main (/lib64/libc.so.6+0x27081) #15 0x461fed in _start (utilities/ovs-ofctl+0x461fed) Fix that by getting a new pointer before using. Credit to OSS-Fuzz. Fuzzer regression test will fail only with AddressSanitizer enabled. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27851 Fixes: f839892a206a ("OF support and translation of generic encap and decap") Acked-by: William Tu <u9012063@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
0
static void b43_request_firmware(struct work_struct *work) { struct b43_wl *wl = container_of(work, struct b43_wl, firmware_load); struct b43_wldev *dev = wl->current_dev; struct b43_request_fw_context *ctx; unsigned int i; int err; const char *errmsg; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return; ctx->dev = dev; ctx->req_type = B43_FWTYPE_PROPRIETARY; err = b43_try_request_fw(ctx); if (!err) goto start_ieee80211; /* Successfully loaded it. */ /* Was fw version known? */ if (ctx->fatal_failure) goto out; /* proprietary fw not found, try open source */ ctx->req_type = B43_FWTYPE_OPENSOURCE; err = b43_try_request_fw(ctx); if (!err) goto start_ieee80211; /* Successfully loaded it. */ if(ctx->fatal_failure) goto out; /* Could not find a usable firmware. Print the errors. */ for (i = 0; i < B43_NR_FWTYPES; i++) { errmsg = ctx->errors[i]; if (strlen(errmsg)) b43err(dev->wl, "%s", errmsg); } b43_print_fw_helptext(dev->wl, 1); goto out; start_ieee80211: wl->hw->queues = B43_QOS_QUEUE_NUM; if (!modparam_qos || dev->fw.opensource) wl->hw->queues = 1; err = ieee80211_register_hw(wl->hw); if (err) goto err_one_core_detach; wl->hw_registred = true; b43_leds_register(wl->current_dev); goto out; err_one_core_detach: b43_one_core_detach(dev->dev); out: kfree(ctx); }
Safe
[ "CWE-134" ]
wireless
9538cbaab6e8b8046039b4b2eb6c9d614dc782bd
2.766759924621602e+37
58
b43: stop format string leaking into error msgs The module parameter "fwpostfix" is userspace controllable, unfiltered, and is used to define the firmware filename. b43_do_request_fw() populates ctx->errors[] on error, containing the firmware filename. b43err() parses its arguments as a format string. For systems with b43 hardware, this could lead to a uid-0 to ring-0 escalation. CVE-2013-2852 Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: John W. Linville <linville@tuxdriver.com>
0
PHP_FUNCTION(enchant_broker_request_dict) { zval *broker; enchant_broker *pbroker; enchant_dict *dict; EnchantDict *d; char *tag; int taglen; int pos; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) { RETURN_FALSE; } PHP_ENCHANT_GET_BROKER; if (taglen == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tag cannot be empty"); RETURN_FALSE; } d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag); if (d) { pos = pbroker->dictcnt++; if (pbroker->dictcnt) { pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt); } else { pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *)); pos = 0; } dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict)); dict->id = pos; dict->pbroker = pbroker; dict->pdict = d; dict->prev = pos ? pbroker->dict[pos-1] : NULL; dict->next = NULL; pbroker->dict[pos] = dict; if (pos) { pbroker->dict[pos-1]->next = dict; } dict->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict); zend_list_addref(pbroker->rsrc_id); } else { RETURN_FALSE; } }
Safe
[ "CWE-119" ]
php-src
bdfe457a2c1b47209e32783b3a6447e81baf179a
2.902616000713086e+38
49
Port for for bug #68552
0