PVS-Studioéçã³ãŒãã¢ãã©ã€ã¶ãŒã䜿çšããŠãèå³æ·±ãå Žæãæ€çŽ¢ããŸããã äžèšã®èšèªã§èšè¿°ãããã³ãŒãã®ãšã©ãŒããã³æœåšçãªè匱æ§ãæ€åºã§ããŸãã
èªåã§ãšã©ãŒãæ¢ãããšã«èå³ãããå Žåã¯ããã€ã§ãåœç€Ÿã®ã¢ãã©ã€ã¶ãŒãããŠã³ããŒãããŠè©Šãããšãã§ããŸãã åŠçãç±å¿ãªããã°ã©ããŒåãã®ã¢ãã©ã€ã¶ãŒã®ç¡æçããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã®éçºè åãã®ç¡æã©ã€ã»ã³ã¹ ãããã³ãã¹ãŠãã¹ãŠã®è©ŠçšçãæäŸããŠããŸãã ãããããæ¥å¹ŽãŸã§ã«ããã10ãç²åŸã§ããã§ããããïŒ :)
泚ïŒèªè ãèªåã§ç¢ºèªããã¢ãã©ã€ã¶ãŒã®èŠåãèŠãåã«ãç°åžžãèªåã§ç¹å®ããããšããå§ãããŸãã ããã€ã®ééããèŠã€ããããšãã§ããŸããïŒ
10äœ
åºå žïŒ ãããŠåã³å®å®ãžïŒãŠãã³ãŒã³ã¹ãã©ãªãŠã ã蚪ããæ¹æ³
ãã®ãšã©ãŒã¯ãStellariumä»®æ³ãã©ãã¿ãªãŠã ã®ç¢ºèªäžã«çºèŠãããŸããã
äžèšã®ã³ãŒãã¹ããããã¯ãå°ããªãã®ã§ãããããããªãããŒãªãšã©ãŒãå«ãã§ããŸãã
Plane::Plane(Vec3f &v1, Vec3f &v2, Vec3f &v3) : distance(0.0f), sDistance(0.0f) { Plane(v1, v2, v3, SPolygon::CCW); }
èŠã€ããïŒ
PVS-StudioèŠåïŒ V603ãªããžã§ã¯ãã¯äœæãããŸãããã䜿çšãããŠããŸããã ã³ã³ã¹ãã©ã¯ã¿ãåŒã³åºãå Žåã¯ããthis-> Plane :: PlaneïŒ....ïŒãã䜿çšããå¿ èŠããããŸãã Plane.cpp 29
ã³ãŒãã®äœæè ã¯ãã¡ã€ã³ã³ã³ã¹ãã©ã¯ã¿ãŒã«åã蟌ãŸããå¥ã®ã³ã³ã¹ãã©ã¯ã¿ãŒã䜿çšããŠããªããžã§ã¯ãã®ãã£ãŒã«ãã®äžéšãåæåããããšãæãã§ããŸããã 確ãã«ã圌ã¯å¯èŠé åãé¢ãããšãã«ç Žå£ãããäžæãªããžã§ã¯ãã®ã¿ãäœæã§ããŸããã ãããã£ãŠããªããžã§ã¯ãã®ããã€ãã®ãã£ãŒã«ãã¯åæåãããŸããã
ãã¹ããããã³ã³ã¹ãã©ã¯ã¿ãŒåŒã³åºãã®ä»£ããã«ãC ++ 11ã§å°å ¥ãããå§ä»»ã³ã³ã¹ãã©ã¯ã¿ãŒã䜿çšããå¿ èŠããããŸãã ããšãã°ããããè¡ãããšãã§ããŸãïŒ
Plane::Plane(Vec3f& v1, Vec3f& v2, Vec3f& v3) : Plane(v1, v2, v3, SPolygon::CCW) { distance = 0.0f; sDistance = 0.0f; }
ãã®åŸããã¹ãŠã®å¿ é ãã£ãŒã«ããæ£ããåæåãããŸãã ããã¯çŽ æŽãããããšã§ã¯ãããŸãããïŒ
9äœ
ãœãŒã¹ïŒ Perl 5ïŒãã¯ãããšã©ãŒãé ãæ¹æ³
9çªç®ã¯ãPerl 5ãœãŒã¹ã³ãŒãããã®æ³šç®ãã¹ããã¯ãã§ãã
ååã®Svyatoslavã¯ãèšäºãæžãããã®ãšã©ãŒãåéããŠããã¯ãã®äœ¿çšã«é¢ããŠã¢ãã©ã€ã¶ãŒã«ãã£ãŠçºè¡ãããèŠåã«ééããŸããã ããã«ãããŸãïŒ
PP(pp_match) { .... MgBYTEPOS_set(mg, TARG, truebase, RXp_OFFS(prog)[0].end); .... }
åé¡ãäœã§ããããç¥ãããã«ãã¹ãŽã£ã¢ãã¹ã©ãã¯ããã«æãäžããŸããã 圌ã¯ãã¯ãã®å®çŸ©ãéããããã«ããã€ãã®ãã¹ãããããã¯ããå«ãŸããŠããããšã確èªããŸãããããã®äžéšã«ã¯ãã¹ãããããã¯ããå«ãŸããŠããŸããã ç解ããã®ãéåžžã«å°é£ã§ãã£ããããååŠçæžã¿ã®ãã¡ã€ã«ã䜿çšããå¿ èŠããããŸããã ããããæ²ããããªãããã¯åœ¹ã«ç«ã¡ãŸããã§ããã åã®ã³ãŒãè¡ã®ä»£ããã«ãSvyatoslavã¯ãããçºèŠããŸããã
(((targ)->sv_flags & 0x00000400) && (!((targ)->sv_flags & 0x00200000) || S_sv_only_taint_gmagic(targ)) ? (mg)->mg_len = ((prog->offs)[0].end), (mg)->mg_flags |= 0x40 : ((mg)->mg_len = (((targ)->sv_flags & 0x20000000) && !__builtin_expect(((((PL_curcop)->cop_hints + 0) & 0x00000008) ? (_Bool)1 :(_Bool)0),(0))) ? (ssize_t)Perl_utf8_length( (U8 *)(truebase), (U8 *)(truebase)+((prog->offs)[0].end)) : (ssize_t)((prog->offs)[0].end), (mg)->mg_flags &= ~0x40));
èŠåPVS-StudioïŒ V502 ãïŒïŒãæŒç®åã¯ãäºæ³ãšã¯ç°ãªãæ¹æ³ã§åäœããå¯èœæ§ããããŸãã ãïŒïŒãæŒç®åã®åªå é äœã¯ãã&&ãæŒç®åãããäœããªã£ãŠããŸãã pp_hot.c 3036
ç§ã®ç®ã§ãã®ãããªãšã©ãŒãèŠã€ããã®ã¯é£ãããšæããŸãã æ£çŽãªãšãããç§ãã¡ã¯ãã®ã³ãŒããé·ãéé»æ³ããå®éã«ããã«ééãã¯ãªããšããçµè«ã«éããŸããã ãããããããã«ããŠããããã¯èªã¿ã«ããã³ãŒãã®ããªãé¢çœãäŸã§ãã
ãã¯ãã¯æªã§ãããšèšãããŠããŸãã ãã¡ãããããããäžå¯æ¬ ã§ããããšãå€æããå ŽåããããŸããããã¯ããé¢æ°ã«çœ®ãæããããšãã§ããå Žåã¯ãå¿ ãå®è¡ããå¿ èŠããããŸãã
ãã¹ãããããã¯ãã¯ç¹ã«å°ããŸãã ç解ãé£ããã ãã§ãªããäºæž¬ã§ããªãçµæãããããå¯èœæ§ããããŸãã ãã¯ãã®äœæè ã誀ã£ãŠãã®ãããªãã¯ããééããå Žåãé¢æ°å ã§èŠã€ãããããã¯ããã«å°é£ã«ãªããŸãã
8äœ
åºå žïŒ ChromiumïŒãã®ä»ã®ãšã©ãŒ
次ã®äŸã¯ãChromiumãããžã§ã¯ãã®åæã«é¢ããäžé£ã®èšäºããåŒçšãããã®ã§ãã 圌女ã¯WebRTCã©ã€ãã©ãªã§èªèº«ãã«ããŒããŸããã
std::vector<SdpVideoFormat> StereoDecoderFactory::GetSupportedFormats() const { std::vector<SdpVideoFormat> formats = ....; for (const auto& format : formats) { if (cricket::CodecNamesEq(....)) { .... formats.push_back(stereo_format); } } return formats; }
PVS-StudioèŠåïŒ V789 CWE-672ç¯å²ããŒã¹ã®forã«ãŒãã§äœ¿çšããããformatsãã³ã³ããã®ã€ãã¬ãŒã¿ã¯ããpush_backãé¢æ°ã®åŒã³åºãæã«ç¡å¹ã«ãªããŸãã stereocodecfactory.cc 89
ãšã©ãŒã¯ãç¯å²ããŒã¹ã®forã«ãŒãå ã§ãã©ãŒããããã¯ãã«ã®ãµã€ãºãå€åããããšã§ãã ç¯å²ããŒã¹ã®ã«ãŒãã¯ã€ãã¬ãŒã¿ãŒã«åºã¥ããŠããããããã®ãããªã«ãŒãå ã®ã³ã³ãããŒã®ãµã€ãºãå€æŽãããšããããã®ã€ãã¬ãŒã¿ãŒãç¡å¹ã«ãªãå¯èœæ§ããããŸãã
æ瀺çãªå埩åã䜿çšããŠã«ãŒããæžãæãããšããã®ãšã©ãŒãç¶ããŸãã ãããã£ãŠãæ確ã«ããããã«ã次ã®ã³ãŒãã䜿çšã§ããŸãã
for (auto format = begin(formats), __end = end(formats); format != __end; ++format) { if (cricket::CodecNamesEq(....)) { .... formats.push_back(stereo_format); } }
ããšãã°ã push_backã¡ãœããã䜿çšãããšããã¯ãã«ã解æŸãããå Žåããããã€ãã¬ãŒã¿ã¯ç¡å¹ãªã¡ã¢ãªé åãæããŸãã
ãã®ãããªãšã©ãŒãåé¿ããã«ã¯ãã«ãŒã«ãé å®ããå¿ èŠããããŸããã«ãŒãå ã§ã³ã³ããã®ãµã€ãºãå€æŽããªãã§ãã ãããæ¡ä»¶ã¯ãã®ã³ã³ããã«é¢é£ä»ããããŠããŸãã ããã¯ãç¯å²ããŒã¹ã®ã«ãŒãããã³å埩åã䜿çšããã«ãŒãã«é©çšãããŸãã StackOverflowã®ãã£ã¹ã«ãã·ã§ã³ã§ãã©ã®æäœãã€ãã¬ãŒã¿ã®ç¡å¹åã«ã€ãªãããã«ã€ããŠèªãããšãã§ããŸãã
7äœ
åºå žïŒ GodotïŒéçã³ãŒãã¢ãã©ã€ã¶ãŒã®å®æçãªäœ¿çš
ãããªã²ãŒã æ¥çã®æåã®äŸã¯ãGodotã²ãŒã ãšã³ãžã³ã§çºèŠããã³ãŒãã®ã¹ããããã§ãã ããªãã®ç®ã§ãšã©ãŒãçºèŠããããã«æ±ããããªããã°ãªããªããããããŸããããç§ãã¡ã®æŽç·Žãããèªè ã¯ãããåŠçã§ãããšç¢ºä¿¡ããŠããŸãïŒ
void AnimationNodeBlendSpace1D::add_blend_point( const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index) { ERR_FAIL_COND(blend_points_used >= MAX_BLEND_POINTS); ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(p_at_index < -1 || p_at_index > blend_points_used); if (p_at_index == -1 || p_at_index == blend_points_used) { p_at_index = blend_points_used; } else { for (int i = blend_points_used - 1; i > p_at_index; i++) { blend_points[i] = blend_points[i - 1]; } } .... }
PVS-StudioèŠåïŒ V621 CWE-835 ãforãæŒç®åã®æ€æ»ãæ€èšããŠãã ããã ã«ãŒãã誀ã£ãŠå®è¡ããããããŸã£ããå®è¡ãããªãå¯èœæ§ããããŸãã animation_blend_space_1d.cpp 113
ãµã€ã¯ã«ã®ç¶æ ãããã«è©³ããèããŠã¿ãŸãããã ã«ãŠã³ã¿ãŒå€æ°ã¯ãå€blend_points_used-1ã§åæåãããŸãã åæã«ãåã®2ã€ã®ãã§ãã¯ïŒ ERR_FAIL_CONDããã³if ïŒã«åºã¥ããŠãã«ãŒãã®å®è¡æã«ã blend_points_usedãåžžã«p_at_indexããã倧ããããšãæããã«ãªããŸãã ãããã£ãŠãã«ãŒãæ¡ä»¶ãåžžã«çã«ãªãããã«ãŒãããŸã£ããå®è¡ãããŸããã
blend_points_usedã1 == p_at_indexã®å Žåãã«ãŒãã¯å®è¡ãããŸããã
ä»ã®ãã¹ãŠã®å Žåãã«ãŠã³ã¿iã¯ã«ãŒãã®åå埩ã§å¢å ããããããã§ãã¯i> p_at_indexã¯åžžã«trueã§ãã
ãµã€ã¯ã«ã¯æ°žé ã«ç¶ãããã«èŠãããããããŸããããããã§ã¯ãããŸããã
ãŸããå€æ°iã®æŽæ°ãªãŒããŒãããŒãçºçããŸãããããã¯æªå®çŸ©ã®åäœã§ãã ãããã£ãŠãããã«é Œã䟡å€ã¯ãããŸããã
iãunsigned intåã§ãã£ãå Žåãã«ãŠã³ã¿ãŒãå¯èœãªæ倧å€ã«éããåŸã i ++æŒç®åã¯ããã0ã«å€æããŸã ã ãã®åäœã¯æšæºã§å®çŸ©ãããŠãããã眲åãªãã©ããã³ã°ããšåŒã°ããŸãã ãã ãããã®ãããªã¡ã«ããºã ã䜿çšããããšãè¯ãèãã§ã¯ãªãããšã«æ³šæããå¿ èŠããããŸãã
ããããããã¯æåã®å Žæã§ããããçµå±ã¯ãŸã 2ã€ç®ããããŸãïŒ å®éã«ã¯ãæŽæ°ãªãŒããŒãããŒã«éããããšãããããŸããã ã¢ã¬ã€ãæµ·å€ã«è¡ãåã ããã¯ãã¢ã¬ã€ã«å²ãåœãŠããããããã¯å€ã®ã¡ã¢ãªé åã«ã¢ã¯ã»ã¹ããããšããããšãæå³ããŸãã ãããŠããããæŒ ç¶ãšããè¡åã§ãã å€å žçãªäŸ:)
ãã®ãããªãšã©ãŒãç°¡åã«åé¿ã§ããããã«ãããããããã€ãã®æšå¥šäºé ã®ã¿ã瀺ããŸãã
- ããã·ã³ãã«ã§çŽæçãªã³ãŒããæžã
- ãã培åºçãªã³ãŒãã¬ãã¥ãŒãè¡ããæ°ãã«èšè¿°ãããã³ãŒãã«å¯ŸããŠããå€ãã®ãã¹ããèšè¿°ããŸã
- éçã¢ãã©ã€ã¶ãŒã䜿çšããŸã;ïŒ
6äœ
ãœãŒã¹ïŒ Amazon LumberyardïŒThe Cry of the Soul
gamedevæ¥çã®å¥ã®äŸãã€ãŸãAmazon Lumberyard AAAãšã³ãžã³ã®ãœãŒã¹ã³ãŒãããã
void TranslateVariableNameByOperandType(....) { // Igor: yet another Qualcomm's special case // GLSL compiler thinks that -2147483648 is // an integer overflow which is not if (*((int*)(&psOperand->afImmediates[0])) == 2147483648) { bformata(glsl, "-2147483647-1"); } else { // Igor: this is expected to fix // paranoid compiler checks such as Qualcomm's if (*((unsigned int*)(&psOperand->afImmediates[0])) >= 2147483648) { bformata(glsl, "%d", *((int*)(&psOperand->afImmediates[0]))); } else { bformata(glsl, "%d", *((int*)(&psOperand->afImmediates[0]))); } } bcatcstr(glsl, ")"); .... }
PVS-StudioèŠåïŒ V523 ãthenãã¹ããŒãã¡ã³ãã¯ãelseãã¹ããŒãã¡ã³ããšåçã§ãã toglsloperand.c 700
Amazon Lumberyardã¯ãã¯ãã¹ãã©ãããã©ãŒã ãšã³ãžã³ãšããŠéçºãããŠããŸãã ãããã£ãŠãéçºè ã¯ã§ããã ãå€ãã®ã³ã³ãã€ã©ããµããŒãããããšããŠããŸãã ããã°ã©ããŒIgorã¯ãã³ã¡ã³ãã§äŒããããŠããããã«ãQualcommã³ã³ãã€ã©ãŒã«ééããŸããã
ã€ãŽãŒã«ãã¿ã¹ã¯ãå®äºããã³ã³ãã€ã©ã®ãåå·ççãªããã§ãã¯ã«å¯ŸåŠã§ãããã©ããã¯ããããŸããããéåžžã«å¥åŠãªã³ãŒããæ®ããŸããã ifã¹ããŒãã¡ã³ãã® thenãã©ã³ããšelseãã©ã³ãã®äž¡æ¹ã«ãŸã£ããåãã³ãŒããå«ãŸããŠããã®ã¯å¥åŠã§ãã ã»ãšãã©ã®å Žåããã®ãããªãšã©ãŒã¯ãç²éãªã³ããŒããŒã¹ãã®çµæãšããŠçºçãããã®ã§ãã
ããã§äœãã¢ããã€ã¹ã§ãããããããããŸããã ãã®ãããAmazon Lumberyardéçºè ããã°ã®ä¿®æ£ã«æåããããã°ã©ããŒã®ã€ãŽãŒã«ã«å¹žéãç¥ããŸãïŒ
5äœ
åºå žïŒ ç¹°ãè¿ãã«ãªããŸãããPVS-Studioã¢ãã©ã€ã¶ãŒã¯äººéããã泚ææ·±ãããšãå€æããŸãã
次ã®äŸã§èå³æ·±ã話ãèµ·ãããŸããã ç§ã®ååã®Andrei Karpovã¯ãQtãã¬ãŒã ã¯ãŒã¯ã®æ¬¡ã®ãã¹ãã«é¢ããèšäºãæºåããŠããŸããã 泚ç®ã«å€ãããšã©ãŒãæžãéçšã§ã圌ã¯ã¢ãã©ã€ã¶ãŒããã®èŠåã«ééããŸããããããã¯ééã£ãŠãããšèããŸããã é¢é£ããã³ãŒãã¹ãããããšèŠåã次ã«ç€ºããŸãã
QWindowsCursor::CursorState QWindowsCursor::cursorState() { enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; CURSORINFO cursorInfo; cursorInfo.cbSize = sizeof(CURSORINFO); if (GetCursorInfo(&cursorInfo)) { if (cursorInfo.flags & CursorShowing) // <= V616 .... }
PVS-StudioèŠåïŒ V616 CWE-480å€ã0ã®ãCursorShowingããšããååã®å®æ°ã¯ããããåäœã®æäœã§äœ¿çšãããŸãã qwindowscursor.cpp 669
ã€ãŸããPVS-Studioã¯ãæããã«ãšã©ãŒããªãã£ãå Žæã§èªããŸããïŒ CursorShowingå®æ°ã0ã§ããããšã¯ã§ããŸãããæåéãããã®äžã®2ã3è¡ã¯1ã«åæåãããããã§ãã
æ€èšŒã«äžå®å®ãªããŒãžã§ã³ã®ã¢ãã©ã€ã¶ãŒã䜿çšããããããAndreiã¯èŠåã®æ£ç¢ºããçã£ãŠããŸããã 圌ã¯ãã®ã³ãŒãã®ã»ã¯ã·ã§ã³ãæ°å泚ææ·±ã調ã¹ãŸããããããã§ããšã©ãŒã¯èŠã€ãããŸããã§ããã ãã®çµæãä»ã®ååãç¶æ³ãä¿®æ£ã§ããããã«ã圌ã¯ãã®èª€æ€ç¥ããã°ãã©ãã«ãŒã«æžããŸããã
ãããŠã詳现ãªåæã«ãã£ãŠã®ã¿ãPVS-Studioãåã³äººéããã泚ææ·±ãããšãæããã«ãªããŸããã å€0x1ã¯ååä»ãå®æ°cursorShowingã«å²ãåœãŠããããããå®æ°æŒç®ãandãã«ã¯ååä»ãå®æ°CursorShowingãå«ãŸããŸãã æåã¯å°æåã§å§ãŸãã2çªç®ã¯å€§æåã§å§ãŸãããããããã¯å®å šã«ç°ãªãå®æ°ã§ãã
QWindowsCursorã¯ã©ã¹ã«ã¯å®éã«ãã®ååã®å®æ°ãå«ãŸããŠãããããã³ãŒãã¯æ£åžžã«ã³ã³ãã€ã«ãããŸãã 圌女ã®å®çŸ©ã¯æ¬¡ã®ãšããã§ãã
class QWindowsCursor : public QPlatformCursor { public: enum CursorState { CursorShowing, CursorHidden, CursorSuppressed }; .... }
ååä»ãåæåå®æ°ãæ瀺çã«å²ãåœãŠãªãå Žåãããã©ã«ãã§åæåãããŸãã CursorShowingã¯åæã®æåã®èŠçŽ ã§ããããã 0ã«èšå®ãããŸã ã
ãã®ãããªééããé²ãããã«ããšã³ãã£ãã£ã«ããŸãã«ã䌌ãååãä»ããªãã§ãã ããã ãããã®ãšã³ãã£ãã£ãåãã¿ã€ãã§ããããæé»çã«çžäºã«ãã£ã¹ãã§ããå Žåã¯ãç¹ã«ãã®ã«ãŒã«ã«åŸãå¿ èŠããããŸãã å®éããã®ãããªå Žåãç®ã§ãšã©ãŒãæ€åºããããšã¯äºå®äžäžå¯èœã§ãããæ£ãããªãã³ãŒãã¯æ£åžžã«ã³ã³ãã€ã«ããããããžã§ã¯ãå ã§åé¡ãªãåäœããŸãã
4äœ
ãœãŒã¹ïŒ å ¥åããŒã¿ãåŠçããŠã足ã§æ®åœ±ããŸã
ããã3ã®ãã¡ã€ããªã¹ãã«è¿ã¥ããŠããŸãããFreeSWITCHãããžã§ã¯ãã®ãšã©ãŒã¯æ¬¡ã ã«çºçããŸãã
static const char *basic_gets(int *cnt) { .... int c = getchar(); if (c < 0) { if (fgets(command_buf, sizeof(command_buf) - 1, stdin) != command_buf) { break; } command_buf[strlen(command_buf)-1] = '\0'; /* remove endline */ break; } .... }
PVS-StudioèŠåïŒ V1010 CWE-20æªãã§ãã¯ã®æ±æããŒã¿ãã€ã³ããã¯ã¹ã§äœ¿çšãããŠããŸãïŒ 'strlenïŒcommand_bufïŒ'ã
ã¢ãã©ã€ã¶ãŒã¯ãåŒstrlenïŒcommand_bufïŒ-1ãæªæ€èšŒããŒã¿ã䜿çšããããšãèŠåããŸãã ãããŠå®éïŒCèšèªæååïŒåäžã®æå-'\ 0'ãå«ãïŒã®èŠ³ç¹ããcommand_bufã空ã§ããããšãå€æããå Žåã strlenïŒcommand_bufïŒã¯0ãè¿ããŸã ã ãã®å Žåã command_buf [-1]ãåŒã³åºãã ãæªå®çŸ©ã®åäœãè¡šããŸãã ãã©ãã«ïŒ
ãã®ééãã®æ£äœã¯ãããããªãèµ·ãããã§ãããªãã ã©ã®ããã«èµ·ãããã§ãã ãã®ãšã©ãŒã¯ãèªåã§ãã¿ãããããŠåçŸã§ãã楜ããäŸã®1ã€ã§ãã FreeSwitchãèµ·åããäžèšã®ã³ãŒãã»ã¯ã·ã§ã³ã®å®è¡ã«ã€ãªããã¢ã¯ã·ã§ã³ãå®è¡ããããã°ã©ã ã«å ¥åçšã®ç©ºè¡ãæž¡ãããšãã§ããŸãã
ãã®çµæãæéŠã軜ãããããšãåäœäžã®ããã°ã©ã ãåäœããªãããã°ã©ã ã«ãªããŸãïŒãããã ãšã¬ã¬ã³ãã§ã¯ãããŸããïŒã ãã®ãšã©ãŒãåçŸããæ¹æ³ã®è©³çŽ°ã¯ãäžèšã®ãªã³ã¯ã®ãœãŒã¹èšäºã«èšèŒãããŠããŸãããä»ã®ãšããã¯æ確ãªçµæã瀺ããŸãã
å ¥åã¯äœã§ãæ§ããŸããã®ã§ãåžžã«ç¢ºèªããå¿ èŠããããŸãã ããããã°ãã¢ãã©ã€ã¶ãŒã¯èªãããããã°ã©ã ã®ä¿¡é Œæ§ãé«ãŸããŸãã
åè ã«å¯ŸåŠããæãæ¥ãŸããïŒæ±ºåæŠã«ç§»ããŸãïŒ
3äœ
åºå žïŒ NCBI Genome WorkbenchïŒçµ¶æ» å±Researchç 究
3人ã®åè³è ã¯ãNCBI Genome Workbenchãããžã§ã¯ãã®ã³ãŒãïŒéºäŒããŒã¿ã®ç 究ãšåæã®ããã®ããŒã«ã»ããïŒã«ãã£ãŠéãããŸãã ããã§ééããèŠã€ããããã«éºäŒåçµã¿æãã¹ãŒããŒãã³ã§ããå¿ èŠã¯ãããŸããããããªãã®æ°ããã®å¯èœæ§ãèªèããŠããŸãã
/** * Crypt a given password using schema required for NTLMv1 authentication * @param passwd clear text domain password * @param challenge challenge data given by server * @param flags NTLM flags from server side * @param answer buffer where to store crypted password */ void tds_answer_challenge(....) { .... if (ntlm_v == 1) { .... /* with security is best be pedantic */ memset(hash, 0, sizeof(hash)); memset(passwd_buf, 0, sizeof(passwd_buf)); ... } else { .... } }
PVS-Studioã®èŠåïŒ
- V597ã³ã³ãã€ã©ãŒã¯ããããã·ã¥ããããã¡ãŒããã©ãã·ã¥ããããã«äœ¿çšããããmemsetãé¢æ°åŒã³åºããåé€ã§ããŸããã ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿ èŠããããŸãã challenge.c 365
- V597ã³ã³ãã€ã©ã¯ããpasswd_bufããããã¡ãŒã®ãã©ãã·ã¥ã«äœ¿çšããããmemsetãé¢æ°åŒã³åºããåé€ã§ããŸããã ãã©ã€ããŒãããŒã¿ãæ¶å»ããã«ã¯ãmemset_sïŒïŒé¢æ°ã䜿çšããå¿ èŠããããŸãã challenge.c 366
ãªããšãééããèŠã€ããŸãããïŒ ãããããªããããªãã¯-ãããã£ãïŒ..ãŸãããŸãã¯ãŸã éºäŒåçµã¿æãã¹ãŒããŒãã³ã
å®éãçŸä»£ã®æé©åã³ã³ãã€ã©ã¯ãã¢ã»ã³ãã«ãããããã°ã©ã ãããé«éã«åäœãããããã«å€ãã®ããšãè¡ãããšãã§ããŸãã ç¹ã«ãã³ã³ãã€ã©ã¯ã memsetã«æž¡ããããããã¡ãä»ã®ã©ãã§ã䜿çšãããŠããªãããšã远跡ã§ããŸãã
ãã®å Žåããäžå¿ èŠãªã memsetåŒã³åºããåé€ããåé€ãããã¹ãŠã®æš©å©ãåŸãããšãã§ããŸãã 次ã«ãéèŠãªããŒã¿ãä¿åãããããã¡ãã¡ã¢ãªã«æ®ããŠãæ»æè ãåã°ããŸãã
ãã®ãããªèæ¯ã«å¯ŸããŠãæåŠç解説ãå®å šæ§ã身ã«ä»ããŠãã€ãŸããªããã¯ããã«é¢çœãèŠããŸãã ãã®ãããžã§ã¯ãã®ããã«çºè¡ãããèŠåã®æ°ãéåžžã«å°ãªãããšããå€æãããšãéçºè ã¯æ³šæãæã£ãŠå®å šãªã³ãŒããæžãããã«éåžžã«æžåœã«åªåããŸããã ãã ããã芧ã®ãšããããã®ã»ãã¥ãªãã£ã®æ¬ é¥ãã¹ãããããããšã¯éåžžã«ç°¡åã§ãã Common Weakness Enumerationã«ãããšãæ¬ é¥ã¯CWE-14ã«åé¡ãããŸãïŒãããã¡ãã¯ãªã¢ããã³ãŒãã®ã³ã³ãã€ã©åé€ã
ã¡ã¢ãªãå®å šã«ã¯ãªã¢ããã«ã¯ã memset_sïŒïŒé¢æ°ã䜿çšããŸãã memsetïŒïŒãããå®å šã§ããã ãã§ãªããã³ã³ãã€ã©ã«ãã£ãŠãç¡èŠãããããšãã§ããŸããã
2äœ
åºå žïŒ PVS-Studioãã©ã®ããã«3人åã®ããã°ã©ããŒããã泚æãæã£ãã®ã
ãã®ãããã®éã¡ããªã¹ããã客æ§ããéãããŠããŸããã 圌ã¯ãã¢ãã©ã€ã¶ãŒã誀ã£ãèŠåãçºããããšã確信ããŠããŸããã
ãŠãŒãžãŒã³ã¯æçŽãåãåããç°¡åã«ã¹ãã£ã³ããŠã¹ãŽã£ã¢ãã¹ã©ãã«éã£ãã Svyatoslavã¯ãã¯ã©ã€ã¢ã³ãããéä¿¡ãããã³ãŒãã®äžéšãææ ®æ·±ãèŠãŠããã¢ãã©ã€ã¶ãŒã¯ãããããŸã«ééã£ãŠããã®ã§ã¯ãªããããšèããŸããã ãããã£ãŠã圌ã¯ã¢ã³ãã¬ã€ãšçžè«ã«è¡ããŸããã 圌ã¯ãŸãããµã€ãããã§ãã¯ããŠæ±ºå®ããŸãããå®éãã¢ãã©ã€ã¶ãŒã¯åœéœæ§ãåºããŸãã
ããªãã¯äœãããããšãã§ããŸããããªãã¯ãããä¿®æ£ããå¿ èŠããããŸãã ãããŠãSvyatoslavãã¿ã¹ã¯ããã°ãã©ãã«ãŒãšããŠåœ¢åŒåããããã®åæäŸãäœæãå§ãããšãã®ã¿ã圌ã¯äœãèµ·ãã£ãŠããã®ããç解ããŸããã
å®éãã³ãŒãã«ã¯ãšã©ãŒãååšããŠããŸããããããã°ã©ããŒããšã©ãŒãæ€åºããããšã¯ã§ããŸããã§ããã æ£çŽãªãšããããã®èšäºã®èè ãæåããŸããã§ããã
ãããŠããã¯ãåæè£ çœ®ãééã£ãå Žæã«å¯ŸããŠæ確ã«èŠåãçºãããšããäºå®ã«ããããããã§ãïŒ
ãã®ãããªcraftãªééããèŠã€ããããšãã§ããŸããïŒ èŠæãšæ³šæåã確èªããŠãã ããã
PVS-StudioèŠåïŒ
- V560æ¡ä»¶åŒã®äžéšã¯åžžã«åœã§ãïŒïŒch> = 0x0FF21ïŒã decodew.cpp 525
- V560æ¡ä»¶åŒã®äžéšã¯åžžã«çã§ãïŒïŒch <= 0x0FF3AïŒã decodew.cpp 525
- V560æ¡ä»¶åŒã®äžéšã¯åžžã«åœã§ãïŒïŒch> = 0x0FF41ïŒã decodew.cpp 525
- V560æ¡ä»¶åŒã®äžéšã¯åžžã«çã§ãïŒïŒch <= 0x0FF5AïŒã decodew.cpp 525
ããªããæåããå Žå-ããªãã¯ç§ã®æ¬æãä¿æããŸããïŒ
ãšã©ãŒã¯ãè«çåŠå®æŒç®åïŒïŒïŒãæ¡ä»¶å šäœã«é©çšãããããã®æåã®éšååŒã«ã®ã¿é©çšããããšããäºå®ã«ãããŸãã
!((ch >= 0x0FF10) && (ch <= 0x0FF19))
ãã®æ¡ä»¶ãæºããããå Žåãå€æ°chã®å€ã¯éé[0x0FF10 ... 0x0FF19]ã«ãããŸãã ãããã£ãŠãããã«4ã€ã®æ¯èŒã¯æå³ããããŸãããåžžã«çãŸãã¯åœã®ããããã«ãªããŸãã
ãã®ãããªãšã©ãŒãåé¿ããã«ã¯ãããã€ãã®ã«ãŒã«ã«åŸã䟡å€ããããŸãã ãŸããã³ãŒããããŒãã«ã«åãããã®ã¯éåžžã«äŸ¿å©ã§æ確ã§ãã 第äºã«ãæ¬åŒ§ã§åŒããªãŒããŒããŒãããªãã§ãã ããã ããšãã°ããã®ã³ãŒãã¯æ¬¡ã®ããã«æžãæããããšãã§ããŸãã
const bool isLetterOrDigit = (ch >= 0x0FF10 && ch <= 0x0FF19) // 0..9 || (ch >= 0x0FF21 && ch <= 0x0FF3A) // A..Z || (ch >= 0x0FF41 && ch <= 0x0FF5A); // a..z if (!isLetterOrDigit)
ããããã第äžã«ããã©ã±ããã®æ°ãã¯ããã«å°ãªããªãã第äºã«ãç®ãç¯ããééããããã£ããããã確çãé«ããªããŸãã
ãããŠä»-ãã§ãªãŒïŒæåã®å Žæã«ç§»åããŸãïŒ
äžäœ
åºå žïŒ ã·ã§ãã¯ç¶æ ã®ã·ã¹ãã ïŒäŒèª¬çãªã·ã¹ãã ã·ã§ãã¯ã®ãœãŒã¹ã³ãŒãã®èå³æ·±ããšã©ãŒ
ãããã£ãŠãä»æ¥ã®ãããã®ãã¡ã€ããªã¹ãã¯ãäŒèª¬çãªã·ã¹ãã ã·ã§ãã¯ã®ééãã§ãïŒ 1994幎ã«ãªãªãŒã¹ããããã®ã²ãŒã ã¯ãDead SpaceãBioShockãDeus Exãªã©ã®è±¡åŸŽçãªã²ãŒã ã®å é§è ã§ãããåºæ¿ãåããŸããã
ããããæåã«ãç§ã¯äœããèªããªããã°ãªããŸããã ãããã説æããå 容ã«ã¯ããšã©ãŒã¯å«ãŸããŠããŸããã æŠããŠãããã¯ã³ãŒãã®äžéšã§ãããããŸããããç§ã¯ãããããªããšå ±æããªãããšãæã¿ãŸããã§ããïŒ
å®éãã²ãŒã ã®ãœãŒã¹ã³ãŒããåæããéçšã§ãååã®ãã¯ããªã¢ã¯å€ãã®èå³æ·±ãã³ã¡ã³ããèŠã€ããŸããã ãã¡ãã¡ã§ãçªç¶ãéã³å¿ãšç®èãªçºèšãããã«ã¯è©©ããããŸããïŒ
// I'll give you fish, I'll give you candy, // I'll give you, everything I have in my hand // that kid from the wrong side came over my house again, // decapitated all my dolls // and if you bore me, you lose your soul to me // - "Gepetto", Belly, _Star_ // And here, ladies and gentlemen, // is a celebration of C and C++ and their untamed passion... // ================== TerrainData terrain_info; // Now the actual stuff... // ======================= // this is all outrageously horrible, as we dont know what // we really need to deal with here // And if you thought the hack for papers was bad, // wait until you see the one for datas... - X // Returns whether or not in the humble opinion of the // sound system, the sample should be politely obliterated // out of existence // it's a wonderful world, with a lot of strange men // who are standing around, and they all wearing towels
ãã·ã¢èªã話ãèªè ã®ããã«ãããããã®ç¡æ翻蚳ãäœæããŸããã
// , , // , // // // // , // - "Gepetto", Belly, _Star_ // , , // C C++ // ================== TerrainData terrain_info; // ... // ======================= // , , // // , // , ... - X // , // // , // ,
ãããã®ã³ã¡ã³ãã¯ã90幎代ååã«ã²ãŒã ã®éçºè ã«ãã£ãŠæ®ãããŸãã...ãšããã§ãã·ã¹ãã ã·ã§ãã¯ã®ããŒããã¶ã€ããŒã§ãããã°ãã£ãŒããã³ãŒããæžããŠããŸããã ãããã®ã³ã¡ã³ãã®ããããã圌ã«ãã£ãŠå人çã«æžãããã®ãããããŸããã ã¿ãªã«ãçãç·æ§ã«ã€ããŠ-ããã¯åœŒã®äœåã§ã¯ãªãããšãé¡ã£ãŠããŸã:)
ãããã«
çµè«ãšããŠãæ°ãããšã©ãŒãæ¢ãããããã«ã€ããŠã®èšäºãæžããŠãããååã«æè¬ããããšæããŸããã¿ããªããããšãïŒããªããããªããã°ããã®èšäºã¯ããã»ã©é¢çœããªãã£ãã§ãããã
ãŸããç§ãã¡ã®æ¥çžŸã«ã€ããŠãå°ãã話ããããšæããŸãããªããªãã1幎éãç§ãã¡ã¯åãªããã¹ãæ¢ã以äžã®ããšã«åãçµãã§ããããã§ãããŸããã¢ãã©ã€ã¶ãŒãéçºããã³æ¹åãããã®çµæãå€§å¹ ãªå€æŽãè¡ãããŸããã
ããšãã°ãããã€ãã®æ°ããã³ã³ãã€ã©ã®ãµããŒããè¿œå ãã蚺æã«ãŒã«ã®ãªã¹ããæ¡åŒµããŸããããŸããMISRA Cããã³MISRA C ++æšæºã®åæãµããŒããæäŸããŸãããæãéèŠã§æéã®ãããã€ãããŒã·ã§ã³ã¯ãæ°ããèšèªã®ãµããŒãã§ãããã¯ããJavaã³ãŒããåæã§ããããã«ãªããŸããïŒãããŠãã¢ã€ã³ã³ãæŽæ°ããŸãã :)
èªè ã«ãæè¬ããããèšäºãèªãã§æžããŠãããŠããããšãïŒããªãã®ãã£ãŒãããã¯ã¯éåžžã«å¿å°ãããç§ãã¡ã«ãšã£ãŠéèŠã§ãã
ããã«ããã2018幎ã®äžäœ10åã®C ++ãšã©ãŒãçµäºããŸãããäžçªå¥œãã ã£ãå Žæãšãã®çç±ã¯ïŒ2018幎ã«èå³æ·±ãäŸã«åºäŒããŸãããïŒã³ã¡ã³ãã§ãããæããŠãã ããïŒ
次åãŸã§ïŒ
ãã®èšäºãè±èªåã®èŽè¡ãšå ±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒGeorge Gribkovã2018幎ã«èŠã€ãã£ãC ++ãããžã§ã¯ãã®äžäœ10åã®ãã°