func
stringlengths
0
484k
target
int64
0
1
cwe
sequencelengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
static boolean ReadICCProfile(j_decompress_ptr jpeg_info) { char magick[12]; ErrorManager *error_manager; ExceptionInfo *exception; Image *image; MagickBooleanType status; register ssize_t i; register unsigned char *p; size_t length; StringInfo *icc_profile, *profile; /* Read color profile. */ length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8); length+=(size_t) GetCharacter(jpeg_info); length-=2; if (length <= 14) { while (length-- > 0) if (GetCharacter(jpeg_info) == EOF) break; return(TRUE); } for (i=0; i < 12; i++) magick[i]=(char) GetCharacter(jpeg_info); if (LocaleCompare(magick,ICC_PROFILE) != 0) { /* Not a ICC profile, return. */ for (i=0; i < (ssize_t) (length-12); i++) if (GetCharacter(jpeg_info) == EOF) break; return(TRUE); } (void) GetCharacter(jpeg_info); /* id */ (void) GetCharacter(jpeg_info); /* markers */ length-=14; error_manager=(ErrorManager *) jpeg_info->client_data; exception=error_manager->exception; image=error_manager->image; profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); return(FALSE); } error_manager->profile=profile; p=GetStringInfoDatum(profile); for (i=0; i < (ssize_t) length; i++) { int c; c=GetCharacter(jpeg_info); if (c == EOF) break; *p++=(unsigned char) c; } if (i != (ssize_t) length) { profile=DestroyStringInfo(profile); (void) ThrowMagickException(exception,GetMagickModule(), CorruptImageError,"InsufficientImageDataInFile","`%s'", image->filename); return(FALSE); } error_manager->profile=NULL; icc_profile=(StringInfo *) GetImageProfile(image,"icc"); if (icc_profile != (StringInfo *) NULL) { ConcatenateStringInfo(icc_profile,profile); profile=DestroyStringInfo(profile); } else { status=SetImageProfile(image,"icc",profile,exception); profile=DestroyStringInfo(profile); if (status == MagickFalse) { (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); return(FALSE); } } if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Profile: ICC, %.20g bytes",(double) length); return(TRUE); }
1
[ "CWE-416" ]
ImageMagick
39f226a9c137f547e12afde972eeba7551124493
162,374,092,337,400,400,000,000,000,000,000,000,000
111
https://github.com/ImageMagick/ImageMagick/issues/1641
__export struct rad_dict_attr_t *rad_dict_find_attr_id(struct rad_dict_vendor_t *vendor, int id) { struct rad_dict_attr_t *attr; struct list_head *items = vendor ? &vendor->items : &dict->items; list_for_each_entry(attr, items, entry) if (attr->id == id) return attr; return NULL; }
0
[ "CWE-787" ]
accel-ppp
d4cb89721cc8e5b3dd3fbefaf173eb77ecb85615
123,560,801,128,212,490,000,000,000,000,000,000,000
11
fix buffer overflow when receive radius packet This patch fixes buffer overflow if radius packet contains invalid atribute length and attrubute type from the following list: ipv4addr, ipv6addr, ipv6prefix or ifid Reported-by: Chloe Ong Reported-by: Eugene Lim <spaceraccoon@users.noreply.github.com> Reported-by: Kar Wei Loh Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
void set_user_nice(struct task_struct *p, long nice) { int old_prio, delta, on_rq; unsigned long flags; struct rq *rq; if (TASK_NICE(p) == nice || nice < -20 || nice > 19) return; /* * We have to be careful, if called from sys_setpriority(), * the task might be in the middle of scheduling on another CPU. */ rq = task_rq_lock(p, &flags); update_rq_clock(rq); /* * The RT priorities are set via sched_setscheduler(), but we still * allow the 'normal' nice value to be set - but as expected * it wont have any effect on scheduling until the task is * SCHED_FIFO/SCHED_RR: */ if (task_has_rt_policy(p)) { p->static_prio = NICE_TO_PRIO(nice); goto out_unlock; } on_rq = p->se.on_rq; if (on_rq) dequeue_task(rq, p, 0); p->static_prio = NICE_TO_PRIO(nice); set_load_weight(p); old_prio = p->prio; p->prio = effective_prio(p); delta = p->prio - old_prio; if (on_rq) { enqueue_task(rq, p, 0); /* * If the task increased its priority or is running and * lowered its priority, then reschedule its CPU: */ if (delta < 0 || (delta > 0 && task_running(rq, p))) resched_task(rq->curr); } out_unlock: task_rq_unlock(rq, &flags); }
0
[]
linux-2.6
8f1bc385cfbab474db6c27b5af1e439614f3025c
80,653,397,182,524,560,000,000,000,000,000,000,000
46
sched: fair: weight calculations In order to level the hierarchy, we need to calculate load based on the root view. That is, each task's load is in the same unit. A / \ B 1 / \ 2 3 To compute 1's load we do: weight(1) -------------- rq_weight(A) To compute 2's load we do: weight(2) weight(B) ------------ * ----------- rq_weight(B) rw_weight(A) This yields load fractions in comparable units. The consequence is that it changes virtual time. We used to have: time_{i} vtime_{i} = ------------ weight_{i} vtime = \Sum vtime_{i} = time / rq_weight. But with the new way of load calculation we get that vtime equals time. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
GetNumWrongData(const byte * curPtr, const int maxnum) { int count = 0; if (1 == maxnum) { return (1); } while (maxnum > count+1 && *(curPtr + count) != *(curPtr + count + 1)) { count++; } return (count); }
0
[ "CWE-787" ]
ghostpdl
9f39ed4a92578a020ae10459643e1fe72573d134
62,986,818,176,178,330,000,000,000,000,000,000,000
13
Bug 701792: Avoid going beyond buffer in GetNumSameData() and GetNumWrongData(). GetNumSameData() compared buffer contents before checking that we are still within bounds of buffer, which caused the bug. Have made similar fix to GetNumWrongData() because it has similar error. Fixes address sanitizer error in: ./sanbin/gs -sOutputFile=tmp -sDEVICE=lips4v ../bug-701792.pdf
int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir, const char *name, int name_len) { int ret; struct btrfs_key key; struct btrfs_dir_item *di; int data_size; struct extent_buffer *leaf; int slot; struct btrfs_path *path; path = btrfs_alloc_path(); if (!path) return -ENOMEM; key.objectid = dir; btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); key.offset = btrfs_name_hash(name, name_len); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); /* return back any errors */ if (ret < 0) goto out; /* nothing found, we're safe */ if (ret > 0) { ret = 0; goto out; } /* we found an item, look for our name in the item */ di = btrfs_match_dir_item_name(root, path, name, name_len); if (di) { /* our exact name was found */ ret = -EEXIST; goto out; } /* * see if there is room in the item to insert this * name */ data_size = sizeof(*di) + name_len + sizeof(struct btrfs_item); leaf = path->nodes[0]; slot = path->slots[0]; if (data_size + btrfs_item_size_nr(leaf, slot) + sizeof(struct btrfs_item) > BTRFS_LEAF_DATA_SIZE(root)) { ret = -EOVERFLOW; } else { /* plenty of insertion room */ ret = 0; } out: btrfs_free_path(path); return ret; }
0
[ "CWE-310" ]
linux-2.6
9c52057c698fb96f8f07e7a4bcf4801a092bda89
248,982,828,227,266,640,000,000,000,000,000,000,000
58
Btrfs: fix hash overflow handling The handling for directory crc hash overflows was fairly obscure, split_leaf returns EOVERFLOW when we try to extend the item and that is supposed to bubble up to userland. For a while it did so, but along the way we added better handling of errors and forced the FS readonly if we hit IO errors during the directory insertion. Along the way, we started testing only for EEXIST and the EOVERFLOW case was dropped. The end result is that we may force the FS readonly if we catch a directory hash bucket overflow. This fixes a few problem spots. First I add tests for EOVERFLOW in the places where we can safely just return the error up the chain. btrfs_rename is harder though, because it tries to insert the new directory item only after it has already unlinked anything the rename was going to overwrite. Rather than adding very complex logic, I added a helper to test for the hash overflow case early while it is still safe to bail out. Snapshot and subvolume creation had a similar problem, so they are using the new helper now too. Signed-off-by: Chris Mason <chris.mason@fusionio.com> Reported-by: Pascal Junod <pascal@junod.info>
static int rsi_mac80211_resume(struct ieee80211_hw *hw) { u16 rx_filter_word = 0; struct rsi_hw *adapter = hw->priv; struct rsi_common *common = adapter->priv; common->wow_flags = 0; rsi_dbg(INFO_ZONE, "%s: mac80211 resume\n", __func__); if (common->hibernate_resume) return 0; mutex_lock(&common->mutex); rsi_send_wowlan_request(common, 0, 0); rx_filter_word = (ALLOW_DATA_ASSOC_PEER | ALLOW_CTRL_ASSOC_PEER | ALLOW_MGMT_ASSOC_PEER); rsi_send_rx_filter_frame(common, rx_filter_word); mutex_unlock(&common->mutex); return 0; }
0
[ "CWE-416" ]
linux
abd39c6ded9db53aa44c2540092bdd5fb6590fa8
60,472,285,856,768,470,000,000,000,000,000,000,000
23
rsi: add fix for crash during assertions Observed crash in some scenarios when assertion has occurred, this is because hw structure is freed and is tried to get accessed in some functions where null check is already present. So, avoided the crash by making the hw to NULL after freeing. Signed-off-by: Sanjay Konduri <sanjay.konduri@redpinesignals.com> Signed-off-by: Sushant Kumar Mishra <sushant.mishra@redpinesignals.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
MagickExport MagickBooleanType SetImageProperty(Image *image, const char *property,const char *value,ExceptionInfo *exception) { MagickBooleanType status; MagickStatusType flags; assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if (image->properties == (void *) NULL) image->properties=NewSplayTree(CompareSplayTreeString, RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */ if (value == (const char *) NULL) return(DeleteImageProperty(image,property)); /* delete if NULL */ status=MagickTrue; if (strlen(property) <= 1) { /* Do not 'set' single letter properties - read only shorthand. */ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } /* FUTURE: binary chars or quotes in key should produce a error */ /* Set attributes with known names or special prefixes return result is found, or break to set a free form properity */ switch (*property) { #if 0 /* Percent escape's sets values with this prefix: for later use Throwing an exception causes this setting to fail */ case '8': { if (LocaleNCompare("8bim:",property,5) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; } #endif case 'B': case 'b': { if (LocaleCompare("background",property) == 0) { (void) QueryColorCompliance(value,AllCompliance, &image->background_color,exception); /* check for FUTURE: value exception?? */ /* also add user input to splay tree */ } break; /* not an attribute, add as a property */ } case 'C': case 'c': { if (LocaleCompare("channels",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } if (LocaleCompare("colorspace",property) == 0) { ssize_t colorspace; colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, value); if (colorspace < 0) return(MagickFalse); /* FUTURE: value exception?? */ return(SetImageColorspace(image,(ColorspaceType) colorspace,exception)); } if (LocaleCompare("compose",property) == 0) { ssize_t compose; compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value); if (compose < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->compose=(CompositeOperator) compose; return(MagickTrue); } if (LocaleCompare("compress",property) == 0) { ssize_t compression; compression=ParseCommandOption(MagickCompressOptions,MagickFalse, value); if (compression < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->compression=(CompressionType) compression; return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'D': case 'd': { if (LocaleCompare("delay",property) == 0) { GeometryInfo geometry_info; flags=ParseGeometry(value,&geometry_info); if ((flags & GreaterValue) != 0) { if (image->delay > (size_t) floor(geometry_info.rho+0.5)) image->delay=(size_t) floor(geometry_info.rho+0.5); } else if ((flags & LessValue) != 0) { if (image->delay < (size_t) floor(geometry_info.rho+0.5)) image->delay=(ssize_t) floor(geometry_info.sigma+0.5); } else image->delay=(size_t) floor(geometry_info.rho+0.5); if ((flags & SigmaValue) != 0) image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5); return(MagickTrue); } if (LocaleCompare("delay_units",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } if (LocaleCompare("density",property) == 0) { GeometryInfo geometry_info; flags=ParseGeometry(value,&geometry_info); image->resolution.x=geometry_info.rho; image->resolution.y=geometry_info.sigma; if ((flags & SigmaValue) == 0) image->resolution.y=image->resolution.x; return(MagickTrue); } if (LocaleCompare("depth",property) == 0) { image->depth=StringToUnsignedLong(value); return(MagickTrue); } if (LocaleCompare("dispose",property) == 0) { ssize_t dispose; dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value); if (dispose < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->dispose=(DisposeType) dispose; return(MagickTrue); } break; /* not an attribute, add as a property */ } #if 0 /* Percent escape's sets values with this prefix: for later use Throwing an exception causes this setting to fail */ case 'E': case 'e': { if (LocaleNCompare("exif:",property,5) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } case 'F': case 'f': { if (LocaleNCompare("fx:",property,3) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } #endif case 'G': case 'g': { if (LocaleCompare("gamma",property) == 0) { image->gamma=StringToDouble(value,(char **) NULL); return(MagickTrue); } if (LocaleCompare("gravity",property) == 0) { ssize_t gravity; gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value); if (gravity < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->gravity=(GravityType) gravity; return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'H': case 'h': { if (LocaleCompare("height",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } case 'I': case 'i': { if (LocaleCompare("intensity",property) == 0) { ssize_t intensity; intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,value); if (intensity < 0) return(MagickFalse); image->intensity=(PixelIntensityMethod) intensity; return(MagickTrue); } if (LocaleCompare("intent",property) == 0) { ssize_t rendering_intent; rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, value); if (rendering_intent < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->rendering_intent=(RenderingIntent) rendering_intent; return(MagickTrue); } if (LocaleCompare("interpolate",property) == 0) { ssize_t interpolate; interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, value); if (interpolate < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->interpolate=(PixelInterpolateMethod) interpolate; return(MagickTrue); } #if 0 /* Percent escape's sets values with this prefix: for later use Throwing an exception causes this setting to fail */ if (LocaleNCompare("iptc:",property,5) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } #endif break; /* not an attribute, add as a property */ } case 'K': case 'k': if (LocaleCompare("kurtosis",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ case 'L': case 'l': { if (LocaleCompare("loop",property) == 0) { image->iterations=StringToUnsignedLong(value); return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'M': case 'm': if ((LocaleCompare("magick",property) == 0) || (LocaleCompare("max",property) == 0) || (LocaleCompare("mean",property) == 0) || (LocaleCompare("min",property) == 0) || (LocaleCompare("min",property) == 0)) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ case 'O': case 'o': if (LocaleCompare("opaque",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ case 'P': case 'p': { if (LocaleCompare("page",property) == 0) { char *geometry; geometry=GetPageGeometry(value); flags=ParseAbsoluteGeometry(geometry,&image->page); geometry=DestroyString(geometry); return(MagickTrue); } #if 0 /* Percent escape's sets values with this prefix: for later use Throwing an exception causes this setting to fail */ if (LocaleNCompare("pixel:",property,6) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } #endif if (LocaleCompare("profile",property) == 0) { ImageInfo *image_info; StringInfo *profile; image_info=AcquireImageInfo(); (void) CopyMagickString(image_info->filename,value,MagickPathExtent); (void) SetImageInfo(image_info,1,exception); profile=FileToStringInfo(image_info->filename,~0UL,exception); if (profile != (StringInfo *) NULL) status=SetImageProfile(image,image_info->magick,profile,exception); image_info=DestroyImageInfo(image_info); return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'R': case 'r': { if (LocaleCompare("rendering-intent",property) == 0) { ssize_t rendering_intent; rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse, value); if (rendering_intent < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->rendering_intent=(RenderingIntent) rendering_intent; return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'S': case 's': if ((LocaleCompare("size",property) == 0) || (LocaleCompare("skewness",property) == 0) || (LocaleCompare("scenes",property) == 0) || (LocaleCompare("standard-deviation",property) == 0)) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ case 'T': case 't': { if (LocaleCompare("tile-offset",property) == 0) { char *geometry; geometry=GetPageGeometry(value); flags=ParseAbsoluteGeometry(geometry,&image->tile_offset); geometry=DestroyString(geometry); return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'U': case 'u': { if (LocaleCompare("units",property) == 0) { ssize_t units; units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value); if (units < 0) return(MagickFalse); /* FUTURE: value exception?? */ image->units=(ResolutionType) units; return(MagickTrue); } break; /* not an attribute, add as a property */ } case 'V': case 'v': { if (LocaleCompare("version",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } case 'W': case 'w': { if (LocaleCompare("width",property) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } #if 0 /* Percent escape's sets values with this prefix: for later use Throwing an exception causes this setting to fail */ case 'X': case 'x': { if (LocaleNCompare("xmp:",property,4) == 0) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); } break; /* not an attribute, add as a property */ } #endif } /* Default: not an attribute, add as a property */ status=AddValueToSplayTree((SplayTreeInfo *) image->properties, ConstantString(property),ConstantString(value)); /* FUTURE: error if status is bad? */ return(status); }
0
[ "CWE-476" ]
ImageMagick
b61d35eaccc0a7ddeff8a1c3abfcd0a43ccf210b
229,196,161,740,944,960,000,000,000,000,000,000,000
459
https://github.com/ImageMagick/ImageMagick/issues/298
proto_tree_add_item_ret_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, const gint start, gint length, const guint encoding, gboolean *retval) { header_field_info *hfinfo = proto_registrar_get_nth(hfindex); field_info *new_fi; guint64 value, bitval; DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!"); if (hfinfo->type != FT_BOOLEAN) { REPORT_DISSECTOR_BUG("field %s is not of type FT_BOOLEAN", hfinfo->abbrev); } /* length validation for native number encoding caught by get_uint64_value() */ /* length has to be -1 or > 0 regardless of encoding */ if (length < -1 || length == 0) REPORT_DISSECTOR_BUG("Invalid length %d passed to proto_tree_add_item_ret_boolean", length); if (encoding & ENC_STRING) { REPORT_DISSECTOR_BUG("wrong encoding"); } /* I believe it's ok if this is called with a NULL tree */ value = get_uint64_value(tree, tvb, start, length, encoding); if (retval) { bitval = value; if (hfinfo->bitmask) { /* Mask out irrelevant portions */ bitval &= hfinfo->bitmask; } *retval = (bitval != 0); } CHECK_FOR_NULL_TREE(tree); TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo); new_fi = new_field_info(tree, hfinfo, tvb, start, length); proto_tree_set_boolean(new_fi, value); new_fi->flags |= (encoding & ENC_LITTLE_ENDIAN) ? FI_LITTLE_ENDIAN : FI_BIG_ENDIAN; return proto_tree_add_node(tree, new_fi); }
0
[ "CWE-401" ]
wireshark
a9fc769d7bb4b491efb61c699d57c9f35269d871
257,882,672,430,912,520,000,000,000,000,000,000,000
48
epan: Fix a memory leak. Make sure _proto_tree_add_bits_ret_val allocates a bits array using the packet scope, otherwise we leak memory. Fixes #17032.
auth_update_component(struct sc_card *card, struct auth_update_component_info *args) { struct sc_apdu apdu; unsigned char sbuf[SC_MAX_APDU_BUFFER_SIZE + 0x10]; unsigned char ins, p1, p2; int rv, len; LOG_FUNC_CALLED(card->ctx); if (args->len > sizeof(sbuf) || args->len > 0x100) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); sc_log(card->ctx, "nn %i; len %i", args->component, args->len); ins = 0xD8; p1 = args->component; p2 = 0x04; len = 0; sbuf[len++] = args->type; sbuf[len++] = args->len; memcpy(sbuf + len, args->data, args->len); len += args->len; if (args->type == SC_CARDCTL_OBERTHUR_KEY_DES) { int outl; const unsigned char in[8] = {0,0,0,0,0,0,0,0}; unsigned char out[8]; EVP_CIPHER_CTX * ctx = NULL; if (args->len!=8 && args->len!=24) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL,SC_ERROR_OUT_OF_MEMORY); p2 = 0; if (args->len == 24) EVP_EncryptInit_ex(ctx, EVP_des_ede(), NULL, args->data, NULL); else EVP_EncryptInit_ex(ctx, EVP_des_ecb(), NULL, args->data, NULL); rv = EVP_EncryptUpdate(ctx, out, &outl, in, 8); EVP_CIPHER_CTX_free(ctx); if (rv == 0) { sc_log(card->ctx, "OpenSSL encryption error."); LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } sbuf[len++] = 0x03; memcpy(sbuf + len, out, 3); len += 3; } else { sbuf[len++] = 0; } sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, ins, p1, p2); apdu.cla |= 0x80; apdu.data = sbuf; apdu.datalen = len; apdu.lc = len; if (args->len == 0x100) { sbuf[0] = args->type; sbuf[1] = 0x20; memcpy(sbuf + 2, args->data, 0x20); sbuf[0x22] = 0; apdu.cla |= 0x10; apdu.data = sbuf; apdu.datalen = 0x23; apdu.lc = 0x23; rv = sc_transmit_apdu(card, &apdu); apdu.cla &= ~0x10; LOG_TEST_RET(card->ctx, rv, "APDU transmit failed"); sbuf[0] = args->type; sbuf[1] = 0xE0; memcpy(sbuf + 2, args->data + 0x20, 0xE0); sbuf[0xE2] = 0; apdu.data = sbuf; apdu.datalen = 0xE3; apdu.lc = 0xE3; } rv = sc_transmit_apdu(card, &apdu); sc_mem_clear(sbuf, sizeof(sbuf)); LOG_TEST_RET(card->ctx, rv, "APDU transmit failed"); rv = sc_check_sw(card, apdu.sw1, apdu.sw2); LOG_FUNC_RETURN(card->ctx, rv); }
0
[ "CWE-125" ]
OpenSC
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
262,522,697,236,003,360,000,000,000,000,000,000,000
89
fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
static s32 brcmf_set_auth_type(struct net_device *ndev, struct cfg80211_connect_params *sme) { struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); struct brcmf_cfg80211_security *sec; s32 val = 0; s32 err = 0; switch (sme->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: val = 0; brcmf_dbg(CONN, "open system\n"); break; case NL80211_AUTHTYPE_SHARED_KEY: val = 1; brcmf_dbg(CONN, "shared key\n"); break; default: val = 2; brcmf_dbg(CONN, "automatic, auth type (%d)\n", sme->auth_type); break; } err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "auth", val); if (err) { brcmf_err("set auth failed (%d)\n", err); return err; } sec = &profile->sec; sec->auth_type = sme->auth_type; return err; }
0
[ "CWE-119", "CWE-787" ]
linux
8f44c9a41386729fea410e688959ddaa9d51be7c
275,196,499,693,108,930,000,000,000,000,000,000,000
32
brcmfmac: fix possible buffer overflow in brcmf_cfg80211_mgmt_tx() The lower level nl80211 code in cfg80211 ensures that "len" is between 25 and NL80211_ATTR_FRAME (2304). We subtract DOT11_MGMT_HDR_LEN (24) from "len" so thats's max of 2280. However, the action_frame->data[] buffer is only BRCMF_FIL_ACTION_FRAME_SIZE (1800) bytes long so this memcpy() can overflow. memcpy(action_frame->data, &buf[DOT11_MGMT_HDR_LEN], le16_to_cpu(action_frame->len)); Cc: stable@vger.kernel.org # 3.9.x Fixes: 18e2f61db3b70 ("brcmfmac: P2P action frame tx.") Reported-by: "freenerguo(郭大兴)" <freenerguo@tencent.com> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
CImg<T>& blur_box(const float boxsize_x, const float boxsize_y, const float boxsize_z, const unsigned int boundary_conditions=1, const unsigned int nb_iter=1) { if (is_empty()) return *this; if (_width>1) boxfilter(boxsize_x,0,'x',boundary_conditions,nb_iter); if (_height>1) boxfilter(boxsize_y,0,'y',boundary_conditions,nb_iter); if (_depth>1) boxfilter(boxsize_z,0,'z',boundary_conditions,nb_iter); return *this; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
340,143,946,313,479,640,000,000,000,000,000,000,000
9
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
static int network_flush(cdtime_t timeout, __attribute__((unused)) const char *identifier, __attribute__((unused)) user_data_t *user_data) { pthread_mutex_lock(&send_buffer_lock); if (send_buffer_fill > 0) { if (timeout > 0) { cdtime_t now = cdtime(); if ((send_buffer_last_update + timeout) > now) { pthread_mutex_unlock(&send_buffer_lock); return (0); } } flush_buffer(); } pthread_mutex_unlock(&send_buffer_lock); return (0); } /* int network_flush */
0
[ "CWE-835" ]
collectd
f6be4f9b49b949b379326c3d7002476e6ce4f211
256,471,210,509,380,000,000,000,000,000,000,000,000
19
network plugin: Fix endless loop DOS in parse_packet() When correct 'Signature part' is received by Collectd, configured without AuthFile option, condition for endless loop occurs due to missing increase of pointer to next unprocessed part. This is a forward-port of #2233. Fixes: CVE-2017-7401 Closes: #2174 Signed-off-by: Florian Forster <octo@collectd.org>
static void test_bug9643() { MYSQL_STMT *stmt; MYSQL_BIND my_bind[1]; int32 a; int rc; const char *stmt_text; int num_rows= 0; ulong type; ulong prefetch_rows= 5; myheader("test_bug9643"); mysql_query(mysql, "drop table if exists t1"); mysql_query(mysql, "create table t1 (id integer not null primary key)"); rc= mysql_query(mysql, "insert into t1 (id) values " " (1), (2), (3), (4), (5), (6), (7), (8), (9)"); myquery(rc); stmt= mysql_stmt_init(mysql); /* Not implemented in 5.0 */ type= (ulong) CURSOR_TYPE_SCROLLABLE; rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); DIE_UNLESS(rc); if (! opt_silent) printf("Got error (as expected): %s\n", mysql_stmt_error(stmt)); type= (ulong) CURSOR_TYPE_READ_ONLY; rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); check_execute(stmt, rc); rc= mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void*) &prefetch_rows); check_execute(stmt, rc); stmt_text= "select * from t1"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); my_bind[0].buffer_type= MYSQL_TYPE_LONG; my_bind[0].buffer= (void*) &a; my_bind[0].buffer_length= sizeof(a); mysql_stmt_bind_result(stmt, my_bind); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); while ((rc= mysql_stmt_fetch(stmt)) == 0) ++num_rows; DIE_UNLESS(num_rows == 9); rc= mysql_stmt_close(stmt); DIE_UNLESS(rc == 0); rc= mysql_query(mysql, "drop table t1"); myquery(rc); }
0
[ "CWE-416" ]
server
eef21014898d61e77890359d6546d4985d829ef6
257,412,792,354,208,870,000,000,000,000,000,000,000
56
MDEV-11933 Wrong usage of linked list in mysql_prune_stmt_list mysql_prune_stmt_list() was walking the list following element->next pointers, but inside the loop it was invoking list_add(element) that modified element->next. So, mysql_prune_stmt_list() failed to visit and reset all elements, and some of them were left with pointers to invalid MYSQL.
zzip_mem_disk_load(ZZIP_MEM_DISK* dir, ZZIP_DISK* disk) { if (dir->list) zzip_mem_disk_unload(dir); ___ struct zzip_disk_entry* entry = zzip_disk_findfirst(disk); for (; entry ; entry = zzip_disk_findnext(disk, entry)) { ZZIP_MEM_DISK_ENTRY* item = zzip_mem_disk_entry_new(disk, entry); if (dir->last) { dir->last->zz_next = item; } else { dir->list = item; }; dir->last = item; } ____; dir->disk = disk; return 0; }
1
[ "CWE-119" ]
zziplib
596d9dfce2624e849417d4301e8d67935608aa5e
219,475,429,227,882,320,000,000,000,000,000,000,000
12
memdisk (.)
int rsa_pkcs1_decrypt( rsa_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len) { switch( ctx->padding ) { case RSA_PKCS_V15: return rsa_rsaes_pkcs1_v15_decrypt( ctx, mode, olen, input, output, output_max_len ); #if defined(POLARSSL_PKCS1_V21) case RSA_PKCS_V21: return rsa_rsaes_oaep_decrypt( ctx, mode, NULL, 0, olen, input, output, output_max_len ); #endif default: return( POLARSSL_ERR_RSA_INVALID_PADDING ); } }
1
[ "CWE-310" ]
polarssl
43f9799ce61c6392a014d0a2ea136b4b3a9ee194
103,061,960,944,602,730,000,000,000,000,000,000,000
22
RSA blinding on CRT operations to counter timing attacks
void subtime(struct timeval *a, struct timeval *b) { timersub(a, b, b); }
0
[ "CWE-20", "CWE-703" ]
sgminer
910c36089940e81fb85c65b8e63dcd2fac71470c
228,197,706,535,211,000,000,000,000,000,000,000,000
4
stratum: parse_notify(): Don't die on malformed bbversion/prev_hash/nbit/ntime. Might have introduced a memory leak, don't have time to check. :( Should the other hex2bin()'s be checked? Thanks to Mick Ayzenberg <mick.dejavusecurity.com> for finding this.
bool Item::cleanup_processor(void *arg) { if (fixed) cleanup(); return FALSE; }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
250,276,211,036,235,450,000,000,000,000,000,000,000
6
MDEV-24176 Preparations 1. moved fix_vcol_exprs() call to open_table() mysql_alter_table() doesn't do lock_tables() so it cannot win from fix_vcol_exprs() from there. Tests affected: main.default_session 2. Vanilla cleanups and comments.
static struct sb_uart_state *uart_get(struct uart_driver *drv, int line) { struct sb_uart_state *state; MP_MUTEX_LOCK(mp_mutex); state = drv->state + line; if (mutex_lock_interruptible(&state->mutex)) { state = ERR_PTR(-ERESTARTSYS); goto out; } state->count++; if (!state->port) { state->count--; MP_STATE_UNLOCK(state); state = ERR_PTR(-ENXIO); goto out; } if (!state->info) { state->info = kmalloc(sizeof(struct sb_uart_info), GFP_KERNEL); if (state->info) { memset(state->info, 0, sizeof(struct sb_uart_info)); init_waitqueue_head(&state->info->open_wait); init_waitqueue_head(&state->info->delta_msr_wait); state->port->info = state->info; tasklet_init(&state->info->tlet, mp_tasklet_action, (unsigned long)state); } else { state->count--; MP_STATE_UNLOCK(state); state = ERR_PTR(-ENOMEM); } } out: MP_MUTEX_UNLOCK(mp_mutex); return state; }
0
[ "CWE-200" ]
linux
a8b33654b1e3b0c74d4a1fed041c9aae50b3c427
313,685,609,041,585,120,000,000,000,000,000,000,000
40
Staging: sb105x: info leak in mp_get_count() The icount.reserved[] array isn't initialized so it leaks stack information to userspace. Reported-by: Nico Golde <nico@ngolde.de> Reported-by: Fabian Yamaguchi <fabs@goesec.de> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
grapheme_extract_charcount_iter(UBreakIterator *bi, int32_t csize, unsigned char *pstr, int32_t str_len) { int pos = 0, prev_pos = 0; int ret_pos = 0, prev_ret_pos = 0; while ( 1 ) { pos = ubrk_next(bi); if ( UBRK_DONE == pos ) { break; } /* if we are beyond our limit, then the loop is done */ if ( pos > csize ) { break; } /* update our pointer in the original UTF-8 buffer by as many characters as ubrk_next iterated over */ prev_ret_pos = ret_pos; U8_FWD_N(pstr, ret_pos, str_len, pos - prev_pos); if ( prev_ret_pos == ret_pos ) { /* something wrong - malformed utf8? */ break; } prev_pos = pos; } return ret_pos; }
0
[]
php-src
16d0b9c836b793f9338c5a6296fba1b272bbae06
29,138,782,675,523,820,000,000,000,000,000,000,000
33
Fix bug #72061 - Out-of-bounds reads in zif_grapheme_stripos with negative offset
static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) { struct regulator_bulk_data *bulk = data; bulk->ret = regulator_enable(bulk->consumer); }
0
[ "CWE-416" ]
linux
60a2362f769cf549dc466134efe71c8bf9fbaaba
53,491,484,475,638,870,000,000,000,000,000,000,000
6
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>
static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti) { struct pgpath *pgpath, *tmp; struct multipath *m = ti->private; list_for_each_entry_safe(pgpath, tmp, pgpaths, list) { list_del(&pgpath->list); if (m->hw_handler_name) scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev)); dm_put_device(ti, pgpath->path.dev); free_pgpath(pgpath); } }
0
[ "CWE-284", "CWE-264" ]
linux
ec8013beddd717d1740cfefb1a9b900deef85462
249,918,762,209,933,000,000,000,000,000,000,000,000
13
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>
bgp_attr_origin (struct bgp_attr_parser_args *args) { struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; /* If any recognized attribute has Attribute Length that conflicts with the expected length (based on the attribute type code), then the Error Subcode is set to Attribute Length Error. The Data field contains the erroneous attribute (type, length and value). */ if (length != 1) { zlog (peer->log, LOG_ERR, "Origin attribute length is not one %d", length); return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } /* Fetch origin attribute. */ attr->origin = stream_getc (BGP_INPUT (peer)); /* If the ORIGIN attribute has an undefined value, then the Error Subcode is set to Invalid Origin Attribute. The Data field contains the unrecognized attribute (type, length and value). */ if ((attr->origin != BGP_ORIGIN_IGP) && (attr->origin != BGP_ORIGIN_EGP) && (attr->origin != BGP_ORIGIN_INCOMPLETE)) { zlog (peer->log, LOG_ERR, "Origin attribute value is invalid %d", attr->origin); return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_INVAL_ORIGIN, args->total); } /* Set oring attribute flag. */ attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN); return 0; }
0
[]
quagga
8794e8d229dc9fe29ea31424883433d4880ef408
155,420,048,715,899,980,000,000,000,000,000,000,000
42
bgpd: Fix regression in args consolidation, total should be inited from args * bgp_attr.c: (bgp_attr_unknown) total should be initialised from the args.
bool ParticipantImpl::removeSubscriber( Subscriber* sub) { for (auto sit = m_subscribers.begin(); sit != m_subscribers.end(); ++sit) { if (sit->second->getGuid() == sub->getGuid()) { delete(sit->second); m_subscribers.erase(sit); return true; } } return false; }
0
[ "CWE-284" ]
Fast-DDS
d2aeab37eb4fad4376b68ea4dfbbf285a2926384
172,398,974,772,747,200,000,000,000,000,000,000,000
14
check remote permissions (#1387) * Refs 5346. Blackbox test Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 5346. one-way string compare Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 5346. Do not add partition separator on last partition Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 5346. Uncrustify Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 5346. Uncrustify Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Access control unit testing It only covers Partition and Topic permissions Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs #3680. Fix partition check on Permissions plugin. Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Uncrustify Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Fix tests on mac Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Fix windows tests Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Avoid memory leak on test Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * Refs 3680. Proxy data mocks should not return temporary objects Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> * refs 3680. uncrustify Signed-off-by: Iker Luengo <ikerluengo@eprosima.com> Co-authored-by: Miguel Company <MiguelCompany@eprosima.com>
void virDomainInputDefFree(virDomainInputDefPtr def) { if (!def) return; virDomainDeviceInfoClear(&def->info); VIR_FREE(def->source.evdev); VIR_FREE(def->virtio); VIR_FREE(def); }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
237,339,978,112,959,250,000,000,000,000,000,000,000
10
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <hhan@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char buf[32]; unsigned int len; len = sprintf(buf, "%ld\n", tlb_single_page_flush_ceiling); return simple_read_from_buffer(user_buf, count, ppos, buf, len); }
0
[ "CWE-362" ]
linux
71b3c126e61177eb693423f2e18a1914205b165e
23,801,901,871,415,734,000,000,000,000,000,000,000
9
x86/mm: Add barriers and document switch_mm()-vs-flush synchronization When switch_mm() activates a new PGD, it also sets a bit that tells other CPUs that the PGD is in use so that TLB flush IPIs will be sent. In order for that to work correctly, the bit needs to be visible prior to loading the PGD and therefore starting to fill the local TLB. Document all the barriers that make this work correctly and add a couple that were missing. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-mm@kvack.org Cc: stable@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
bool CSteamNetworkConnectionUDP::BBeginAccept( CSteamNetworkListenSocketDirectUDP *pParent, const netadr_t &adrFrom, CSharedSocket *pSharedSock, const SteamNetworkingIdentity &identityRemote, uint32 unConnectionIDRemote, const CMsgSteamDatagramCertificateSigned &msgCert, const CMsgSteamDatagramSessionCryptInfoSigned &msgCryptSessionInfo, SteamDatagramErrMsg &errMsg ) { AssertMsg( !m_pTransport, "Trying to accept when we already have transport?" ); // Setup transport CConnectionTransportUDP *pTransport = new CConnectionTransportUDP( *this ); if ( !pTransport->BAccept( pSharedSock, adrFrom, errMsg ) ) { pTransport->TransportDestroySelfNow(); return false; } m_pTransport = pTransport; m_identityRemote = identityRemote; // Caller should have ensured a valid identity Assert( !m_identityRemote.IsInvalid() ); m_unConnectionIDRemote = unConnectionIDRemote; if ( !pParent->BAddChildConnection( this, errMsg ) ) return false; // Let base class do some common initialization SteamNetworkingMicroseconds usecNow = SteamNetworkingSockets_GetLocalTimestamp(); if ( !CSteamNetworkConnectionBase::BInitConnection( usecNow, 0, nullptr, errMsg ) ) { DestroyTransport(); return false; } // Process crypto handshake now if ( !BRecvCryptoHandshake( msgCert, msgCryptSessionInfo, true ) ) { DestroyTransport(); Assert( GetState() == k_ESteamNetworkingConnectionState_ProblemDetectedLocally ); V_sprintf_safe( errMsg, "Failed crypto init. %s", m_szEndDebug ); return false; } // Start the connection state machine return BConnectionState_Connecting( usecNow, errMsg ); }
0
[ "CWE-703" ]
GameNetworkingSockets
d944a10808891d202bb1d5e1998de6e0423af678
224,142,327,983,614,340,000,000,000,000,000,000,000
51
Tweak pointer math to avoid possible integer overflow
static void fwnet_remove(struct fw_unit *unit) { struct fwnet_peer *peer = dev_get_drvdata(&unit->device); struct fwnet_device *dev = peer->dev; struct net_device *net; int i; mutex_lock(&fwnet_device_mutex); net = dev->netdev; fwnet_remove_peer(peer, dev); if (list_empty(&dev->peer_list)) { unregister_netdev(net); fwnet_fifo_stop(dev); for (i = 0; dev->queued_datagrams && i < 5; i++) ssleep(1); WARN_ON(dev->queued_datagrams); list_del(&dev->dev_link); free_netdev(net); } mutex_unlock(&fwnet_device_mutex); }
0
[ "CWE-119", "CWE-284", "CWE-787" ]
linux
667121ace9dbafb368618dbabcf07901c962ddac
183,275,235,350,997,300,000,000,000,000,000,000,000
28
firewire: net: guard against rx buffer overflows The IP-over-1394 driver firewire-net lacked input validation when handling incoming fragmented datagrams. A maliciously formed fragment with a respectively large datagram_offset would cause a memcpy past the datagram buffer. So, drop any packets carrying a fragment with offset + length larger than datagram_size. In addition, ensure that - GASP header, unfragmented encapsulation header, or fragment encapsulation header actually exists before we access it, - the encapsulated datagram or fragment is of nonzero size. Reported-by: Eyal Itkin <eyal.itkin@gmail.com> Reviewed-by: Eyal Itkin <eyal.itkin@gmail.com> Fixes: CVE 2016-8633 Cc: stable@vger.kernel.org Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen) { void *addr; /* * VMAP_STACK (at least) puts stack into the vmalloc address space */ if (is_vmalloc_addr(buf)) addr = vmalloc_to_page(buf); else addr = virt_to_page(buf); sg_set_page(sg, addr, buflen, offset_in_page(buf)); }
0
[ "CWE-476" ]
linux
d6f5e358452479fa8a773b5c6ccc9e4ec5a20880
3,494,783,149,816,233,000,000,000,000,000,000,000
13
cifs: fix NULL ptr dereference in smb2_ioctl_query_info() When calling smb2_ioctl_query_info() with invalid smb_query_info::flags, a NULL ptr dereference is triggered when trying to kfree() uninitialised rqst[n].rq_iov array. This also fixes leaked paths that are created in SMB2_open_init() which required SMB2_open_free() to properly free them. Here is a small C reproducer that triggers it #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #define die(s) perror(s), exit(1) #define QUERY_INFO 0xc018cf07 int main(int argc, char *argv[]) { int fd; if (argc < 2) exit(1); fd = open(argv[1], O_RDONLY); if (fd == -1) die("open"); if (ioctl(fd, QUERY_INFO, (uint32_t[]) { 0, 0, 0, 4, 0, 0}) == -1) die("ioctl"); close(fd); return 0; } mount.cifs //srv/share /mnt -o ... gcc repro.c && ./a.out /mnt/f0 [ 1832.124468] CIFS: VFS: \\w22-dc.zelda.test\test Invalid passthru query flags: 0x4 [ 1832.125043] general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI [ 1832.125764] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] [ 1832.126241] CPU: 3 PID: 1133 Comm: a.out Not tainted 5.17.0-rc8 #2 [ 1832.126630] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014 [ 1832.127322] RIP: 0010:smb2_ioctl_query_info+0x7a3/0xe30 [cifs] [ 1832.127749] Code: 00 00 00 fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 6c 05 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 74 24 28 4c 89 f2 48 c1 ea 03 <80> 3c 02 00 0f 85 cb 04 00 00 49 8b 3e e8 bb fc fa ff 48 89 da 48 [ 1832.128911] RSP: 0018:ffffc90000957b08 EFLAGS: 00010256 [ 1832.129243] RAX: dffffc0000000000 RBX: ffff888117e9b850 RCX: ffffffffa020580d [ 1832.129691] RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffffa043a2c0 [ 1832.130137] RBP: ffff888117e9b878 R08: 0000000000000001 R09: 0000000000000003 [ 1832.130585] R10: fffffbfff4087458 R11: 0000000000000001 R12: ffff888117e9b800 [ 1832.131037] R13: 00000000ffffffea R14: 0000000000000000 R15: ffff888117e9b8a8 [ 1832.131485] FS: 00007fcee9900740(0000) GS:ffff888151a00000(0000) knlGS:0000000000000000 [ 1832.131993] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1832.132354] CR2: 00007fcee9a1ef5e CR3: 0000000114cd2000 CR4: 0000000000350ee0 [ 1832.132801] Call Trace: [ 1832.132962] <TASK> [ 1832.133104] ? smb2_query_reparse_tag+0x890/0x890 [cifs] [ 1832.133489] ? cifs_mapchar+0x460/0x460 [cifs] [ 1832.133822] ? rcu_read_lock_sched_held+0x3f/0x70 [ 1832.134125] ? cifs_strndup_to_utf16+0x15b/0x250 [cifs] [ 1832.134502] ? lock_downgrade+0x6f0/0x6f0 [ 1832.134760] ? cifs_convert_path_to_utf16+0x198/0x220 [cifs] [ 1832.135170] ? smb2_check_message+0x1080/0x1080 [cifs] [ 1832.135545] cifs_ioctl+0x1577/0x3320 [cifs] [ 1832.135864] ? lock_downgrade+0x6f0/0x6f0 [ 1832.136125] ? cifs_readdir+0x2e60/0x2e60 [cifs] [ 1832.136468] ? rcu_read_lock_sched_held+0x3f/0x70 [ 1832.136769] ? __rseq_handle_notify_resume+0x80b/0xbe0 [ 1832.137096] ? __up_read+0x192/0x710 [ 1832.137327] ? __ia32_sys_rseq+0xf0/0xf0 [ 1832.137578] ? __x64_sys_openat+0x11f/0x1d0 [ 1832.137850] __x64_sys_ioctl+0x127/0x190 [ 1832.138103] do_syscall_64+0x3b/0x90 [ 1832.138378] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 1832.138702] RIP: 0033:0x7fcee9a253df [ 1832.138937] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00 [ 1832.140107] RSP: 002b:00007ffeba94a8a0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 1832.140606] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fcee9a253df [ 1832.141058] RDX: 00007ffeba94a910 RSI: 00000000c018cf07 RDI: 0000000000000003 [ 1832.141503] RBP: 00007ffeba94a930 R08: 00007fcee9b24db0 R09: 00007fcee9b45c4e [ 1832.141948] R10: 00007fcee9918d40 R11: 0000000000000246 R12: 00007ffeba94aa48 [ 1832.142396] R13: 0000000000401176 R14: 0000000000403df8 R15: 00007fcee9b78000 [ 1832.142851] </TASK> [ 1832.142994] Modules linked in: cifs cifs_arc4 cifs_md4 bpf_preload [last unloaded: cifs] Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
TEST_F(ExpressionNaryTest, GroupingOptimizationOnAssociativeOnlyNotExecuteOnSingleConstantsBack) { BSONArray spec = BSON_ARRAY("$path" << 55); addOperandArrayToExpr(_associativeOnly, spec); assertContents(_associativeOnly, spec); intrusive_ptr<Expression> optimized = _associativeOnly->optimize(); ASSERT(_associativeOnly == optimized); assertContents(_associativeOnly, BSON_ARRAY("$path" << 55)); }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
336,184,152,400,771,970,000,000,000,000,000,000,000
8
SERVER-38070 fix infinite loop in agg expression
int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) { WARN_ON(mm == NULL); return security_ops->vm_enough_memory(mm, pages); }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
263,465,344,747,992,300,000,000,000,000,000,000,000
5
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>
congestion_control_init(congestion_control_t *cc, const circuit_params_t *params, cc_path_t path) { cc->sendme_pending_timestamps = smartlist_new(); cc->sendme_arrival_timestamps = smartlist_new(); cc->in_slow_start = 1; congestion_control_init_params(cc, params, path); cc->next_cc_event = CWND_UPDATE_RATE(cc); }
0
[]
tor
b0496d40197dd5b4fb7b694c1410082d4e34dda6
113,303,769,819,035,550,000,000,000,000,000,000,000
12
Fix for RTT calculation hang during congestion control. Only cache RTT on explicit stalls; Only use this cache for the RTT decrease case. Otherwise use only local circuit RTT state for clock jump checks.
kssl_tgt_is_available(KSSL_CTX *kssl_ctx) { krb5_error_code krb5rc = KRB5KRB_ERR_GENERIC; krb5_context krb5context = NULL; krb5_ccache krb5ccdef = NULL; krb5_creds krb5creds, *krb5credsp = NULL; int rc = 0; memset((char *)&krb5creds, 0, sizeof(krb5creds)); if (!kssl_ctx) return(0); if (!kssl_ctx->service_host) return(0); if ((krb5rc = krb5_init_context(&krb5context)) != 0) goto err; if ((krb5rc = krb5_sname_to_principal(krb5context, kssl_ctx->service_host, (kssl_ctx->service_name)? kssl_ctx->service_name: KRB5SVC, KRB5_NT_SRV_HST, &krb5creds.server)) != 0) goto err; if ((krb5rc = krb5_cc_default(krb5context, &krb5ccdef)) != 0) goto err; if ((krb5rc = krb5_cc_get_principal(krb5context, krb5ccdef, &krb5creds.client)) != 0) goto err; if ((krb5rc = krb5_get_credentials(krb5context, 0, krb5ccdef, &krb5creds, &krb5credsp)) != 0) goto err; rc = 1; err: #ifdef KSSL_DEBUG kssl_ctx_show(kssl_ctx); #endif /* KSSL_DEBUG */ if (krb5creds.client) krb5_free_principal(krb5context, krb5creds.client); if (krb5creds.server) krb5_free_principal(krb5context, krb5creds.server); if (krb5context) krb5_free_context(krb5context); return(rc); }
0
[ "CWE-20" ]
openssl
cca1cd9a3447dd067503e4a85ebd1679ee78a48e
26,146,682,338,263,900,000,000,000,000,000,000,000
48
Submitted by: Tomas Hoger <thoger@redhat.com> Fix for CVE-2010-0433 where some kerberos enabled versions of OpenSSL could be crashed if the relevant tables were not present (e.g. chrooted).
struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper) { struct dentry *realdentry; realdentry = ovl_upperdentry_dereference(oe); if (realdentry) { *is_upper = true; } else { realdentry = oe->lowerdentry; *is_upper = false; } return realdentry; }
0
[ "CWE-284", "CWE-264" ]
linux
69c433ed2ecd2d3264efd7afec4439524b319121
61,750,705,353,684,010,000,000,000,000,000,000,000
13
fs: limit filesystem stacking depth Add a simple read-only counter to super_block that indicates how deep this is in the stack of filesystems. Previously ecryptfs was the only stackable filesystem and it explicitly disallowed multiple layers of itself. Overlayfs, however, can be stacked recursively and also may be stacked on top of ecryptfs or vice versa. To limit the kernel stack usage we must limit the depth of the filesystem stack. Initially the limit is set to 2. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
static String* Pe_r_bin_pe_parse_string(struct PE_(r_bin_pe_obj_t)* bin, PE_DWord* curAddr) { String* string = calloc (1, sizeof(*string)); PE_DWord begAddr = *curAddr; int len_value = 0; int i = 0; if (!string) { bprintf ("Warning: calloc (String)\n"); return NULL; } if (begAddr > bin->size || begAddr + sizeof(string->wLength) > bin->size) { free_String (string); return NULL; } if (r_buf_read_at (bin->b, *curAddr, (ut8*) &string->wLength, sizeof(string->wLength)) != sizeof(string->wLength)) { bprintf ("Warning: read (String wLength)\n"); goto out_error; } *curAddr += sizeof(string->wLength); if (*curAddr > bin->size || *curAddr + sizeof(string->wValueLength) > bin->size) { goto out_error; } if (r_buf_read_at (bin->b, *curAddr, (ut8*) &string->wValueLength, sizeof(string->wValueLength)) != sizeof(string->wValueLength)) { bprintf ("Warning: read (String wValueLength)\n"); goto out_error; } *curAddr += sizeof(string->wValueLength); if (*curAddr > bin->size || *curAddr + sizeof(string->wType) > bin->size) { goto out_error; } if (r_buf_read_at (bin->b, *curAddr, (ut8*) &string->wType, sizeof(string->wType)) != sizeof(string->wType)) { bprintf ("Warning: read (String wType)\n"); goto out_error; } *curAddr += sizeof(string->wType); if (string->wType != 0 && string->wType != 1) { bprintf ("Warning: check (String wType)\n"); goto out_error; } for (i = 0; *curAddr < begAddr + string->wLength; ++i, *curAddr += sizeof (ut16)) { ut16 utf16_char; if (*curAddr > bin->size || *curAddr + sizeof (ut16) > bin->size) { goto out_error; } if (r_buf_read_at (bin->b, *curAddr, (ut8*) &utf16_char, sizeof (ut16)) != sizeof (ut16)) { bprintf ("Warning: check (String szKey)\n"); goto out_error; } string->szKey = (ut16*) realloc (string->szKey, (i + 1) * sizeof (ut16)); string->szKey[i] = utf16_char; string->wKeyLen += sizeof (ut16); if (!utf16_char) { *curAddr += sizeof (ut16); break; } } align32 (*curAddr); len_value = R_MIN (string->wValueLength * 2, string->wLength - (*curAddr - begAddr)); string->wValueLength = len_value; if (len_value < 0) { len_value = 0; } string->Value = (ut16*) calloc (len_value + 1, 1); if (!string->Value) { bprintf ("Warning: malloc (String Value)\n"); goto out_error; } if (*curAddr > bin->size || *curAddr + len_value > bin->size) { goto out_error; } if (r_buf_read_at (bin->b, *curAddr, (ut8*) string->Value, len_value) != len_value) { bprintf ("Warning: read (String Value)\n"); goto out_error; } *curAddr += len_value; return string; out_error: free_String (string); return NULL; }
0
[ "CWE-125" ]
radare2
4e1cf0d3e6f6fe2552a269def0af1cd2403e266c
234,554,764,011,263,940,000,000,000,000,000,000,000
81
Fix crash in pe
glob_func_error(VALUE val) { struct glob_error_args *arg = (struct glob_error_args *)val; VALUE path = rb_enc_str_new_cstr(arg->path, arg->enc); rb_syserr_fail_str(arg->error, path); return Qnil; }
0
[ "CWE-22" ]
ruby
bd5661a3cbb38a8c3a3ea10cd76c88bbef7871b8
164,057,602,225,359,800,000,000,000,000,000,000,000
7
dir.c: check NUL bytes * dir.c (GlobPathValue): should be used in rb_push_glob only. other methods should use FilePathValue. https://hackerone.com/reports/302338 * dir.c (rb_push_glob): expand GlobPathValue git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
int ipmi_set_my_LUN(struct ipmi_user *user, unsigned int channel, unsigned char LUN) { int index, rv = 0; user = acquire_ipmi_user(user, &index); if (!user) return -ENODEV; if (channel >= IPMI_MAX_CHANNELS) { rv = -EINVAL; } else { channel = array_index_nospec(channel, IPMI_MAX_CHANNELS); user->intf->addrinfo[channel].lun = LUN & 0x3; } release_ipmi_user(user, index); return rv; }
0
[ "CWE-416", "CWE-284" ]
linux
77f8269606bf95fcb232ee86f6da80886f1dfae8
166,266,362,563,834,550,000,000,000,000,000,000,000
20
ipmi: fix use-after-free of user->release_barrier.rda When we do the following test, we got oops in ipmi_msghandler driver while((1)) do service ipmievd restart & service ipmievd restart done --------------------------------------------------------------- [ 294.230186] Unable to handle kernel paging request at virtual address 0000803fea6ea008 [ 294.230188] Mem abort info: [ 294.230190] ESR = 0x96000004 [ 294.230191] Exception class = DABT (current EL), IL = 32 bits [ 294.230193] SET = 0, FnV = 0 [ 294.230194] EA = 0, S1PTW = 0 [ 294.230195] Data abort info: [ 294.230196] ISV = 0, ISS = 0x00000004 [ 294.230197] CM = 0, WnR = 0 [ 294.230199] user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000a1c1b75a [ 294.230201] [0000803fea6ea008] pgd=0000000000000000 [ 294.230204] Internal error: Oops: 96000004 [#1] SMP [ 294.235211] Modules linked in: nls_utf8 isofs rpcrdma ib_iser ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_umad rdma_cm ib_cm iw_cm dm_mirror dm_region_hash dm_log dm_mod aes_ce_blk crypto_simd cryptd aes_ce_cipher ghash_ce sha2_ce ses sha256_arm64 sha1_ce hibmc_drm hisi_sas_v2_hw enclosure sg hisi_sas_main sbsa_gwdt ip_tables mlx5_ib ib_uverbs marvell ib_core mlx5_core ixgbe ipmi_si mdio hns_dsaf ipmi_devintf ipmi_msghandler hns_enet_drv hns_mdio [ 294.277745] CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Not tainted 5.0.0-rc2+ #113 [ 294.285511] Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.37 11/21/2017 [ 294.292835] pstate: 80000005 (Nzcv daif -PAN -UAO) [ 294.297695] pc : __srcu_read_lock+0x38/0x58 [ 294.301940] lr : acquire_ipmi_user+0x2c/0x70 [ipmi_msghandler] [ 294.307853] sp : ffff00001001bc80 [ 294.311208] x29: ffff00001001bc80 x28: ffff0000117e5000 [ 294.316594] x27: 0000000000000000 x26: dead000000000100 [ 294.321980] x25: dead000000000200 x24: ffff803f6bd06800 [ 294.327366] x23: 0000000000000000 x22: 0000000000000000 [ 294.332752] x21: ffff00001001bd04 x20: ffff80df33d19018 [ 294.338137] x19: ffff80df33d19018 x18: 0000000000000000 [ 294.343523] x17: 0000000000000000 x16: 0000000000000000 [ 294.348908] x15: 0000000000000000 x14: 0000000000000002 [ 294.354293] x13: 0000000000000000 x12: 0000000000000000 [ 294.359679] x11: 0000000000000000 x10: 0000000000100000 [ 294.365065] x9 : 0000000000000000 x8 : 0000000000000004 [ 294.370451] x7 : 0000000000000000 x6 : ffff80df34558678 [ 294.375836] x5 : 000000000000000c x4 : 0000000000000000 [ 294.381221] x3 : 0000000000000001 x2 : 0000803fea6ea000 [ 294.386607] x1 : 0000803fea6ea008 x0 : 0000000000000001 [ 294.391994] Process swapper/3 (pid: 0, stack limit = 0x0000000083087293) [ 294.398791] Call trace: [ 294.401266] __srcu_read_lock+0x38/0x58 [ 294.405154] acquire_ipmi_user+0x2c/0x70 [ipmi_msghandler] [ 294.410716] deliver_response+0x80/0xf8 [ipmi_msghandler] [ 294.416189] deliver_local_response+0x28/0x68 [ipmi_msghandler] [ 294.422193] handle_one_recv_msg+0x158/0xcf8 [ipmi_msghandler] [ 294.432050] handle_new_recv_msgs+0xc0/0x210 [ipmi_msghandler] [ 294.441984] smi_recv_tasklet+0x8c/0x158 [ipmi_msghandler] [ 294.451618] tasklet_action_common.isra.5+0x88/0x138 [ 294.460661] tasklet_action+0x2c/0x38 [ 294.468191] __do_softirq+0x120/0x2f8 [ 294.475561] irq_exit+0x134/0x140 [ 294.482445] __handle_domain_irq+0x6c/0xc0 [ 294.489954] gic_handle_irq+0xb8/0x178 [ 294.497037] el1_irq+0xb0/0x140 [ 294.503381] arch_cpu_idle+0x34/0x1a8 [ 294.510096] do_idle+0x1d4/0x290 [ 294.516322] cpu_startup_entry+0x28/0x30 [ 294.523230] secondary_start_kernel+0x184/0x1d0 [ 294.530657] Code: d538d082 d2800023 8b010c81 8b020021 (c85f7c25) [ 294.539746] ---[ end trace 8a7a880dee570b29 ]--- [ 294.547341] Kernel panic - not syncing: Fatal exception in interrupt [ 294.556837] SMP: stopping secondary CPUs [ 294.563996] Kernel Offset: disabled [ 294.570515] CPU features: 0x002,21006008 [ 294.577638] Memory Limit: none [ 294.587178] Starting crashdump kernel... [ 294.594314] Bye! Because the user->release_barrier.rda is freed in ipmi_destroy_user(), but the refcount is not zero, when acquire_ipmi_user() uses user->release_barrier.rda in __srcu_read_lock(), it causes oops. Fix this by calling cleanup_srcu_struct() when the refcount is zero. Fixes: e86ee2d44b44 ("ipmi: Rework locking and shutdown for hot remove") Cc: stable@vger.kernel.org # 4.18 Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Corey Minyard <cminyard@mvista.com>
irc_server_set_host (struct t_irc_server *server, const char *host) { struct t_irc_channel *ptr_channel; /* if host is the same, just return */ if ((!server->host && !host) || (server->host && host && strcmp (server->host, host) == 0)) { return; } /* update the nick host in server */ if (server->host) free (server->host); server->host = (host) ? strdup (host) : NULL; /* set local variable "host" for server and all channels/pv */ weechat_buffer_set (server->buffer, "localvar_set_host", host); for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { weechat_buffer_set (ptr_channel->buffer, "localvar_set_host", host); } weechat_bar_item_update ("irc_host"); weechat_bar_item_update ("irc_nick_host"); }
0
[ "CWE-120", "CWE-787" ]
weechat
40ccacb4330a64802b1f1e28ed9a6b6d3ca9197f
282,281,645,955,468,200,000,000,000,000,000,000,000
28
irc: fix crash when a new message 005 is received with longer nick prefixes Thanks to Stuart Nevans Locke for reporting the issue.
static int crypto_pcomp_init(struct crypto_tfm *tfm, u32 type, u32 mask) { return 0; }
0
[ "CWE-310" ]
linux
9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6
147,664,987,213,752,340,000,000,000,000,000,000,000
4
crypto: user - fix info leaks in report API Three errors resulting in kernel memory disclosure: 1/ The structures used for the netlink based crypto algorithm report API are located on the stack. As snprintf() does not fill the remainder of the buffer with null bytes, those stack bytes will be disclosed to users of the API. Switch to strncpy() to fix this. 2/ crypto_report_one() does not initialize all field of struct crypto_user_alg. Fix this to fix the heap info leak. 3/ For the module name we should copy only as many bytes as module_name() returns -- not as much as the destination buffer could hold. But the current code does not and therefore copies random data from behind the end of the module name, as the module name is always shorter than CRYPTO_MAX_ALG_NAME. Also switch to use strncpy() to copy the algorithm's name and driver_name. They are strings, after all. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
**/ CImgList():
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
148,572,735,456,648,060,000,000,000,000,000,000,000
2
Fix other issues in 'CImg<T>::load_bmp()'.
unsigned int iucv_sock_poll(struct file *file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; unsigned int mask = 0; sock_poll_wait(file, sk_sleep(sk), wait); if (sk->sk_state == IUCV_LISTEN) return iucv_accept_poll(sk); if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) mask |= POLLERR | (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0); if (sk->sk_shutdown & RCV_SHUTDOWN) mask |= POLLRDHUP; if (sk->sk_shutdown == SHUTDOWN_MASK) mask |= POLLHUP; if (!skb_queue_empty(&sk->sk_receive_queue) || (sk->sk_shutdown & RCV_SHUTDOWN)) mask |= POLLIN | POLLRDNORM; if (sk->sk_state == IUCV_CLOSED) mask |= POLLHUP; if (sk->sk_state == IUCV_DISCONN) mask |= POLLIN; if (sock_writeable(sk) && iucv_below_msglim(sk)) mask |= POLLOUT | POLLWRNORM | POLLWRBAND; else set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); return mask; }
0
[ "CWE-20", "CWE-269" ]
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
266,043,790,386,285,540,000,000,000,000,000,000,000
38
net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
xfrm_state_lookup(struct net *net, u32 mark, const xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family) { struct xfrm_state *x; rcu_read_lock(); x = __xfrm_state_lookup(net, mark, daddr, spi, proto, family); rcu_read_unlock(); return x; }
0
[ "CWE-416" ]
linux
dbb2483b2a46fbaf833cfb5deb5ed9cace9c7399
106,215,368,509,155,800,000,000,000,000,000,000,000
10
xfrm: clean up xfrm protocol checks In commit 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") I introduced a check for xfrm protocol, but according to Herbert IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so it should be removed from validate_tmpl(). And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific protocols, this is why xfrm_state_flush() could still miss IPPROTO_ROUTING, which leads that those entries are left in net->xfrm.state_all before exit net. Fix this by replacing IPSEC_PROTO_ANY with zero. This patch also extracts the check from validate_tmpl() to xfrm_id_proto_valid() and uses it in parse_ipsecrequest(). With this, no other protocols should be added into xfrm. Fixes: 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") Reported-by: syzbot+0bf0519d6e0de15914fe@syzkaller.appspotmail.com Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
int security_syslog(int type) { return security_ops->syslog(type); }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
207,415,667,638,984,660,000,000,000,000,000,000,000
4
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>
bool ha_partition::initialize_partition(MEM_ROOT *mem_root) { handler **file_array, *file; ulonglong check_table_flags; DBUG_ENTER("ha_partition::initialize_partition"); if (m_create_handler) { m_tot_parts= m_part_info->get_tot_partitions(); DBUG_ASSERT(m_tot_parts > 0); if (new_handlers_from_part_info(mem_root)) DBUG_RETURN(1); } else if (!table_share || !table_share->normalized_path.str) { /* Called with dummy table share (delete, rename and alter table). Don't need to set-up anything. */ DBUG_RETURN(0); } else if (get_from_handler_file(table_share->normalized_path.str, mem_root, false)) { my_error(ER_FAILED_READ_FROM_PAR_FILE, MYF(0)); DBUG_RETURN(1); } /* We create all underlying table handlers here. We do it in this special method to be able to report allocation errors. Set up primary_key_is_clustered and has_transactions since they are called often in all kinds of places, other parameters are calculated on demand. Verify that all partitions have the same table_flags. */ check_table_flags= m_file[0]->ha_table_flags(); m_pkey_is_clustered= TRUE; file_array= m_file; do { file= *file_array; if (!file->primary_key_is_clustered()) m_pkey_is_clustered= FALSE; if (check_table_flags != file->ha_table_flags()) { my_error(ER_MIX_HANDLER_ERROR, MYF(0)); DBUG_RETURN(1); } } while (*(++file_array)); m_handler_status= handler_initialized; DBUG_RETURN(0); }
0
[]
server
f305a7ce4bccbd56520d874e1d81a4f29bc17a96
169,860,518,244,737,900,000,000,000,000,000,000,000
53
bugfix: long partition names
init_write_reg( int name, yankreg_T **old_y_previous, yankreg_T **old_y_current, int must_append, int *yank_type UNUSED) { if (!valid_yank_reg(name, TRUE)) // check for valid reg name { emsg_invreg(name); return FAIL; } // Don't want to change the current (unnamed) register *old_y_previous = y_previous; *old_y_current = y_current; get_yank_register(name, TRUE); if (!y_append && !must_append) free_yank_all(); return OK; }
0
[ "CWE-122", "CWE-787" ]
vim
d25f003342aca9889067f2e839963dfeccf1fe05
299,550,476,032,393,100,000,000,000,000,000,000,000
22
patch 9.0.0011: reading beyond the end of the line with put command Problem: Reading beyond the end of the line with put command. Solution: Adjust the end mark position.
static json_t *json_object_deep_copy(const json_t *object) { json_t *result; void *iter; result = json_object(); if(!result) return NULL; /* Cannot use json_object_foreach because object has to be cast non-const */ iter = json_object_iter((json_t *)object); while(iter) { const char *key; const json_t *value; key = json_object_iter_key(iter); value = json_object_iter_value(iter); json_object_set_new_nocheck(result, key, json_deep_copy(value)); iter = json_object_iter_next((json_t *)object, iter); } return result; }
0
[ "CWE-310" ]
jansson
8f80c2d83808150724d31793e6ade92749b1faa4
198,512,818,646,698,080,000,000,000,000,000,000,000
24
CVE-2013-6401: Change hash function, randomize hashes Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing and testing.
static int mmap_ureg(struct vm_area_struct *vma, struct qib_devdata *dd, u64 ureg) { unsigned long phys; unsigned long sz; int ret; /* * This is real hardware, so use io_remap. This is the mechanism * for the user process to update the head registers for their ctxt * in the chip. */ sz = dd->flags & QIB_HAS_HDRSUPP ? 2 * PAGE_SIZE : PAGE_SIZE; if ((vma->vm_end - vma->vm_start) > sz) { qib_devinfo(dd->pcidev, "FAIL mmap userreg: reqlen %lx > PAGE\n", vma->vm_end - vma->vm_start); ret = -EFAULT; } else { phys = dd->physaddr + ureg; vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND; ret = io_remap_pfn_range(vma, vma->vm_start, phys >> PAGE_SHIFT, vma->vm_end - vma->vm_start, vma->vm_page_prot); } return ret; }
0
[ "CWE-284", "CWE-264" ]
linux
e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3
325,892,051,447,840,600,000,000,000,000,000,000,000
30
IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [ Expanded check to all known write() entry points ] Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com>
xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) { return(xmlHashAddEntry3(table, name, NULL, NULL, userdata)); }
0
[ "CWE-399" ]
libxml2
8973d58b7498fa5100a876815476b81fd1a2412a
148,906,882,834,292,230,000,000,000,000,000,000,000
3
Add hash randomization to hash and dict structures Following http://www.ocert.org/advisories/ocert-2011-003.html it seems that having hash randomization might be a good idea when using XML with untrusted data * configure.in: lookup for rand, srand and time * dict.c: add randomization to dictionaries hash tables * hash.c: add randomization to normal hash tables
static struct bsg_command *bsg_alloc_command(struct bsg_device *bd) { struct bsg_command *bc = ERR_PTR(-EINVAL); spin_lock_irq(&bd->lock); if (bd->queued_cmds >= bd->max_queue) goto out; bd->queued_cmds++; spin_unlock_irq(&bd->lock); bc = kmem_cache_zalloc(bsg_cmd_cachep, GFP_KERNEL); if (unlikely(!bc)) { spin_lock_irq(&bd->lock); bd->queued_cmds--; bc = ERR_PTR(-ENOMEM); goto out; } bc->bd = bd; INIT_LIST_HEAD(&bc->list); dprintk("%s: returning free cmd %p\n", bd->name, bc); return bc; out: spin_unlock_irq(&bd->lock); return bc; }
0
[ "CWE-399" ]
linux-2.6
f2f1fa78a155524b849edf359e42a3001ea652c0
83,903,343,827,894,920,000,000,000,000,000,000,000
28
Enforce a minimum SG_IO timeout There's no point in having too short SG_IO timeouts, since if the command does end up timing out, we'll end up through the reset sequence that is several seconds long in order to abort the command that timed out. As a result, shorter timeouts than a few seconds simply do not make sense, as the recovery would be longer than the timeout itself. Add a BLK_MIN_SG_TIMEOUT to match the existign BLK_DEFAULT_SG_TIMEOUT. Suggested-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Jens Axboe <jens.axboe@oracle.com> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
static inline struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again) { return skb; }
0
[ "CWE-416" ]
linux
dbb2483b2a46fbaf833cfb5deb5ed9cace9c7399
60,852,953,061,237,295,000,000,000,000,000,000,000
4
xfrm: clean up xfrm protocol checks In commit 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") I introduced a check for xfrm protocol, but according to Herbert IPSEC_PROTO_ANY should only be used as a wildcard for lookup, so it should be removed from validate_tmpl(). And, IPSEC_PROTO_ANY is expected to only match 3 IPSec-specific protocols, this is why xfrm_state_flush() could still miss IPPROTO_ROUTING, which leads that those entries are left in net->xfrm.state_all before exit net. Fix this by replacing IPSEC_PROTO_ANY with zero. This patch also extracts the check from validate_tmpl() to xfrm_id_proto_valid() and uses it in parse_ipsecrequest(). With this, no other protocols should be added into xfrm. Fixes: 6a53b7593233 ("xfrm: check id proto in validate_tmpl()") Reported-by: syzbot+0bf0519d6e0de15914fe@syzkaller.appspotmail.com Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
static int shmem_remount_fs(struct super_block *sb, int *flags, char *data) { struct shmem_sb_info *sbinfo = SHMEM_SB(sb); struct shmem_sb_info config = *sbinfo; unsigned long blocks; unsigned long inodes; int error = -EINVAL; if (shmem_parse_options(data, &config, true)) return error; spin_lock(&sbinfo->stat_lock); blocks = sbinfo->max_blocks - sbinfo->free_blocks; inodes = sbinfo->max_inodes - sbinfo->free_inodes; if (config.max_blocks < blocks) goto out; if (config.max_inodes < inodes) goto out; /* * Those tests also disallow limited->unlimited while any are in * use, so i_blocks will always be zero when max_blocks is zero; * but we must separately disallow unlimited->limited, because * in that case we have no record of how much is already in use. */ if (config.max_blocks && !sbinfo->max_blocks) goto out; if (config.max_inodes && !sbinfo->max_inodes) goto out; error = 0; sbinfo->max_blocks = config.max_blocks; sbinfo->free_blocks = config.max_blocks - blocks; sbinfo->max_inodes = config.max_inodes; sbinfo->free_inodes = config.max_inodes - inodes; mpol_put(sbinfo->mpol); sbinfo->mpol = config.mpol; /* transfers initial ref */ out: spin_unlock(&sbinfo->stat_lock); return error; }
0
[ "CWE-400" ]
linux-2.6
14fcc23fdc78e9d32372553ccf21758a9bd56fa1
85,681,055,874,180,990,000,000,000,000,000,000,000
41
tmpfs: fix kernel BUG in shmem_delete_inode SuSE's insserve initscript ordering program hits kernel BUG at mm/shmem.c:814 on 2.6.26. It's using posix_fadvise on directories, and the shmem_readpage method added in 2.6.23 is letting POSIX_FADV_WILLNEED allocate useless pages to a tmpfs directory, incrementing i_blocks count but never decrementing it. Fix this by assigning shmem_aops (pointing to readpage and writepage and set_page_dirty) only when it's needed, on a regular file or a long symlink. Many thanks to Kel for outstanding bugreport and steps to reproduce it. Reported-by: Kel Modderman <kel@otaku42.de> Tested-by: Kel Modderman <kel@otaku42.de> Signed-off-by: Hugh Dickins <hugh@veritas.com> Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
static errno_t sssctl_restore(bool force_start, bool force_restart) { errno_t ret; if (!sssctl_start_sssd(force_start)) { return ERR_SSSD_NOT_RUNNING; } if (sssctl_backup_file_exists(SSS_BACKUP_USER_OVERRIDES)) { ret = sssctl_run_command((const char *[]){"sss_override", "user-import", SSS_BACKUP_USER_OVERRIDES, NULL}); if (ret != EOK) { ERROR("Unable to import user overrides\n"); return ret; } } if (sssctl_backup_file_exists(SSS_BACKUP_USER_OVERRIDES)) { ret = sssctl_run_command((const char *[]){"sss_override", "group-import", SSS_BACKUP_GROUP_OVERRIDES, NULL}); if (ret != EOK) { ERROR("Unable to import group overrides\n"); return ret; } } sssctl_restart_sssd(force_restart); ret = EOK; return ret; }
0
[ "CWE-78" ]
sssd
7ab83f97e1cbefb78ece17232185bdd2985f0bbe
154,674,701,828,439,540,000,000,000,000,000,000,000
32
TOOLS: replace system() with execvp() to avoid execution of user supplied command :relnote: A flaw was found in SSSD, where the sssctl command was vulnerable to shell command injection via the logs-fetch and cache-expire subcommands. This flaw allows an attacker to trick the root user into running a specially crafted sssctl command, such as via sudo, to gain root access. The highest threat from this vulnerability is to confidentiality, integrity, as well as system availability. This patch fixes a flaw by replacing system() with execvp(). :fixes: CVE-2021-3621 Reviewed-by: Pavel Březina <pbrezina@redhat.com>
thread_specific_data(void *private_data) { xmlDocPtr myDoc; const char *filename = (const char *) private_data; int okay = 1; if (!strcmp(filename, "test/threads/invalid.xml")) { xmlDoValidityCheckingDefaultValue = 0; xmlGenericErrorContext = stdout; } else { xmlDoValidityCheckingDefaultValue = 1; xmlGenericErrorContext = stderr; } myDoc = xmlParseFile(filename); if (myDoc) { xmlFreeDoc(myDoc); } else { printf("parse failed\n"); okay = 0; } if (!strcmp(filename, "test/threads/invalid.xml")) { if (xmlDoValidityCheckingDefaultValue != 0) { printf("ValidityCheckingDefaultValue override failed\n"); okay = 0; } if (xmlGenericErrorContext != stdout) { printf("xmlGenericErrorContext override failed\n"); okay = 0; } } else { if (xmlDoValidityCheckingDefaultValue != 1) { printf("ValidityCheckingDefaultValue override failed\n"); okay = 0; } if (xmlGenericErrorContext != stderr) { printf("xmlGenericErrorContext override failed\n"); okay = 0; } } if (okay == 0) return ((void *) Failed); return ((void *) Okay); }
0
[ "CWE-125" ]
libxml2
a820dbeac29d330bae4be05d9ecd939ad6b4aa33
44,216,203,358,287,320,000,000,000,000,000,000,000
43
Bug 758605: Heap-based buffer overread in xmlDictAddString <https://bugzilla.gnome.org/show_bug.cgi?id=758605> Reviewed by David Kilzer. * HTMLparser.c: (htmlParseName): Add bounds check. (htmlParseNameComplex): Ditto. * result/HTML/758605.html: Added. * result/HTML/758605.html.err: Added. * result/HTML/758605.html.sax: Added. * runtest.c: (pushParseTest): The input for the new test case was so small (4 bytes) that htmlParseChunk() was never called after htmlCreatePushParserCtxt(), thereby creating a false positive test failure. Fixed by using a do-while loop so we always call htmlParseChunk() at least once. * test/HTML/758605.html: Added.
void fsck_set_msg_types(struct fsck_options *options, const char *values) { char *buf = xstrdup(values), *to_free = buf; int done = 0; while (!done) { int len = strcspn(buf, " ,|"), equal; done = !buf[len]; if (!len) { buf++; continue; } buf[len] = '\0'; for (equal = 0; equal < len && buf[equal] != '=' && buf[equal] != ':'; equal++) buf[equal] = tolower(buf[equal]); buf[equal] = '\0'; if (!strcmp(buf, "skiplist")) { if (equal == len) die("skiplist requires a path"); init_skiplist(options, buf + equal + 1); buf += len + 1; continue; } if (equal == len) die("Missing '=': '%s'", buf); fsck_set_msg_type(options, buf, buf + equal + 1); buf += len + 1; } free(to_free); }
0
[ "CWE-20", "CWE-88", "CWE-522" ]
git
a124133e1e6ab5c7a9fef6d0e6bcb084e3455b46
130,448,972,128,989,900,000,000,000,000,000,000,000
37
fsck: detect submodule urls starting with dash Urls with leading dashes can cause mischief on older versions of Git. We should detect them so that they can be rejected by receive.fsckObjects, preventing modern versions of git from being a vector by which attacks can spread. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
static void *m_start(struct seq_file *m, loff_t *pos) { struct proc_mounts *p = proc_mounts(m); down_read(&namespace_sem); return seq_list_start(&p->ns->list, *pos); }
0
[ "CWE-284", "CWE-264" ]
linux
3151527ee007b73a0ebd296010f1c0454a919c7d
308,368,640,005,441,440,000,000,000,000,000,000,000
7
userns: Don't allow creation if the user is chrooted Guarantee that the policy of which files may be access that is established by setting the root directory will not be violated by user namespaces by verifying that the root directory points to the root of the mount namespace at the time of user namespace creation. Changing the root is a privileged operation, and as a matter of policy it serves to limit unprivileged processes to files below the current root directory. For reasons of simplicity and comprehensibility the privilege to change the root directory is gated solely on the CAP_SYS_CHROOT capability in the user namespace. Therefore when creating a user namespace we must ensure that the policy of which files may be access can not be violated by changing the root directory. Anyone who runs a processes in a chroot and would like to use user namespace can setup the same view of filesystems with a mount namespace instead. With this result that this is not a practical limitation for using user namespaces. Cc: stable@vger.kernel.org Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Reported-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
static int ehci_process_itd(EHCIState *ehci, EHCIitd *itd, uint32_t addr) { USBDevice *dev; USBEndpoint *ep; uint32_t i, len, pid, dir, devaddr, endp; uint32_t pg, off, ptr1, ptr2, max, mult; ehci->periodic_sched_active = PERIODIC_ACTIVE; dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION); devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR); endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP); max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT); mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT); for(i = 0; i < 8; i++) { if (itd->transact[i] & ITD_XACT_ACTIVE) { pg = get_field(itd->transact[i], ITD_XACT_PGSEL); off = itd->transact[i] & ITD_XACT_OFFSET_MASK; len = get_field(itd->transact[i], ITD_XACT_LENGTH); if (len > max * mult) { len = max * mult; } if (len > BUFF_SIZE || pg > 6) { return -1; } ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK); qemu_sglist_init(&ehci->isgl, ehci->device, 2, ehci->as); if (off + len > 4096) { /* transfer crosses page border */ if (pg == 6) { qemu_sglist_destroy(&ehci->isgl); return -1; /* avoid page pg + 1 */ } ptr2 = (itd->bufptr[pg + 1] & ITD_BUFPTR_MASK); uint32_t len2 = off + len - 4096; uint32_t len1 = len - len2; qemu_sglist_add(&ehci->isgl, ptr1 + off, len1); qemu_sglist_add(&ehci->isgl, ptr2, len2); } else { qemu_sglist_add(&ehci->isgl, ptr1 + off, len); } dev = ehci_find_device(ehci, devaddr); if (dev == NULL) { ehci_trace_guest_bug(ehci, "no device found"); qemu_sglist_destroy(&ehci->isgl); return -1; } pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT; ep = usb_ep_get(dev, pid, endp); if (ep && ep->type == USB_ENDPOINT_XFER_ISOC) { usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false, (itd->transact[i] & ITD_XACT_IOC) != 0); usb_packet_map(&ehci->ipacket, &ehci->isgl); usb_handle_packet(dev, &ehci->ipacket); usb_packet_unmap(&ehci->ipacket, &ehci->isgl); } else { DPRINTF("ISOCH: attempt to addess non-iso endpoint\n"); ehci->ipacket.status = USB_RET_NAK; ehci->ipacket.actual_length = 0; } qemu_sglist_destroy(&ehci->isgl); switch (ehci->ipacket.status) { case USB_RET_SUCCESS: break; default: fprintf(stderr, "Unexpected iso usb result: %d\n", ehci->ipacket.status); /* Fall through */ case USB_RET_IOERROR: case USB_RET_NODEV: /* 3.3.2: XACTERR is only allowed on IN transactions */ if (dir) { itd->transact[i] |= ITD_XACT_XACTERR; ehci_raise_irq(ehci, USBSTS_ERRINT); } break; case USB_RET_BABBLE: itd->transact[i] |= ITD_XACT_BABBLE; ehci_raise_irq(ehci, USBSTS_ERRINT); break; case USB_RET_NAK: /* no data for us, so do a zero-length transfer */ ehci->ipacket.actual_length = 0; break; } if (!dir) { set_field(&itd->transact[i], len - ehci->ipacket.actual_length, ITD_XACT_LENGTH); /* OUT */ } else { set_field(&itd->transact[i], ehci->ipacket.actual_length, ITD_XACT_LENGTH); /* IN */ } if (itd->transact[i] & ITD_XACT_IOC) { ehci_raise_irq(ehci, USBSTS_INT); } itd->transact[i] &= ~ITD_XACT_ACTIVE; } } return 0; }
1
[ "CWE-617" ]
qemu
2fdb42d840400d58f2e706ecca82c142b97bcbd6
177,780,597,048,296,830,000,000,000,000,000,000,000
107
hw: ehci: check return value of 'usb_packet_map' If 'usb_packet_map' fails, we should stop to process the usb request. Signed-off-by: Li Qiang <liq3ea@163.com> Message-Id: <20200812161727.29412-1-liq3ea@163.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
int free_embedded_options(char ** options_list, int options_count) { int i; for (i= 0; i < options_count; i++) { if (options_list[i]) free(options_list[i]); } free(options_list); return 1; }
0
[ "CWE-416" ]
DBD-mysql
a56ae87a4c1c1fead7d09c3653905841ccccf1cc
12,008,645,177,397,620,000,000,000,000,000,000,000
13
fix use-after-free crash in RT #97625
static bool reg_type_mismatch_ok(enum bpf_reg_type type) { switch (base_type(type)) { case PTR_TO_CTX: case PTR_TO_SOCKET: case PTR_TO_SOCK_COMMON: case PTR_TO_TCP_SOCK: case PTR_TO_XDP_SOCK: case PTR_TO_BTF_ID: return false; default: return true; } }
0
[ "CWE-787" ]
linux
64620e0a1e712a778095bd35cbb277dc2259281f
202,620,438,503,806,000,000,000,000,000,000,000,000
14
bpf: Fix out of bounds access for ringbuf helpers Both bpf_ringbuf_submit() and bpf_ringbuf_discard() have ARG_PTR_TO_ALLOC_MEM in their bpf_func_proto definition as their first argument. They both expect the result from a prior bpf_ringbuf_reserve() call which has a return type of RET_PTR_TO_ALLOC_MEM_OR_NULL. Meaning, after a NULL check in the code, the verifier will promote the register type in the non-NULL branch to a PTR_TO_MEM and in the NULL branch to a known zero scalar. Generally, pointer arithmetic on PTR_TO_MEM is allowed, so the latter could have an offset. The ARG_PTR_TO_ALLOC_MEM expects a PTR_TO_MEM register type. However, the non- zero result from bpf_ringbuf_reserve() must be fed into either bpf_ringbuf_submit() or bpf_ringbuf_discard() but with the original offset given it will then read out the struct bpf_ringbuf_hdr mapping. The verifier missed to enforce a zero offset, so that out of bounds access can be triggered which could be used to escalate privileges if unprivileged BPF was enabled (disabled by default in kernel). Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it") Reported-by: <tr3e.wang@gmail.com> (SecCoder Security Lab) Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Alexei Starovoitov <ast@kernel.org>
GF_Filter *gf_fs_load_filter(GF_FilterSession *fsess, const char *name, GF_Err *err_code) { const char *args=NULL; const char *sep, *file_ext; u32 i, len, count = gf_list_count(fsess->registry); Bool quiet = (err_code && (*err_code == GF_EOS)) ? GF_TRUE : GF_FALSE; assert(fsess); assert(name); if (err_code) *err_code = GF_OK; sep = gf_fs_path_escape_colon(fsess, name); if (sep) { args = sep+1; len = (u32) (sep - name); } else len = (u32) strlen(name); if (!len) { if (!quiet) { GF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, ("Missing filter name in %s\n", name)); } return NULL; } if (!strncmp(name, "enc", len)) { return gf_fs_load_encoder(fsess, args); } /*regular filter loading*/ for (i=0;i<count;i++) { const GF_FilterRegister *f_reg = gf_list_get(fsess->registry, i); if ((strlen(f_reg->name)==len) && !strncmp(f_reg->name, name, len)) { GF_Filter *filter; GF_FilterArgType argtype = GF_FILTER_ARG_EXPLICIT; if ((f_reg->flags & GF_FS_REG_REQUIRES_RESOLVER) && !fsess->max_resolve_chain_len) { GF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, ("Filter %s requires graph resolver but it is disabled\n", name)); if (err_code) *err_code = GF_BAD_PARAM; return NULL; } if (f_reg->flags & GF_FS_REG_ACT_AS_SOURCE) argtype = GF_FILTER_ARG_EXPLICIT_SOURCE; filter = gf_filter_new(fsess, f_reg, args, NULL, argtype, err_code, NULL, GF_FALSE); if (!filter) return NULL; if (!filter->num_output_pids) { const char *src_url = strstr(name, "src"); if (src_url && (src_url[3]==fsess->sep_name)) gf_filter_post_process_task(filter); } return filter; } } /*check JS file*/ file_ext = gf_file_ext_start(name); if (file_ext && (file_ext > sep) ) file_ext = NULL; if (!file_ext || strstr(name, ".js") || strstr(name, ".jsf") || strstr(name, ".mjs") ) { Bool file_exists = GF_FALSE; char szName[10+GF_MAX_PATH]; char szPath[10+GF_MAX_PATH]; if (len>GF_MAX_PATH) return NULL; strncpy(szPath, name, len); szPath[len]=0; GF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, ("Trying JS filter %s\n", szPath)); if (gf_file_exists(szPath)) { file_exists = GF_TRUE; } else { strcpy(szName, szPath); file_exists = gf_fs_solve_js_script(szPath, szName, file_ext); if (!file_exists && !file_ext) { strcat(szName, ".js"); if (gf_file_exists(szName)) { strncpy(szPath, name, len); szPath[len]=0; strcat(szPath, ".js"); file_exists = GF_TRUE; } } } if (file_exists) { sprintf(szName, "jsf%cjs%c", fsess->sep_args, fsess->sep_name); strcat(szName, szPath); if (name[len]) strcat(szName, name+len); return gf_fs_load_filter(fsess, szName, err_code); } } if (!quiet) { GF_LOG(GF_LOG_ERROR, GF_LOG_FILTER, ("Failed to load filter %s: no such filter registry\n", name)); } if (err_code) *err_code = GF_FILTER_NOT_FOUND; return NULL; }
1
[ "CWE-476" ]
gpac
44fdc3d972c31c56efe73e1a3b63438d46087652
220,232,041,198,906,980,000,000,000,000,000,000,000
97
fixed #1906
TEST_F(HttpHealthCheckerImplTest, GoAwayProbeInProgress) { setupHCHttp2(); EXPECT_CALL(runtime_.snapshot_, featureEnabled("health_check.verify_cluster", 100)) .WillRepeatedly(Return(false)); cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80", simTime())}; cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // GOAWAY with NO_ERROR code during check should be handled gracefully. test_sessions_[0]->codec_client_->raiseGoAway(Http::GoAwayErrorCode::NoError); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectUnchanged(0); respond(0, "200", false, false, true, false, {}, false); // GOAWAY should cause a new connection to be created. expectClientCreate(0); expectStreamCreate(0); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); // Test host state hasn't changed. expectUnchanged(0); respond(0, "200", false, false, true, false, {}, false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); }
0
[ "CWE-476" ]
envoy
9b1c3962172a972bc0359398af6daa3790bb59db
215,775,242,690,504,880,000,000,000,000,000,000,000
31
healthcheck: fix grpc inline removal crashes (#749) Signed-off-by: Matt Klein <mklein@lyft.com> Signed-off-by: Pradeep Rao <pcrao@google.com>
Error Box_auxC::write(StreamWriter& writer) const { size_t box_start = reserve_box_header_space(writer); writer.write(m_aux_type); for (uint8_t subtype : m_aux_subtypes) { writer.write8(subtype); } prepend_header(writer, box_start); return Error::Ok; }
0
[ "CWE-703" ]
libheif
2710c930918609caaf0a664e9c7bc3dce05d5b58
241,889,598,447,862,300,000,000,000,000,000,000,000
14
force fraction to a limited resolution to finally solve those pesky numerical edge cases
static void cmd_capabilities(char *keyword __attribute__((unused))) { const char *mechlist; int mechcount = 0; prot_printf(nntp_out, "101 Capability list follows:\r\n"); prot_printf(nntp_out, "VERSION 2\r\n"); if (nntp_authstate || (config_serverinfo == IMAP_ENUM_SERVERINFO_ON)) { prot_printf(nntp_out, "IMPLEMENTATION Cyrus NNTP%s %s\r\n", config_mupdate_server ? " Murder" : "", cyrus_version()); } /* add STARTTLS */ if (tls_enabled() && !nntp_starttls_done && !nntp_authstate) prot_printf(nntp_out, "STARTTLS\r\n"); /* check for SASL mechs */ sasl_listmech(nntp_saslconn, NULL, "SASL ", " ", "\r\n", &mechlist, NULL, &mechcount); /* add the AUTHINFO variants */ if (!nntp_authstate) { prot_printf(nntp_out, "AUTHINFO%s%s\r\n", (nntp_starttls_done || (extprops_ssf > 1) || config_getswitch(IMAPOPT_ALLOWPLAINTEXT)) ? " USER" : "", mechcount ? " SASL" : ""); } /* add the SASL mechs */ if (mechcount) prot_printf(nntp_out, "%s", mechlist); /* add the reader capabilities/extensions */ if ((nntp_capa & MODE_READ) && (nntp_authstate || allowanonymous)) { prot_printf(nntp_out, "READER\r\n"); prot_printf(nntp_out, "POST\r\n"); if (config_getswitch(IMAPOPT_ALLOWNEWNEWS)) prot_printf(nntp_out, "NEWNEWS\r\n"); prot_printf(nntp_out, "HDR\r\n"); prot_printf(nntp_out, "OVER\r\n"); prot_printf(nntp_out, "XPAT\r\n"); } /* add the feeder capabilities/extensions */ if (nntp_capa & MODE_FEED) { prot_printf(nntp_out, "IHAVE\r\n"); prot_printf(nntp_out, "STREAMING\r\n"); } /* add the LIST variants */ prot_printf(nntp_out, "LIST ACTIVE%s\r\n", ((nntp_capa & MODE_READ) && (nntp_authstate || allowanonymous)) ? " HEADERS NEWSGROUPS OVERVIEW.FMT" : ""); prot_printf(nntp_out, ".\r\n"); did_capabilities = 1; }
0
[ "CWE-287" ]
cyrus-imapd
77903669e04c9788460561dd0560b9c916519594
96,705,534,033,984,220,000,000,000,000,000,000,000
58
Secunia SA46093 - make sure nntp authentication completes Discovered by Stefan Cornelius, Secunia Research The vulnerability is caused due to the access restriction for certain commands only checking whether or not variable "nntp_userid" is non-NULL, without performing additional checks to verify that a complete, successful authentication actually took place. The variable "nntp_userid" can be set to point to a string holding the username (changing it to a non-NULL, thus allowing attackers to bypass the checks) by sending an "AUTHINFO USER" command. The variable is not reset to NULL until e.g. a wrong "AUTHINFO PASS" command is received. This can be exploited to bypass the authentication mechanism and allows access to e.g. the "NEWNEWS" or the "LIST NEWSGROUPS" commands by sending an "AUTHINFO USER" command without a following "AUTHINFO PASS" command.
void Compute(OpKernelContext* context) override { // Read ragged_splits inputs. OpInputList ragged_nested_splits_in; OP_REQUIRES_OK(context, context->input_list("rt_nested_splits", &ragged_nested_splits_in)); const int ragged_nested_splits_len = ragged_nested_splits_in.size(); RaggedTensorVariant batched_ragged_input; // Read ragged_values input. batched_ragged_input.set_values(context->input(ragged_nested_splits_len)); batched_ragged_input.mutable_nested_splits()->reserve( ragged_nested_splits_len); for (int i = 0; i < ragged_nested_splits_len; i++) { batched_ragged_input.append_splits(ragged_nested_splits_in[i]); } if (!batched_input_) { // Encode as a Scalar Variant Tensor. Tensor* encoded_scalar; OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({}), &encoded_scalar)); encoded_scalar->scalar<Variant>()() = std::move(batched_ragged_input); return; } // Unbatch the Ragged Tensor and encode the components. std::vector<RaggedTensorVariant> unbatched_ragged_input; auto batched_splits_top_vec = batched_ragged_input.splits(0).vec<SPLIT_TYPE>(); int num_components = batched_splits_top_vec.size() - 1; OP_REQUIRES(context, num_components >= 0, errors::Internal("Invalid split argument.")); OP_REQUIRES_OK(context, UnbatchRaggedZerothDim<VALUE_TYPE, SPLIT_TYPE>( batched_ragged_input, &unbatched_ragged_input)); // Bundle the encoded scalar Variant Tensors into a rank-1 Variant Tensor. Tensor* encoded_vector; int output_size = unbatched_ragged_input.size(); OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({output_size}), &encoded_vector)); auto encoded_vector_t = encoded_vector->vec<Variant>(); for (int i = 0; i < output_size; i++) { encoded_vector_t(i) = unbatched_ragged_input[i]; } }
1
[ "CWE-125", "CWE-824" ]
tensorflow
be7a4de6adfbd303ce08be4332554dff70362612
209,500,931,068,648,330,000,000,000,000,000,000,000
45
Ensure non-empty rt_nested_splits in tf.raw_ops.RaggedTensorToVariant PiperOrigin-RevId: 387664237 Change-Id: Ia1700c34b5610873d63561abc86e23b46ead93b3
llsec_update_devkey_info(struct mac802154_llsec_device *dev, const struct ieee802154_llsec_key_id *in_key, u32 frame_counter) { struct mac802154_llsec_device_key *devkey = NULL; if (dev->dev.key_mode == IEEE802154_LLSEC_DEVKEY_RESTRICT) { devkey = llsec_devkey_find(dev, in_key); if (!devkey) return -ENOENT; } if (dev->dev.key_mode == IEEE802154_LLSEC_DEVKEY_RECORD) { int rc = llsec_update_devkey_record(dev, in_key); if (rc < 0) return rc; } spin_lock_bh(&dev->lock); if ((!devkey && frame_counter < dev->dev.frame_counter) || (devkey && frame_counter < devkey->devkey.frame_counter)) { spin_unlock_bh(&dev->lock); return -EINVAL; } if (devkey) devkey->devkey.frame_counter = frame_counter + 1; else dev->dev.frame_counter = frame_counter + 1; spin_unlock_bh(&dev->lock); return 0; }
0
[ "CWE-416" ]
linux
1165affd484889d4986cf3b724318935a0b120d8
25,222,919,656,107,720,000,000,000,000,000,000,000
36
net: mac802154: Fix general protection fault syzbot found general protection fault in crypto_destroy_tfm()[1]. It was caused by wrong clean up loop in llsec_key_alloc(). If one of the tfm array members is in IS_ERR() range it will cause general protection fault in clean up function [1]. Call Trace: crypto_free_aead include/crypto/aead.h:191 [inline] [1] llsec_key_alloc net/mac802154/llsec.c:156 [inline] mac802154_llsec_key_add+0x9e0/0xcc0 net/mac802154/llsec.c:249 ieee802154_add_llsec_key+0x56/0x80 net/mac802154/cfg.c:338 rdev_add_llsec_key net/ieee802154/rdev-ops.h:260 [inline] nl802154_add_llsec_key+0x3d3/0x560 net/ieee802154/nl802154.c:1584 genl_family_rcv_msg_doit+0x228/0x320 net/netlink/genetlink.c:739 genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] genl_rcv_msg+0x328/0x580 net/netlink/genetlink.c:800 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline] netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1338 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1927 sock_sendmsg_nosec net/socket.c:654 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:674 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2350 ___sys_sendmsg+0xf3/0x170 net/socket.c:2404 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2433 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Reported-by: syzbot+9ec037722d2603a9f52e@syzkaller.appspotmail.com Acked-by: Alexander Aring <aahringo@redhat.com> Link: https://lore.kernel.org/r/20210304152125.1052825-1-paskripkin@gmail.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
void clear_fifo (i) int i; { if (dev_fd_list[i]) { dev_fd_list[i] = 0; nfds--; }
0
[ "CWE-20" ]
bash
4f747edc625815f449048579f6e65869914dd715
256,528,028,332,019,100,000,000,000,000,000,000,000
9
Bash-4.4 patch 7
static inline void DetectRunPrefilterPkt( ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p, DetectRunScratchpad *scratch ) { DetectPrefilterSetNonPrefilterList(p, det_ctx, scratch); /* create our prefilter mask */ PacketCreateMask(p, &scratch->pkt_mask, scratch->alproto, scratch->app_decoder_events); /* build and prefilter non_pf list against the mask of the packet */ PACKET_PROFILING_DETECT_START(p, PROF_DETECT_NONMPMLIST); det_ctx->non_pf_id_cnt = 0; if (likely(det_ctx->non_pf_store_cnt > 0)) { DetectPrefilterBuildNonPrefilterList(det_ctx, scratch->pkt_mask, scratch->alproto); } PACKET_PROFILING_DETECT_END(p, PROF_DETECT_NONMPMLIST); /* run the prefilter engines */ Prefilter(det_ctx, scratch->sgh, p, scratch->flow_flags); /* create match list if we have non-pf and/or pf */ if (det_ctx->non_pf_store_cnt || det_ctx->pmq.rule_id_array_cnt) { PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PF_SORT2); DetectPrefilterMergeSort(de_ctx, det_ctx); PACKET_PROFILING_DETECT_END(p, PROF_DETECT_PF_SORT2); } #ifdef PROFILING if (tv) { StatsAddUI64(tv, det_ctx->counter_mpm_list, (uint64_t)det_ctx->pmq.rule_id_array_cnt); StatsAddUI64(tv, det_ctx->counter_nonmpm_list, (uint64_t)det_ctx->non_pf_store_cnt); /* non mpm sigs after mask prefilter */ StatsAddUI64(tv, det_ctx->counter_fnonmpm_list, (uint64_t)det_ctx->non_pf_id_cnt); } #endif }
0
[ "CWE-347" ]
suricata
d8634daf74c882356659addb65fb142b738a186b
235,252,170,973,257,200,000,000,000,000,000,000,000
42
stream: fix false negative on bad RST If a bad RST was received the stream inspection would not happen for that packet, but it would still move the 'raw progress' tracker forward. Following good packets would then fail to detect anything before the 'raw progress' position. Bug #2770 Reported-by: Alexey Vishnyakov
static int check_version_match(void) { DYNAMIC_STRING ds_version; char version_str[NAME_CHAR_LEN + 1]; if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN)) die("Out of memory"); if (run_query("show variables like 'version'", &ds_version, FALSE)) { fprintf(stderr, "Error: Failed while fetching Server version! Could be" " due to unauthorized access.\n"); dynstr_free(&ds_version); return 1; /* Query failed */ } if (extract_variable_from_show(&ds_version, version_str)) { fprintf(stderr, "Error: Failed while extracting Server version!\n"); dynstr_free(&ds_version); return 1; /* Query failed */ } dynstr_free(&ds_version); if (calc_server_version((char *) version_str) != MYSQL_VERSION_ID) { fprintf(stderr, "Error: Server version (%s) does not match with the " "version of\nthe server (%s) with which this program was built/" "distributed. You can\nuse --skip-version-check to skip this " "check.\n", version_str, MYSQL_SERVER_VERSION); return 1; } else return 0; }
0
[ "CWE-319" ]
mysql-server
0002e1380d5f8c113b6bce91f2cf3f75136fd7c7
140,395,222,213,798,370,000,000,000,000,000,000,000
35
BUG#25575605: SETTING --SSL-MODE=REQUIRED SENDS CREDENTIALS BEFORE VERIFYING SSL CONNECTION MYSQL_OPT_SSL_MODE option introduced. It is set in case of --ssl-mode=REQUIRED and permits only SSL connection. (cherry picked from commit f91b941842d240b8a62645e507f5554e8be76aec)
u32 parse_track_dump(char *arg, u32 dump_type) { if (!create_new_track_action(arg, TRACK_ACTION_RAW_EXTRACT, dump_type)) return 2; track_dump_type = dump_type; return 0;
0
[ "CWE-787" ]
gpac
4e56ad72ac1afb4e049a10f2d99e7512d7141f9d
219,920,299,519,188,300,000,000,000,000,000,000
7
fixed #2216
void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) { struct hci_dev *hdev = conn->hdev; BT_DBG("hcon %p mode %d", conn, conn->mode); if (conn->mode != HCI_CM_SNIFF) goto timer; if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active) goto timer; if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) { struct hci_cp_exit_sniff_mode cp; cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp); } timer: if (hdev->idle_timeout > 0) queue_delayed_work(hdev->workqueue, &conn->idle_work, msecs_to_jiffies(hdev->idle_timeout)); }
0
[ "CWE-327" ]
linux
d5bb334a8e171b262e48f378bd2096c0ea458265
125,774,088,669,376,160,000,000,000,000,000,000,000
23
Bluetooth: Align minimum encryption key size for LE and BR/EDR connections The minimum encryption key size for LE connections is 56 bits and to align LE with BR/EDR, enforce 56 bits of minimum encryption key size for BR/EDR connections as well. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Cc: stable@vger.kernel.org
e_mail_parser_parse (EMailParser *parser, CamelFolder *folder, const gchar *message_uid, CamelMimeMessage *message, GAsyncReadyCallback callback, GCancellable *cancellable, gpointer user_data) { GSimpleAsyncResult *simple; EMailPartList *part_list; g_return_if_fail (E_IS_MAIL_PARSER (parser)); g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); part_list = e_mail_part_list_new (message, message_uid, folder); simple = g_simple_async_result_new ( G_OBJECT (parser), callback, user_data, e_mail_parser_parse); g_simple_async_result_set_check_cancellable (simple, cancellable); g_simple_async_result_set_op_res_gpointer ( simple, part_list, (GDestroyNotify) g_object_unref); g_simple_async_result_run_in_thread ( simple, mail_parser_parse_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (simple); }
0
[ "CWE-347" ]
evolution
9c55a311325f5905d8b8403b96607e46cf343f21
212,244,551,670,967,380,000,000,000,000,000,000,000
31
I#120 - Show security bar above message headers Closes https://gitlab.gnome.org/GNOME/evolution/issues/120
static bool check_underflow(const struct ip6t_entry *e) { const struct xt_entry_target *t; unsigned int verdict; if (!unconditional(&e->ipv6)) return false; t = ip6t_get_target_c(e); if (strcmp(t->u.user.name, XT_STANDARD_TARGET) != 0) return false; verdict = ((struct xt_standard_target *)t)->verdict; verdict = -verdict - 1; return verdict == NF_DROP || verdict == NF_ACCEPT; }
1
[ "CWE-119", "CWE-787" ]
linux
54d83fc74aa9ec72794373cb47432c5f7fb1a309
69,891,328,452,143,980,000,000,000,000,000,000,000
14
netfilter: x_tables: fix unconditional helper Ben Hawkes says: In the mark_source_chains function (net/ipv4/netfilter/ip_tables.c) it is possible for a user-supplied ipt_entry structure to have a large next_offset field. This field is not bounds checked prior to writing a counter value at the supplied offset. Problem is that mark_source_chains should not have been called -- the rule doesn't have a next entry, so its supposed to return an absolute verdict of either ACCEPT or DROP. However, the function conditional() doesn't work as the name implies. It only checks that the rule is using wildcard address matching. However, an unconditional rule must also not be using any matches (no -m args). The underflow validator only checked the addresses, therefore passing the 'unconditional absolute verdict' test, while mark_source_chains also tested for presence of matches, and thus proceeeded to the next (not-existent) rule. Unify this so that all the callers have same idea of 'unconditional rule'. Reported-by: Ben Hawkes <hawkes@google.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
static inline TCGMemOp mo_64_32(TCGMemOp ot) { #ifdef TARGET_X86_64 return ot == MO_64 ? MO_64 : MO_32; #else return MO_32; #endif }
0
[ "CWE-94" ]
qemu
30663fd26c0307e414622c7a8607fbc04f92ec14
250,893,554,458,281,860,000,000,000,000,000,000,000
8
tcg/i386: Check the size of instruction being translated This fixes the bug: 'user-to-root privesc inside VM via bad translation caching' reported by Jann Horn here: https://bugs.chromium.org/p/project-zero/issues/detail?id=1122 Reviewed-by: Richard Henderson <rth@twiddle.net> CC: Peter Maydell <peter.maydell@linaro.org> CC: Paolo Bonzini <pbonzini@redhat.com> Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> Message-Id: <20170323175851.14342-1-bobby.prani@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
lyxml_free_attrs(struct ly_ctx *ctx, struct lyxml_elem *elem) { struct lyxml_attr *a, *next; if (!elem || !elem->attr) { return; } a = elem->attr; do { next = a->next; lydict_remove(ctx, a->name); lydict_remove(ctx, a->value); if (a->type == LYXML_ATTR_STD_UNRES) { free((char *)a->ns); } free(a); a = next; } while (a); }
0
[ "CWE-674" ]
libyang
298b30ea4ebee137226acf9bb38678bd82704582
35,593,257,233,789,404,000,000,000,000,000,000,000
21
common FEATURE add a hard limit for recursion Fixes #1453
SegmentCommand* Binary::segment_from_offset(uint64_t offset) { return const_cast<SegmentCommand*>(static_cast<const Binary*>(this)->segment_from_offset(offset)); }
1
[ "CWE-703" ]
LIEF
7acf0bc4224081d4f425fcc8b2e361b95291d878
42,342,701,268,356,780,000,000,000,000,000,000,000
3
Resolve #764
static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk) { struct sk_buff *skb = alloc_skb(sizeof(struct sadb_msg) + 16, GFP_KERNEL); struct sadb_msg *hdr; if (!skb) return -ENOBUFS; /* Woe be to the platform trying to support PFKEY yet * having normal errnos outside the 1-255 range, inclusive. */ err = -err; if (err == ERESTARTSYS || err == ERESTARTNOHAND || err == ERESTARTNOINTR) err = EINTR; if (err >= 512) err = EINVAL; BUG_ON(err <= 0 || err >= 256); hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); pfkey_hdr_dup(hdr, orig); hdr->sadb_msg_errno = (uint8_t) err; hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk)); return 0; }
0
[ "CWE-20", "CWE-269" ]
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
68,105,614,729,744,530,000,000,000,000,000,000,000
30
net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
void saveVCalendar (TNEFStruct *tnef, const gchar *tmpdir) { gchar *ifilename; variableLength *filename; gchar *charptr, *charptr2; FILE *fptr; gint index; DWORD *dword_ptr; DWORD dword_val; dtr thedate; ifilename = g_build_filename (tmpdir, "calendar.vcf", NULL); printf("%s\n", ifilename); if ((fptr = fopen(ifilename, "wb"))==NULL) { printf("Error writing file to disk!"); } else { fprintf(fptr, "BEGIN:VCALENDAR\n"); if (tnef->messageClass[0] != 0) { charptr2=tnef->messageClass; charptr=charptr2; while (*charptr != 0) { if (*charptr == '.') { charptr2 = charptr; } charptr++; } if (strcmp(charptr2, ".MtgCncl") == 0) { fprintf(fptr, "METHOD:CANCEL\n"); } else { fprintf(fptr, "METHOD:REQUEST\n"); } } else { fprintf(fptr, "METHOD:REQUEST\n"); } fprintf(fptr, "VERSION:2.0\n"); fprintf(fptr, "BEGIN:VEVENT\n"); /* UID After alot of comparisons, I'm reasonably sure this is totally wrong. But it's not really necessary. */ /* I think it only exists to connect future modification entries to this entry. so as long as it's incorrectly interpreted the same way every time, it should be ok :) */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_BINARY, 0x3))) == MAPI_UNDEFINED) { if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_BINARY, 0x23))) == MAPI_UNDEFINED) { filename = NULL; } } if (filename!=NULL) { fprintf(fptr, "UID:"); for (index=0;index<filename->size;index++) { fprintf(fptr,"%02X", (guchar)filename->data[index]); } fprintf(fptr,"\n"); } /* Sequence */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_LONG, 0x8201))) != MAPI_UNDEFINED) { dword_ptr = (DWORD*)filename->data; fprintf(fptr, "SEQUENCE:%i\n", (gint) *dword_ptr); } if ((filename=MAPIFindProperty (&(tnef->MapiProperties), PROP_TAG (PT_BINARY, PR_SENDER_SEARCH_KEY))) != MAPI_UNDEFINED) { charptr = filename->data; charptr2 = strstr(charptr, ":"); if (charptr2 == NULL) charptr2 = charptr; else charptr2++; fprintf(fptr, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", charptr2, charptr2); } /* Required Attendees */ if ((filename = MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, 0x823b))) != MAPI_UNDEFINED) { /* We have a list of required participants, so write them out. */ if (filename->size > 1) { charptr = filename->data-1; while (charptr != NULL) { charptr++; charptr2 = strstr(charptr, ";"); if (charptr2 != NULL) { *charptr2 = 0; } while (*charptr == ' ') charptr++; fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;"); fprintf(fptr, "ROLE=REQ-PARTICIPANT;RSVP=TRUE;"); fprintf(fptr, "CN=\"%s\":MAILTO:%s\n", charptr, charptr); charptr = charptr2; } } /* Optional attendees */ if ((filename = MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, 0x823c))) != MAPI_UNDEFINED) { /* The list of optional participants */ if (filename->size > 1) { charptr = filename->data-1; while (charptr != NULL) { charptr++; charptr2 = strstr(charptr, ";"); if (charptr2 != NULL) { *charptr2 = 0; } while (*charptr == ' ') charptr++; fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;"); fprintf(fptr, "ROLE=OPT-PARTICIPANT;RSVP=TRUE;"); fprintf(fptr, "CN=\"%s\":MAILTO:%s\n", charptr, charptr); charptr = charptr2; } } } } else if ((filename = MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, 0x8238))) != MAPI_UNDEFINED) { if (filename->size > 1) { charptr = filename->data-1; while (charptr != NULL) { charptr++; charptr2 = strstr(charptr, ";"); if (charptr2 != NULL) { *charptr2 = 0; } while (*charptr == ' ') charptr++; fprintf(fptr, "ATTENDEE;PARTSTAT=NEEDS-ACTION;"); fprintf(fptr, "ROLE=REQ-PARTICIPANT;RSVP=TRUE;"); fprintf(fptr, "CN=\"%s\":MAILTO:%s\n", charptr, charptr); charptr = charptr2; } } } /* Summary */ filename = NULL; if ((filename=MAPIFindProperty (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, PR_CONVERSATION_TOPIC))) != MAPI_UNDEFINED) { fprintf(fptr, "SUMMARY:"); cstylefprint (fptr, filename); fprintf(fptr, "\n"); } /* Description */ if ((filename=MAPIFindProperty (&(tnef->MapiProperties), PROP_TAG (PT_BINARY, PR_RTF_COMPRESSED))) != MAPI_UNDEFINED) { variableLength buf; if ((buf.data = (gchar *) DecompressRTF (filename, &buf.size)) != NULL) { fprintf(fptr, "DESCRIPTION:"); printRtf (fptr, &buf); free (buf.data); } } /* Location */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, 0x0002))) == MAPI_UNDEFINED) { if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_STRING8, 0x8208))) == MAPI_UNDEFINED) { filename = NULL; } } if (filename != NULL) { fprintf(fptr,"LOCATION: %s\n", filename->data); } /* Date Start */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_SYSTIME, 0x820d))) == MAPI_UNDEFINED) { if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_SYSTIME, 0x8516))) == MAPI_UNDEFINED) { filename=NULL; } } if (filename != NULL) { fprintf(fptr, "DTSTART:"); MAPISysTimetoDTR ((guchar *) filename->data, &thedate); fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n", thedate.wYear, thedate.wMonth, thedate.wDay, thedate.wHour, thedate.wMinute, thedate.wSecond); } /* Date End */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_SYSTIME, 0x820e))) == MAPI_UNDEFINED) { if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_SYSTIME, 0x8517))) == MAPI_UNDEFINED) { filename=NULL; } } if (filename != NULL) { fprintf(fptr, "DTEND:"); MAPISysTimetoDTR ((guchar *) filename->data, &thedate); fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n", thedate.wYear, thedate.wMonth, thedate.wDay, thedate.wHour, thedate.wMinute, thedate.wSecond); } /* Date Stamp */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_SYSTIME, 0x8202))) != MAPI_UNDEFINED) { fprintf(fptr, "CREATED:"); MAPISysTimetoDTR ((guchar *) filename->data, &thedate); fprintf(fptr,"%04i%02i%02iT%02i%02i%02iZ\n", thedate.wYear, thedate.wMonth, thedate.wDay, thedate.wHour, thedate.wMinute, thedate.wSecond); } /* Class */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_BOOLEAN, 0x8506))) != MAPI_UNDEFINED) { dword_ptr = (DWORD*)filename->data; dword_val = SwapDWord ((BYTE*)dword_ptr); fprintf(fptr, "CLASS:" ); if (*dword_ptr == 1) { fprintf(fptr,"PRIVATE\n"); } else { fprintf(fptr,"PUBLIC\n"); } } /* Recurrence */ filename = NULL; if ((filename=MAPIFindUserProp (&(tnef->MapiProperties), PROP_TAG (PT_BINARY, 0x8216))) != MAPI_UNDEFINED) { printRrule (fptr, filename->data, filename->size, tnef); } /* Wrap it up */ fprintf(fptr, "END:VEVENT\n"); fprintf(fptr, "END:VCALENDAR\n"); fclose (fptr); } g_free (ifilename); }
0
[]
evolution
a9fb511ced4cfaffb7109e58a9db66e6279e309c
203,510,093,158,569,770,000,000,000,000,000,000,000
249
bug #641069 - tnef plugin vulnerabilities Resolves directory traversal and buffer overflow vulnerabilities.
static int mark_source_chains(const struct xt_table_info *newinfo, unsigned int valid_hooks, void *entry0, unsigned int *offsets) { unsigned int hook; /* No recursion; use packet counter to save back ptrs (reset * to 0 as we leave), and comefrom to save source hook bitmask. */ for (hook = 0; hook < NF_ARP_NUMHOOKS; hook++) { unsigned int pos = newinfo->hook_entry[hook]; struct arpt_entry *e = entry0 + pos; if (!(valid_hooks & (1 << hook))) continue; /* Set initial back pointer. */ e->counters.pcnt = pos; for (;;) { const struct xt_standard_target *t = (void *)arpt_get_target_c(e); int visited = e->comefrom & (1 << hook); if (e->comefrom & (1 << NF_ARP_NUMHOOKS)) return 0; e->comefrom |= ((1 << hook) | (1 << NF_ARP_NUMHOOKS)); /* Unconditional return/END. */ if ((unconditional(e) && (strcmp(t->target.u.user.name, XT_STANDARD_TARGET) == 0) && t->verdict < 0) || visited) { unsigned int oldpos, size; /* Return: backtrack through the last * big jump. */ do { e->comefrom ^= (1<<NF_ARP_NUMHOOKS); oldpos = pos; pos = e->counters.pcnt; e->counters.pcnt = 0; /* We're at the start. */ if (pos == oldpos) goto next; e = entry0 + pos; } while (oldpos == pos + e->next_offset); /* Move along one */ size = e->next_offset; e = entry0 + pos + size; if (pos + size >= newinfo->size) return 0; e->counters.pcnt = pos; pos += size; } else { int newpos = t->verdict; if (strcmp(t->target.u.user.name, XT_STANDARD_TARGET) == 0 && newpos >= 0) { /* This a jump; chase it. */ if (!xt_find_jump_offset(offsets, newpos, newinfo->number)) return 0; } else { /* ... this is a fallthru */ newpos = pos + e->next_offset; if (newpos >= newinfo->size) return 0; } e = entry0 + newpos; e->counters.pcnt = pos; pos = newpos; } } next: ; } return 1; }
0
[ "CWE-787" ]
linux
b29c457a6511435960115c0f548c4360d5f4801d
30,609,778,745,476,826,000,000,000,000,000,000,000
85
netfilter: x_tables: fix compat match/target pad out-of-bound write xt_compat_match/target_from_user doesn't check that zeroing the area to start of next rule won't write past end of allocated ruleset blob. Remove this code and zero the entire blob beforehand. Reported-by: syzbot+cfc0247ac173f597aaaa@syzkaller.appspotmail.com Reported-by: Andy Nguyen <theflow@google.com> Fixes: 9fa492cdc160c ("[NETFILTER]: x_tables: simplify compat API") Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
static int ntop_set_second_traffic(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__); if(!ntop_interface) return(CONST_LUA_ERROR); ntop_interface->updateSecondTraffic(time(NULL)); return(CONST_LUA_OK); }
0
[ "CWE-476" ]
ntopng
01f47e04fd7c8d54399c9e465f823f0017069f8f
255,683,374,254,688,600,000,000,000,000,000,000,000
10
Security fix: prevents empty host from being used
static int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, ext4_lblk_t iblock, unsigned int maxblocks, struct buffer_head *bh_result, int create, int extend_disksize) { int err = -EIO; ext4_lblk_t offsets[4]; Indirect chain[4]; Indirect *partial; ext4_fsblk_t goal; int indirect_blks; int blocks_to_boundary = 0; int depth; struct ext4_inode_info *ei = EXT4_I(inode); int count = 0; ext4_fsblk_t first_block = 0; loff_t disksize; J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); J_ASSERT(handle != NULL || create == 0); depth = ext4_block_to_path(inode, iblock, offsets, &blocks_to_boundary); if (depth == 0) goto out; partial = ext4_get_branch(inode, depth, offsets, chain, &err); /* Simplest case - block found, no allocation needed */ if (!partial) { first_block = le32_to_cpu(chain[depth - 1].key); clear_buffer_new(bh_result); count++; /*map more blocks*/ while (count < maxblocks && count <= blocks_to_boundary) { ext4_fsblk_t blk; blk = le32_to_cpu(*(chain[depth-1].p + count)); if (blk == first_block + count) count++; else break; } goto got_it; } /* Next simple case - plain lookup or failed read of indirect block */ if (!create || err == -EIO) goto cleanup; /* * Okay, we need to do block allocation. */ goal = ext4_find_goal(inode, iblock, partial); /* the number of blocks need to allocate for [d,t]indirect blocks */ indirect_blks = (chain + depth) - partial - 1; /* * Next look up the indirect map to count the totoal number of * direct blocks to allocate for this branch. */ count = ext4_blks_to_allocate(partial, indirect_blks, maxblocks, blocks_to_boundary); /* * Block out ext4_truncate while we alter the tree */ err = ext4_alloc_branch(handle, inode, iblock, indirect_blks, &count, goal, offsets + (partial - chain), partial); /* * The ext4_splice_branch call will free and forget any buffers * on the new chain if there is a failure, but that risks using * up transaction credits, especially for bitmaps where the * credits cannot be returned. Can we handle this somehow? We * may need to return -EAGAIN upwards in the worst case. --sct */ if (!err) err = ext4_splice_branch(handle, inode, iblock, partial, indirect_blks, count); /* * i_disksize growing is protected by i_data_sem. Don't forget to * protect it if you're about to implement concurrent * ext4_get_block() -bzzz */ if (!err && extend_disksize) { disksize = ((loff_t) iblock + count) << inode->i_blkbits; if (disksize > i_size_read(inode)) disksize = i_size_read(inode); if (disksize > ei->i_disksize) ei->i_disksize = disksize; } if (err) goto cleanup; set_buffer_new(bh_result); got_it: map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key)); if (count > blocks_to_boundary) set_buffer_boundary(bh_result); err = count; /* Clean up and exit */ partial = chain + depth - 1; /* the whole chain */ cleanup: while (partial > chain) { BUFFER_TRACE(partial->bh, "call brelse"); brelse(partial->bh); partial--; } BUFFER_TRACE(bh_result, "returned"); out: return err; }
0
[ "CWE-399" ]
linux-2.6
06a279d636734da32bb62dd2f7b0ade666f65d7c
219,997,241,910,423,230,000,000,000,000,000,000,000
116
ext4: only use i_size_high for regular files Directories are not allowed to be bigger than 2GB, so don't use i_size_high for anything other than regular files. E2fsck should complain about these inodes, but the simplest thing to do for the kernel is to only use i_size_high for regular files. This prevents an intentially corrupted filesystem from causing the kernel to burn a huge amount of CPU and issuing error messages such as: EXT4-fs warning (device loop0): ext4_block_to_path: block 135090028 > max Thanks to David Maciejak from Fortinet's FortiGuard Global Security Research Team for reporting this issue. http://bugzilla.kernel.org/show_bug.cgi?id=12375 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: stable@kernel.org
ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source) { uint32_t idx; HashTable *target; IS_CONSISTENT(source); ALLOC_HASHTABLE(target); GC_REFCOUNT(target) = 1; GC_TYPE_INFO(target) = IS_ARRAY; target->nTableSize = source->nTableSize; target->pDestructor = source->pDestructor; if (source->nNumUsed == 0) { target->u.flags = (source->u.flags & ~(HASH_FLAG_INITIALIZED|HASH_FLAG_PACKED|HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION | HASH_FLAG_STATIC_KEYS; target->nTableMask = HT_MIN_MASK; target->nNumUsed = 0; target->nNumOfElements = 0; target->nNextFreeElement = 0; target->nInternalPointer = HT_INVALID_IDX; HT_SET_DATA_ADDR(target, &uninitialized_bucket); } else if (GC_FLAGS(source) & IS_ARRAY_IMMUTABLE) { target->u.flags = (source->u.flags & ~HASH_FLAG_PERSISTENT) | HASH_FLAG_APPLY_PROTECTION; target->nTableMask = source->nTableMask; target->nNumUsed = source->nNumUsed; target->nNumOfElements = source->nNumOfElements; target->nNextFreeElement = source->nNextFreeElement; HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target))); target->nInternalPointer = source->nInternalPointer; memcpy(HT_GET_DATA_ADDR(target), HT_GET_DATA_ADDR(source), HT_USED_SIZE(source)); if (target->nNumOfElements > 0 && target->nInternalPointer == HT_INVALID_IDX) { idx = 0; while (Z_TYPE(target->arData[idx].val) == IS_UNDEF) { idx++; } target->nInternalPointer = idx; } } else if (source->u.flags & HASH_FLAG_PACKED) { target->u.flags = (source->u.flags & ~(HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION; target->nTableMask = source->nTableMask; target->nNumUsed = source->nNumUsed; target->nNumOfElements = source->nNumOfElements; target->nNextFreeElement = source->nNextFreeElement; HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target))); target->nInternalPointer = source->nInternalPointer; HT_HASH_RESET_PACKED(target); if (target->nNumUsed == target->nNumOfElements) { zend_array_dup_packed_elements(source, target, 0); } else { zend_array_dup_packed_elements(source, target, 1); } if (target->nNumOfElements > 0 && target->nInternalPointer == HT_INVALID_IDX) { idx = 0; while (Z_TYPE(target->arData[idx].val) == IS_UNDEF) { idx++; } target->nInternalPointer = idx; } } else { target->u.flags = (source->u.flags & ~(HASH_FLAG_PERSISTENT|ZEND_HASH_APPLY_COUNT_MASK)) | HASH_FLAG_APPLY_PROTECTION; target->nTableMask = source->nTableMask; target->nNextFreeElement = source->nNextFreeElement; target->nInternalPointer = source->nInternalPointer; HT_SET_DATA_ADDR(target, emalloc(HT_SIZE(target))); HT_HASH_RESET(target); if (target->u.flags & HASH_FLAG_STATIC_KEYS) { if (source->nNumUsed == source->nNumOfElements) { idx = zend_array_dup_elements(source, target, 1, 0); } else { idx = zend_array_dup_elements(source, target, 1, 1); } } else { if (source->nNumUsed == source->nNumOfElements) { idx = zend_array_dup_elements(source, target, 0, 0); } else { idx = zend_array_dup_elements(source, target, 0, 1); } } target->nNumUsed = idx; target->nNumOfElements = idx; if (idx > 0 && target->nInternalPointer == HT_INVALID_IDX) { target->nInternalPointer = 0; } } return target; }
0
[ "CWE-190" ]
php-src
4cc0286f2f3780abc6084bcdae5dce595daa3c12
52,483,778,443,108,580,000,000,000,000,000,000,000
92
Fix #73832 - leave the table in a safe state if the size is too big.
seticc_lab(i_ctx_t * i_ctx_p, float *white, float *black, float *range_buff) { int code; gs_color_space * pcs; int i; /* build the color space object */ code = gs_cspace_build_ICC(&pcs, NULL, gs_gstate_memory(igs)); if (code < 0) return gs_rethrow(code, "building color space object"); /* record the current space as the alternative color space */ /* Get the lab profile. It may already be set in the icc manager. If not then lets populate it. */ if (igs->icc_manager->lab_profile == NULL ) { /* This can't happen as the profile should be initialized during the setting of the user params */ return gs_rethrow(code, "cannot find lab icc profile"); } /* Assign the LAB to LAB profile to this color space */ code = gsicc_set_gscs_profile(pcs, igs->icc_manager->lab_profile, gs_gstate_memory(igs)); if (code < 0) return gs_rethrow(code, "installing the lab profile"); pcs->cmm_icc_profile_data->Range.ranges[0].rmin = 0.0; pcs->cmm_icc_profile_data->Range.ranges[0].rmax = 100.0; for (i = 1; i < 3; i++) { pcs->cmm_icc_profile_data->Range.ranges[i].rmin = range_buff[2 * (i-1)]; pcs->cmm_icc_profile_data->Range.ranges[i].rmax = range_buff[2 * (i-1) + 1]; } /* Set the color space. We are done. */ code = gs_setcolorspace(igs, pcs); return code; }
0
[ "CWE-704" ]
ghostpdl
67d760ab775dae4efe803b5944b0439aa3c0b04a
23,393,012,537,594,376,000,000,000,000,000,000,000
35
Bug #700169 - unchecked type Bug #700169 "Type confusion in setcolorspace" In seticc() we extract "Name" from a dictionary, if it succeeds we then use it as a string, without checking the type to see if it is in fact a string. Add a check on the type, and add a couple to check that 'N' is an integer in a few places too.
create_backup (char const *to, const struct stat *to_st, bool leave_original) { /* When the input to patch modifies the same file more than once, patch only backs up the initial version of each file. To figure out which files have already been backed up, patch remembers the files that replace the original files. Files not known already are backed up; files already known have already been backed up before, and are skipped. When a patch tries to delete a file, in order to not break the above logic, we merely remember which file to delete. After the entire patch file has been read, we delete all files marked for deletion which have not been recreated in the meantime. */ if (to_st && ! (S_ISREG (to_st->st_mode) || S_ISLNK (to_st->st_mode))) fatal ("File %s is not a %s -- refusing to create backup", to, S_ISLNK (to_st->st_mode) ? "symbolic link" : "regular file"); if (to_st && lookup_file_id (to_st) == CREATED) { if (debug & 4) say ("File %s already seen\n", quotearg (to)); } else { int try_makedirs_errno = 0; char *bakname; if (origprae || origbase || origsuff) { char const *p = origprae ? origprae : ""; char const *b = origbase ? origbase : ""; char const *s = origsuff ? origsuff : ""; char const *t = to; size_t plen = strlen (p); size_t blen = strlen (b); size_t slen = strlen (s); size_t tlen = strlen (t); char const *o; size_t olen; for (o = t + tlen, olen = 0; o > t && ! ISSLASH (*(o - 1)); o--) /* do nothing */ ; olen = t + tlen - o; tlen -= olen; bakname = xmalloc (plen + tlen + blen + olen + slen + 1); memcpy (bakname, p, plen); memcpy (bakname + plen, t, tlen); memcpy (bakname + plen + tlen, b, blen); memcpy (bakname + plen + tlen + blen, o, olen); memcpy (bakname + plen + tlen + blen + olen, s, slen + 1); if ((origprae && (contains_slash (origprae + FILE_SYSTEM_PREFIX_LEN (origprae)) || contains_slash (to))) || (origbase && contains_slash (origbase))) try_makedirs_errno = ENOENT; } else { bakname = find_backup_file_name (to, backup_type); if (!bakname) xalloc_die (); } if (! to_st) { int fd; if (debug & 4) say ("Creating empty file %s\n", quotearg (bakname)); try_makedirs_errno = ENOENT; safe_unlink (bakname); while ((fd = safe_open (bakname, O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) { if (errno != try_makedirs_errno) pfatal ("Can't create file %s", quotearg (bakname)); makedirs (bakname); try_makedirs_errno = 0; } if (close (fd) != 0) pfatal ("Can't close file %s", quotearg (bakname)); } else if (leave_original) create_backup_copy (to, bakname, to_st, try_makedirs_errno == 0); else { if (debug & 4) say ("Renaming file %s to %s\n", quotearg_n (0, to), quotearg_n (1, bakname)); while (safe_rename (to, bakname) != 0) { if (errno == try_makedirs_errno) { makedirs (bakname); try_makedirs_errno = 0; } else if (errno == EXDEV) { create_backup_copy (to, bakname, to_st, try_makedirs_errno == 0); safe_unlink (to); break; } else pfatal ("Can't rename file %s to %s", quotearg_n (0, to), quotearg_n (1, bakname)); } } free (bakname); } }
1
[ "CWE-59" ]
patch
dce4683cbbe107a95f1f0d45fabc304acfb5d71a
80,857,221,028,679,830,000,000,000,000,000,000,000
116
Don't follow symlinks unless --follow-symlinks is given * src/inp.c (plan_a, plan_b), src/util.c (copy_to_fd, copy_file, append_to_file): Unless the --follow-symlinks option is given, open files with the O_NOFOLLOW flag to avoid following symlinks. So far, we were only doing that consistently for input files. * src/util.c (create_backup): When creating empty backup files, (re)create them with O_CREAT | O_EXCL to avoid following symlinks in that case as well.
static void print_request(struct drm_printer *m, struct i915_request *rq, const char *prefix) { const char *name = rq->fence.ops->get_timeline_name(&rq->fence); char buf[80] = ""; int x = 0; x = print_sched_attr(&rq->sched.attr, buf, x, sizeof(buf)); drm_printf(m, "%s %llx:%llx%s%s %s @ %dms: %s\n", prefix, rq->fence.context, rq->fence.seqno, i915_request_completed(rq) ? "!" : i915_request_started(rq) ? "*" : "", test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags) ? "+" : test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &rq->fence.flags) ? "-" : "", buf, jiffies_to_msecs(jiffies - rq->emitted_jiffies), name); }
0
[ "CWE-20", "CWE-190" ]
linux
c784e5249e773689e38d2bc1749f08b986621a26
75,069,936,784,148,985,000,000,000,000,000,000,000
25
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
MagickExport Image *SmushImages(const Image *images, const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception) { #define SmushImageTag "Smush/Image" CacheView *smush_view; const Image *image; Image *smush_image; MagickBooleanType matte, proceed, status; MagickOffsetType n; RectangleInfo geometry; register const Image *next; size_t height, number_images, width; ssize_t x_offset, y_offset; /* Compute maximum area of smushed area. */ assert(images != (Image *) NULL); assert(images->signature == MagickCoreSignature); if (images->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); image=images; matte=image->matte; number_images=1; width=image->columns; height=image->rows; next=GetNextImageInList(image); for ( ; next != (Image *) NULL; next=GetNextImageInList(next)) { if (next->matte != MagickFalse) matte=MagickTrue; number_images++; if (stack != MagickFalse) { if (next->columns > width) width=next->columns; height+=next->rows; if (next->previous != (Image *) NULL) height+=offset; continue; } width+=next->columns; if (next->previous != (Image *) NULL) width+=offset; if (next->rows > height) height=next->rows; } /* Smush images. */ smush_image=CloneImage(image,width,height,MagickTrue,exception); if (smush_image == (Image *) NULL) return((Image *) NULL); if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse) { InheritException(exception,&smush_image->exception); smush_image=DestroyImage(smush_image); return((Image *) NULL); } smush_image->matte=matte; (void) SetImageBackgroundColor(smush_image); status=MagickTrue; x_offset=0; y_offset=0; smush_view=AcquireVirtualCacheView(smush_image,exception); for (n=0; n < (MagickOffsetType) number_images; n++) { SetGeometry(smush_image,&geometry); GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry); if (stack != MagickFalse) { x_offset-=geometry.x; y_offset-=SmushYGap(smush_image,image,offset,exception); } else { x_offset-=SmushXGap(smush_image,image,offset,exception); y_offset-=geometry.y; } status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset); proceed=SetImageProgress(image,SmushImageTag,n,number_images); if (proceed == MagickFalse) break; if (stack == MagickFalse) { x_offset+=(ssize_t) image->columns; y_offset=0; } else { x_offset=0; y_offset+=(ssize_t) image->rows; } image=GetNextImageInList(image); } if (stack == MagickFalse) smush_image->columns=(size_t) x_offset; else smush_image->rows=(size_t) y_offset; smush_view=DestroyCacheView(smush_view); if (status == MagickFalse) smush_image=DestroyImage(smush_image); return(smush_image); }
0
[ "CWE-665" ]
ImageMagick6
27b1c74979ac473a430e266ff6c4b645664bc805
324,447,022,029,194,630,000,000,000,000,000,000,000
129
https://github.com/ImageMagick/ImageMagick/issues/1522
static inline void tcp_advance_highest_sack(struct sock *sk, struct sk_buff *skb) { tcp_sk(sk)->highest_sack = tcp_skb_is_last(sk, skb) ? NULL : tcp_write_queue_next(sk, skb); }
0
[ "CWE-416", "CWE-269" ]
linux
bb1fceca22492109be12640d49f5ea5a544c6bb4
246,129,762,974,249,900,000,000,000,000,000,000,000
5
tcp: fix use after free in tcp_xmit_retransmit_queue() When tcp_sendmsg() allocates a fresh and empty skb, it puts it at the tail of the write queue using tcp_add_write_queue_tail() Then it attempts to copy user data into this fresh skb. If the copy fails, we undo the work and remove the fresh skb. Unfortunately, this undo lacks the change done to tp->highest_sack and we can leave a dangling pointer (to a freed skb) Later, tcp_xmit_retransmit_queue() can dereference this pointer and access freed memory. For regular kernels where memory is not unmapped, this might cause SACK bugs because tcp_highest_sack_seq() is buggy, returning garbage instead of tp->snd_nxt, but with various debug features like CONFIG_DEBUG_PAGEALLOC, this can crash the kernel. This bug was found by Marco Grassi thanks to syzkaller. Fixes: 6859d49475d4 ("[TCP]: Abstract tp->highest_sack accessing & point to next skb") Reported-by: Marco Grassi <marco.gra@gmail.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Cc: Yuchung Cheng <ycheng@google.com> Cc: Neal Cardwell <ncardwell@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
static int __check_ptr_off_reg(struct bpf_verifier_env *env, const struct bpf_reg_state *reg, int regno, bool fixed_off_ok) { /* Access to this pointer-typed register or passing it to a helper * is only allowed in its original, unmodified form. */ if (!fixed_off_ok && reg->off) { verbose(env, "dereference of modified %s ptr R%d off=%d disallowed\n", reg_type_str(env, reg->type), regno, reg->off); return -EACCES; } if (!tnum_is_const(reg->var_off) || reg->var_off.value) { char tn_buf[48]; tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off); verbose(env, "variable %s access var_off=%s disallowed\n", reg_type_str(env, reg->type), tn_buf); return -EACCES; } return 0; }
0
[ "CWE-787" ]
linux
64620e0a1e712a778095bd35cbb277dc2259281f
186,718,264,085,003,470,000,000,000,000,000,000,000
25
bpf: Fix out of bounds access for ringbuf helpers Both bpf_ringbuf_submit() and bpf_ringbuf_discard() have ARG_PTR_TO_ALLOC_MEM in their bpf_func_proto definition as their first argument. They both expect the result from a prior bpf_ringbuf_reserve() call which has a return type of RET_PTR_TO_ALLOC_MEM_OR_NULL. Meaning, after a NULL check in the code, the verifier will promote the register type in the non-NULL branch to a PTR_TO_MEM and in the NULL branch to a known zero scalar. Generally, pointer arithmetic on PTR_TO_MEM is allowed, so the latter could have an offset. The ARG_PTR_TO_ALLOC_MEM expects a PTR_TO_MEM register type. However, the non- zero result from bpf_ringbuf_reserve() must be fed into either bpf_ringbuf_submit() or bpf_ringbuf_discard() but with the original offset given it will then read out the struct bpf_ringbuf_hdr mapping. The verifier missed to enforce a zero offset, so that out of bounds access can be triggered which could be used to escalate privileges if unprivileged BPF was enabled (disabled by default in kernel). Fixes: 457f44363a88 ("bpf: Implement BPF ring buffer and verifier support for it") Reported-by: <tr3e.wang@gmail.com> (SecCoder Security Lab) Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Alexei Starovoitov <ast@kernel.org>
static int generate_session_id(const SSL *ssl, unsigned char *id, unsigned int *id_len) { unsigned int count = 0; do { if (RAND_bytes(id, *id_len) <= 0) return 0; /* * Prefix the session_id with the required prefix. NB: If our prefix * is too long, clip it - but there will be worse effects anyway, eg. * the server could only possibly create 1 session ID (ie. the * prefix!) so all future session negotiations will fail due to * conflicts. */ memcpy(id, session_id_prefix, (strlen(session_id_prefix) < *id_len) ? strlen(session_id_prefix) : *id_len); } while (SSL_has_matching_session_id(ssl, id, *id_len) && (++count < MAX_SESSION_ID_ATTEMPTS)); if (count >= MAX_SESSION_ID_ATTEMPTS) return 0; return 1; }
0
[ "CWE-399" ]
openssl
380f18ed5f140e0ae1b68f3ab8f4f7c395658d9e
208,572,317,147,339,400,000,000,000,000,000,000,000
24
CVE-2016-0798: avoid memory leak in SRP The SRP user database lookup method SRP_VBASE_get_by_user had confusing memory management semantics; the returned pointer was sometimes newly allocated, and sometimes owned by the callee. The calling code has no way of distinguishing these two cases. Specifically, SRP servers that configure a secret seed to hide valid login information are vulnerable to a memory leak: an attacker connecting with an invalid username can cause a memory leak of around 300 bytes per connection. Servers that do not configure SRP, or configure SRP but do not configure a seed are not vulnerable. In Apache, the seed directive is known as SSLSRPUnknownUserSeed. To mitigate the memory leak, the seed handling in SRP_VBASE_get_by_user is now disabled even if the user has configured a seed. Applications are advised to migrate to SRP_VBASE_get1_by_user. However, note that OpenSSL makes no strong guarantees about the indistinguishability of valid and invalid logins. In particular, computations are currently not carried out in constant time. Reviewed-by: Rich Salz <rsalz@openssl.org>
static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, enum hrtimer_mode mode) { struct hrtimer_cpu_base *cpu_base; int base; memset(timer, 0, sizeof(struct hrtimer)); cpu_base = raw_cpu_ptr(&hrtimer_bases); if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS) clock_id = CLOCK_MONOTONIC; base = hrtimer_clockid_to_base(clock_id); timer->base = &cpu_base->clock_base[base]; timerqueue_init(&timer->node); }
0
[ "CWE-200" ]
tip
dfb4357da6ddbdf57d583ba64361c9d792b0e0b1
153,070,057,394,107,110,000,000,000,000,000,000,000
17
time: Remove CONFIG_TIMER_STATS Currently CONFIG_TIMER_STATS exposes process information across namespaces: kernel/time/timer_list.c print_timer(): SEQ_printf(m, ", %s/%d", tmp, timer->start_pid); /proc/timer_list: #11: <0000000000000000>, hrtimer_wakeup, S:01, do_nanosleep, cron/2570 Given that the tracer can give the same information, this patch entirely removes CONFIG_TIMER_STATS. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: John Stultz <john.stultz@linaro.org> Cc: Nicolas Pitre <nicolas.pitre@linaro.org> Cc: linux-doc@vger.kernel.org Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Xing Gao <xgao01@email.wm.edu> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Jessica Frazelle <me@jessfraz.com> Cc: kernel-hardening@lists.openwall.com Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Tejun Heo <tj@kernel.org> Cc: Michal Marek <mmarek@suse.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Olof Johansson <olof@lixom.net> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: linux-api@vger.kernel.org Cc: Arjan van de Ven <arjan@linux.intel.com> Link: http://lkml.kernel.org/r/20170208192659.GA32582@beast Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static void i40e_remove_queue_channels(struct i40e_vsi *vsi) { enum i40e_admin_queue_err last_aq_status; struct i40e_cloud_filter *cfilter; struct i40e_channel *ch, *ch_tmp; struct i40e_pf *pf = vsi->back; struct hlist_node *node; int ret, i; /* Reset rss size that was stored when reconfiguring rss for * channel VSIs with non-power-of-2 queue count. */ vsi->current_rss_size = 0; /* perform cleanup for channels if they exist */ if (list_empty(&vsi->ch_list)) return; list_for_each_entry_safe(ch, ch_tmp, &vsi->ch_list, list) { struct i40e_vsi *p_vsi; list_del(&ch->list); p_vsi = ch->parent_vsi; if (!p_vsi || !ch->initialized) { kfree(ch); continue; } /* Reset queue contexts */ for (i = 0; i < ch->num_queue_pairs; i++) { struct i40e_ring *tx_ring, *rx_ring; u16 pf_q; pf_q = ch->base_queue + i; tx_ring = vsi->tx_rings[pf_q]; tx_ring->ch = NULL; rx_ring = vsi->rx_rings[pf_q]; rx_ring->ch = NULL; } /* Reset BW configured for this VSI via mqprio */ ret = i40e_set_bw_limit(vsi, ch->seid, 0); if (ret) dev_info(&vsi->back->pdev->dev, "Failed to reset tx rate for ch->seid %u\n", ch->seid); /* delete cloud filters associated with this channel */ hlist_for_each_entry_safe(cfilter, node, &pf->cloud_filter_list, cloud_node) { if (cfilter->seid != ch->seid) continue; hash_del(&cfilter->cloud_node); if (cfilter->dst_port) ret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter, false); else ret = i40e_add_del_cloud_filter(vsi, cfilter, false); last_aq_status = pf->hw.aq.asq_last_status; if (ret) dev_info(&pf->pdev->dev, "Failed to delete cloud filter, err %s aq_err %s\n", i40e_stat_str(&pf->hw, ret), i40e_aq_str(&pf->hw, last_aq_status)); kfree(cfilter); } /* delete VSI from FW */ ret = i40e_aq_delete_element(&vsi->back->hw, ch->seid, NULL); if (ret) dev_err(&vsi->back->pdev->dev, "unable to remove channel (%d) for parent VSI(%d)\n", ch->seid, p_vsi->seid); kfree(ch); } INIT_LIST_HEAD(&vsi->ch_list); }
0
[ "CWE-400", "CWE-401" ]
linux
27d461333459d282ffa4a2bdb6b215a59d493a8f
274,725,512,782,208,700,000,000,000,000,000,000,000
81
i40e: prevent memory leak in i40e_setup_macvlans In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory for ch should be released. Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
FilterEncodingNode *FLTCreateBinaryCompFilterEncodingNode(void) { FilterEncodingNode *psFilterNode = NULL; psFilterNode = FLTCreateFilterEncodingNode(); /* used to store case sensitivity flag. Default is 0 meaning the comparing is case sensititive */ psFilterNode->pOther = (int *)malloc(sizeof(int)); (*(int *)(psFilterNode->pOther)) = 0; return psFilterNode; }
0
[ "CWE-200", "CWE-119" ]
mapserver
e52a436c0e1c5e9f7ef13428dba83194a800f4df
215,023,328,165,304,860,000,000,000,000,000,000,000
12
security fix (patch by EvenR)
static int getScreenColumns(void) { int cols; #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO inf; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &inf); cols = inf.dwSize.X; #else struct winsize ws; cols = (ioctl(1, TIOCGWINSZ, &ws) == -1) ? 80 : ws.ws_col; #endif // cols is 0 in certain circumstances like inside debugger, which creates further issues return (cols > 0) ? cols : 80; }
0
[ "CWE-200" ]
mongo
035cf2afc04988b22cb67f4ebfd77e9b344cb6e0
322,516,803,212,934,600,000,000,000,000,000,000,000
13
SERVER-25335 avoid group and other permissions when creating .dbshell history file

Dataset Card for "diversevul"

Unofficial, not affiliated with the authors.

Downloads last month
20
Edit dataset card