Chromiumãããžã§ã¯ãã§èŠã€ãã£ããšã©ãŒã®äŸã«ã€ããŠãé«å質ã®ã³ãŒããäœæããããã®æšå¥šäºé ã«é¢ããäžé£ã®èšäºãã玹ä»ããŸãã ããã¯ãã¡ã¢ãªãªãŒã¯å°çšã®3çªç®ã®éšåã§ãã
Chromiumãããžã§ã¯ãã³ãŒããšããã«äœ¿çšãããã©ã€ãã©ãªã¯éåžžã«é«å質ã§ãããšæããŸãã ã¯ããå ¥éèšäºã§çŽ250ã®ãšã©ãŒãæžããŸããããå®éã«ã¯-ããã¯éåžžã«å°ãªãæ°ã§ãã 確çã®æ³åã«ããã巚倧ãªãããžã§ã¯ãã§ã¯å€ãã®ééãããããŸãã
ããã«ãããããããã¡ã¢ãªãªãŒã¯ã«ã€ããŠè©±ããããšãããã»ã©å€ãã¯ãããŸããã Chromiumã®éçºè ã¯ãåçã³ãŒãã¢ãã©ã€ã¶ãŒã奜ãããšã倱æãããŠãããšæããŸãã ãã¡ããããããã®ããŒã«ã«ã¯å€ãã®å©ç¹ããããŸãã ããšãã°ããã€ãããã¯ã¢ãã©ã€ã¶ãŒããšã©ãŒãæ€åºãããšå®éã«ãšã©ãŒãçºçããããã誀æ€ç¥ã¯çºçããŸããã
äžæ¹ãåçåæã«ã¯åŒ±ç¹ããããŸãã äžéšã®ã³ãŒããå®è¡ãããªãå Žåããšã©ãŒã¯æ€åºãããŸããã ãããŠãããã°ã©ããŒã¯ãã³ãŒãã®100ïŒ ããã¹ãã§ã«ããŒããããšã¯éåžžã«é£ããããšãç解ããŠããŸããå®éã«ã¯ãããã¯åã«äžå¯èœã§ãã ãã®çµæãå€ãã®ãšã©ãŒãã³ãŒãå ã«æ®ããããèªäœã蚌æããããã®å¥œãŸããäžé£ã®ç¶æ³ãåŸ ã¡ãŸãã
ããã§ãéçã³ãŒãã¢ãã©ã€ã¶ãŒã圹ç«ã¡ãŸãã ã¯ããããã¯Googleã®éçºè ã«ãšã£ãŠã顧客ã«ãªãã°å¹žãã«ãªããšãããã³ãã§ãã ããã«ãChromiumãããžã§ã¯ãã®æ©èœã«åãããŠPVS-Studioãé©å¿ããã³æ§æããè¿œå äœæ¥ã®æºåãã§ããŠããŸãã ãŸããçºèŠãããšã©ãŒãä¿®æ£ããæºåãã§ããŠããŸãã ãã§ã«åæ§ã®çµéšããããŸãïŒ äŸ ïŒã
ããããã¡ã¢ãªãªãŒã¯ã«æ»ããŸãã åŸã§ãããããã«ãã»ãšãã©å¶åŸ¡ãããªãã³ãŒãã§é衚瀺ã«ãªããŸãã ãããã¯äž»ã«ããŸããŸãªãšã©ãŒãã³ãã©ã§ãã éçã¢ãã©ã€ã¶ãŒã¯ãåçã¢ãã©ã€ã¶ãŒãšã¯ç°ãªããå²ãåœãŠãããã¡ã¢ãªãžã®ããã€ã³ã¿ã®éåœããåžžã«è¿œè·¡ã§ããããã§ã¯ãªããå€ãã®ã¡ã¢ãªãªãŒã¯ãæ€åºããŸããã äžæ¹ãéçã¢ãã©ã€ã¶ãŒã¯ãå®è¡ã®å¯èœæ§ã«é¢ä¿ãªãããã¹ãŠã®ã³ãŒãããã§ãã¯ãããšã©ãŒãéç¥ããŸãã ãããã£ãŠãéçã¢ãã©ã€ã¶ãŒãšåçã¢ãã©ã€ã¶ãŒã¯äºãã«è£å®ããŸãã
PVS-Studioãçºè¡ããã¬ããŒãã®è§£æäžã«æ°ä»ããã¡ã¢ãªãªãŒã¯ãèŠãŠã¿ãŸãããã å ¥éèšäºã§æžããããã«ãã¬ããŒããéåžžã«æµfluentã«èŠãã®ã§ãæ°ã¥ããŠããªãä»ã®ãšã©ãŒããããããããŸããã ãŸããã¡ã¢ãªãªãŒã¯ã¯Chromiumã®ãããªãããžã§ã¯ãã«ãšã£ãŠéåžžã«äžå¿«ã§ããããããããã«ã€ããŠè©±ãã®ã¯èå³æ·±ãããšã§ãã CWEã«ãããšããããã®ãšã©ãŒã¯CWE-401ãšããŠåé¡ã§ããŸãã
ããŒã1ïŒé¢æ°ãçµäºããåã«ã¡ã¢ãªã解æŸããã®ãå¿ãã
Chromiumã³ãŒãã®ãšã©ãŒãèæ ®ããŠãã ããã ãŸããç¡å¹åãããã¡ã¢ãªãããã¡ãå²ãåœãŠãŠè¿ãBnNewãã«ããŒé¢æ°ã瀺ããŸãã
uint32_t* BnNew() { uint32_t* result = new uint32_t[kBigIntSize]; memset(result, 0, kBigIntSize * sizeof(uint32_t)); return result; }
次ã«ãã¡ã¢ãªãªãŒã¯ãåŒãèµ·ããå¯èœæ§ã®ããã³ãŒããèŠãŠã¿ãŸãããã
std::string AndroidRSAPublicKey(crypto::RSAPrivateKey* key) { .... uint32_t* n = BnNew(); .... RSAPublicKey pkey; pkey.len = kRSANumWords; pkey.exponent = 65537; // Fixed public exponent pkey.n0inv = 0 - ModInverse(n0, 0x100000000LL); if (pkey.n0inv == 0) return kDummyRSAPublicKey; .... }
æ¡ä»¶ïŒpkey.n0inv == 0ïŒãæºãããããšãé¢æ°ã¯ãããã¡ãŒã解æŸããã«çµäºããŸãããããã¡ãŒãžã®ãã€ã³ã¿ãŒã¯å€æ°nã«æ ŒçŽãããŸãã
ã¢ãã©ã€ã¶ãŒã¯ã次ã®èŠåãçºè¡ããŠãã®æ¬ é¥ã瀺ããŸããV773 CWE-401ãnããã€ã³ã¿ãŒã解æŸããã«æ©èœãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã android_rsa.cc 248
ãšããã§ãããã¯ç¹ã«Chromiumèªäœã«é¢é£ããã¡ã¢ãªãªãŒã¯ãçµäºããå Žæã§ãã ãããã䜿çšãããã©ã€ãã©ãªã«ã¯ãããã®å€ãããããŸãã ãŸãããŠãŒã¶ãŒã¯ãã¡ã¢ãªãChromiumã©ã€ãã©ãªãŸãã¯Chromiumèªäœã®ã©ã¡ãã«æµããããæ°ã«ããŸããã ãããã£ãŠãã©ã€ãã©ãªã®ãšã©ãŒãéèŠã§ãã
次ã®ãšã©ãŒã¯ãWebKitãšã³ãžã³ã«é¢é£ããŠããŸãã è£å©æ©èœããå床éå§ããå¿ èŠããããŸãã
static CSSValueList* CreateSpaceSeparated() { return new CSSValueList(kSpaceSeparator); }
ãšã©ãŒãå«ãã³ãŒãïŒ
const CSSValue* CSSTransformValue::ToCSSValue(....) const { CSSValueList* transform_css_value = CSSValueList::CreateSpaceSeparated(); for (size_t i = 0; i < transform_components_.size(); i++) { const CSSValue* component = transform_components_[i]->ToCSSValue(secure_context_mode); if (!component) return nullptr; // <= transform_css_value->Append(*component); } return transform_css_value; }
ã³ã³ããŒãã³ããã€ã³ã¿ãŒãnullã§ããããšãå€æããå Žåãé¢æ°ã¯çµäºããã¡ã¢ãªãªãŒã¯ãçºçããŸãã
PVS-Studioã¢ãã©ã€ã¶ãŒã¯èŠåãçæããŸãïŒV773 CWE-401 'transform_css_value'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã csstransformvalue.cpp 73
WebKitã«é¢é£ããä»ã®ãšã©ãŒãèŠãŠã¿ãŸãããã
Request* Request::CreateRequestWithRequestOrString(....) { .... BodyStreamBuffer* temporary_body = ....; .... temporary_body = new BodyStreamBuffer(script_state, std::move(init.GetBody())); .... if (exception_state.HadException()) return nullptr; .... }
HadExceptionïŒïŒé¢æ°ãtrueãè¿ãå Žåãé¢æ°ã¯ã¹ã±ãžã¥ãŒã«ãããæ©ãäœæ¥ãå®äºããŸãã ãã®å Žåã temporary_bodyå€æ°ã«æ ŒçŽãããŠãããã€ã³ã¿ãŒã«å¯ŸããŠdeleteãªãã¬ãŒã¿ãŒãåŒã³åºãããšã¯ãããŸããã
PVS-StudioèŠåïŒV773 CWE-401 'temporary_body'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã request.cpp 381
WebKitã§æ°ä»ããæ®ãã®ãšã©ãŒã¯èª¬æãããã®ãšå€ãããªãã®ã§ãèšäºã§ããããæ€èšããçç±ã¯ãªããã¢ãã©ã€ã¶ãŒã¡ãã»ãŒãžã®ãªã¹ãã ãã«éå®ããŸãã
- V773 CWE-401 'image_set'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã csspropertyparserhelpers.cpp 1507
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã csspropertyparserhelpers.cpp 1619
- V773 CWE-401ã圢ç¶ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 248
- V773 CWE-401ã圢ç¶ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 272
- V773 CWE-401ã圢ç¶ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 289
- V773 CWE-401ã圢ç¶ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 315
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 1359
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 1406
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 1359
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 1406
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 1985
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 2474
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cssparsingutils.cpp 2494
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã atruledescriptorparser.cpp 30
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã atruledescriptorparser.cpp 57
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã atruledescriptorparser.cpp 128
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã csssyntaxdescriptor.cpp 193
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 1232
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 1678
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 1727
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 2036
- V773 CWE-401 'size_and_line_height'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 2070
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã computestylecssvaluemapping.cpp 2070
- V773 CWE-401 'file_list'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã v8scriptvaluedeserializer.cpp 249
- V773 CWE-401 'file_list'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã v8scriptvaluedeserializer.cpp 264
- V773 CWE-401 'computed_style_info'ãã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã inspectordomsnapshotagent.cpp 367
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã cursor.cpp 42
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã content.cpp 103
- V773 CWE-401ãvariation_settingsããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã fontvariationsettings.cpp 56
- V773 CWE-401ãfont_variation_valueããã€ã³ã¿ãŒã®å¯èŠæ§ã¹ã³ãŒãã¯ãã¡ã¢ãªãŒã解æŸããã«çµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã fontvariationsettings.cpp 58
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã rotate.cpp 32
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã quotes.cpp 25
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã textindent.cpp 52
- V773 CWE-401ããªã¹ãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã shapeoutside.cpp 35
- V773 CWE-401ãport_arrayããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã v8messageeventcustom.cpp 127
ããããïŒ ããããã åæã«ãç§ãåãæã£ãŠããã¡ãã»ãŒãžã ããããã«æžãåºãããŸããã ç§ã¯ããã«éå±ãããã®ãããªèŠåãéåžžã«è¡šé¢çã«èŠãŸããã ã»ãšãã©ã®å Žåãã¬ããŒããããæ éã«åæãããšãWebKitã§ããå€ãã®ãšã©ãŒãæ€åºãããŸãã
ããã¯ã©ãããæå³ã§ããïŒ ããã¯ãWebKitãããžã§ã¯ãã«ã¡ã¢ãªãªãŒã¯ã®åé¡ãããããšãæå³ãããã®ãããžã§ã¯ããç¥çŠããŸãã
ããã§ã¯ãICUãããžã§ã¯ãã«ç§»ããããã§èŠã€ãã£ããšã©ãŒãèŠãŠã¿ãŸãããã
UVector* RuleBasedTimeZone::copyRules(UVector* source) { if (source == NULL) { return NULL; } UErrorCode ec = U_ZERO_ERROR; int32_t size = source->size(); UVector *rules = new UVector(size, ec); if (U_FAILURE(ec)) { return NULL; } .... }
ã¿ã€ãUVectorã®ãªããžã§ã¯ãã®åæåäžã«ç¹å®ã®ãšã©ãŒãçºçããå Žåãããã¯ecå€æ°ã«èšå®ãããã¹ããŒã¿ã¹ã«åœ±é¿ããŸãã ããšãã°ãå¿ èŠãªæ°ã®èŠçŽ ãæ ŒçŽããããã®ã¡ã¢ãªãããã¡ãå²ãåœãŠãããšãã§ããªãå Žåãã³ã³ã¹ãã©ã¯ã¿ã¯ã¹ããŒã¿ã¹U_MEMORY_ALLOCATION_ERRORãè¿ããŸãã ãã ããèŠçŽ ãæ ŒçŽããããã®ã¡ã¢ãªãå²ãåœãŠãããšãã§ãããã©ããã«é¢ä¿ãªãã UVectoråã®ãªããžã§ã¯ããäœæããããã®ãªããžã§ã¯ããžã®ãã€ã³ã¿ãŒãã«ãŒã«å€æ°ã«é 眮ãããŸãã
ã³ã³ã¹ãã©ã¯ã¿ãŒãã¹ããŒã¿ã¹U_MEMORY_ALLOCATION_ERRORãè¿ããå Žåãé¢æ°ã¯çµäºããŸãã åæã«ã UVectoråã®ãªããžã§ã¯ãã¯åé€ããããã¡ã¢ãªãªãŒã¯ãçºçããŸãã
PVS-StudioèŠåïŒV773 CWE-401ãã«ãŒã«ããã€ã³ã¿ãŒã解æŸããã«æ©èœãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã rbtz.cpp 668
ICUã©ã€ãã©ãªãŒã®ä»ã®ãšã©ãŒãåãªããªã¹ãã«ãªããŸãã
- V773 CWE-401ãtmpSetããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã uspoof_impl.cpp 184
- V773 CWE-401ãçµæããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã stsearch.cpp 301
- V773 CWE-401ãå€ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã tznames_impl.cpp 154
- V773 CWE-401ããã£ã«ã¿ãŒããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã tridpars.cpp 298
- V773 CWE-401ãã¿ãŒã²ããããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã transreg.cpp 984
- V773 CWE-401ãã€ã³ã¹ã¿ã³ã¹ããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã tzgnames.cpp 1216
- V773 CWE-401ãuseããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã rbbiscan.cpp 1276
ä»ã«äœã«æ°ä»ããŸãããïŒ
Libwebmã©ã€ãã©ãªã
- V773 CWE-401ãnew_frameããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã mkvmuxer.cc 3513
- V773 CWE-401ãnew_frameããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã mkvmuxer.cc 3539
SwiftShaderã©ã€ãã©ãªã
- V773 CWE-401ãããŒãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã Intermediate.cpp 405
- V773 CWE-401ãããŒãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã Intermediate.cpp 443
- V773 CWE-401ãããŒãããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã Intermediate.cpp 514
- V773 CWE-401ãrightUnionArrayããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã Intermediate.cpp 1457
- V773 CWE-401ãunionArrayããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã Intermediate.cpp 1457
- V773 CWE-401ãaggregateArgumentsããã€ã³ã¿ãŒã解æŸããã«é¢æ°ãçµäºããŸããã ã¡ã¢ãªãªãŒã¯ãçºçããå¯èœæ§ããããŸãã parsehelper.cpp 2109
ããããããããã¯ãã¹ãŠã®ãšã©ãŒãšã¯ã»ã©é ãã§ãããPVS-Studioã®æ©èœãå®èšŒããŠãã®èšäºãæžãã«ã¯ååã§ãã
ããŒã1ïŒæšå¥šäºé
äžèšã®ãã¹ãŠã®ã±ãŒã¹ãçµ±åãããã®ã¯äœã§ããïŒ ãã®ãšã©ãŒã¯ãæåã®ã¡ã¢ãªç®¡çã«ããå¯èœã«ãªããŸããïŒ
å人ãã¡ããã§ã«C ++ 17ã䜿çšããŠããŸãã newæŒç®åã®åŒã³åºããåæ¢ããçµæãéåžžã®ãã€ã³ã¿ãŒã«å ¥ããŠããã解æŸããã®ãå¿ããŸãã æ¥ããããã
å²ãåœãŠããããªãœãŒã¹ã®éåžžã®ãã€ã³ã¿ãŒãšããã«ç¶ãæåå¶åŸ¡ã¯ããå¿ èŠãããŸããïŒ åžžã«ã¹ããŒããã€ã³ã¿ãŒã䜿çšããŸãããã
ææ°ã®C ++æšæºã¯ã unique_ptr ã shared_ptrã weak_ptrãªã©ã®ã¹ããŒããã€ã³ã¿ãŒãæäŸããŸãã ã»ãšãã©ã®å Žåã unique_ptrã¯1ã€ã§ååã§ãã
ããšãã°ã次ã®èª€ã£ãã³ãŒãã«æ»ããŸãããã
const CSSValue* CSSTransformValue::ToCSSValue(....) const { CSSValueList* transform_css_value = CSSValueList::CreateSpaceSeparated(); for (size_t i = 0; i < transform_components_.size(); i++) { const CSSValue* component = transform_components_[i]->ToCSSValue(secure_context_mode); if (!component) return nullptr; transform_css_value->Append(*component); } return transform_css_value; }
unique_ptrã䜿çšããŠæžãæããŸãããã ãããè¡ãã«ã¯ããŸãããã€ã³ã¿ãŒèªäœã®ã¿ã€ããå€æŽããå¿ èŠããããŸãã 第äºã«ãæåŸã«ã ãªãªãŒã¹ãããé¢æ°ãåŒã³åºããŠã管ç察象ãªããžã§ã¯ããžã®ãã€ã³ã¿ãŒãè¿ãããããå¶åŸ¡ããå¿ èŠããªããªããŸãã
æ£ããã³ãŒãã¯æ¬¡ã®ãšããã§ãã
const CSSValue* CSSTransformValue::ToCSSValue(....) const { unique_ptr<CSSValueList> transform_css_value( CSSValueList::CreateSpaceSeparated()); for (size_t i = 0; i < transform_components_.size(); i++) { const CSSValue* component = transform_components_[i]->ToCSSValue(secure_context_mode); if (!component) return nullptr; transform_css_value->Append(*component); } return transform_css_value.release(); }
ãã®èšäºã§ã¯ãã¹ããŒããã€ã³ã¿ãŒã®äœ¿çšæ¹æ³ãæããã€ããã¯ãããŸããã ãã®ãããã¯ã¯ãæžç±ã®å€ãã®åªããèšäºãšã»ã¯ã·ã§ã³ã«åœãŠãããŠããŸãã å€æŽã«ãã£ãŠã³ãŒããããè€éã§é¢åã«ãªããªãããšã瀺ãããã£ãã ãã§ãã ããããä»ã§ã¯ééããç¯ãã®ãã¯ããã«å°é£ã«ãªããŸãã
new / deleteãŸãã¯malloc / freeã«å¯ŸåŠããŠééããããªãã®ã¯ããªãã ãšã¯æããªãã§ãã ããã Chromiuméçºè ã¯ãã®ãããªééããç¯ããŸãã ä»ã®éçºè ã¯ããããŸã ã ããªãã¯ãã®ãããªééããç¯ããŸãã ãããŠãããªãã®ããŒã ãç¹å¥ã§ãããšããäžå¿ èŠãªå€¢ãæã£ãŠã¯ãããŸãã:)ã ãã®æ©äŒã«ããããŒãžã£ãŒã«ãã®ã¡ã¢ãä»ããèªãã§ããããŸã ã
ã¹ããŒããã€ã³ã¿ãŒã䜿çšããŸãã
ããŒã2ïŒrealloc
ç§ã®çµéšã§ã¯ãããã°ã©ããŒã¯reallocé¢æ°ã誀çšããããšããããŸãã ãã®é¢æ°ã®äœ¿çšã«é¢é£ããå€å žçãªãšã©ãŒãã¿ãŒã³ã¯æ¬¡ã®ããã«ãªããŸãã
p = realloc(p, n); if (!p) return ERROR;
é¢æ°ã®æ¬¡ã®ããããã£ã«æ³šæããŠãã ãããååãªã¡ã¢ãªããªãå Žåãå€ãã¡ã¢ãªãããã¯ã¯è§£æŸããããnullãã€ã³ã¿ãè¿ãããŸãã
NULLã¯ãããã¡ãžã®ãã€ã³ã¿ãæ ŒçŽããå€æ°pã«æžã蟌ãŸããããããã®ãããã¡ã解æŸããæ©èœã¯å€±ãããŸãã ã¡ã¢ãªãªãŒã¯ããããŸãã
æ£ãããªãã·ã§ã³ã¯ãããšãã°æ¬¡ã®ããã«ã³ãŒããæžãæããããšã§ãã
void *old_p = p; p = realloc(p, n); if (!p) { free(old_p); return ERROR; }
Chromiumãããžã§ã¯ãã§äœ¿çšãããã©ã€ãã©ãªã«ãã®ãããªãšã©ãŒããªãããã§ã¯ãããŸããã
ããšãã°ãFLACã³ãŒããã¯ã®ã³ãŒããèããŠã¿ãŸãããã
FLAC__bool FLAC__format_entropy_codi.....ce_contents_ensure_size( FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order) { .... if(object->capacity_by_order < max_partition_order) { if(0 == (object->parameters = realloc(object->parameters, ....))) return false; if(0 == (object->raw_bits = realloc(object->raw_bits, ....))) return false; .... }
ãã®é¢æ°ã¯ã2ã€ã®ãããã¡ãŒã®ãµã€ãºãå¢ãããŸãã
- ãªããžã§ã¯ã->ãã©ã¡ãŒã¿ãŒ
- ãªããžã§ã¯ã-> raw_bits
ã¡ã¢ãªå²ãåœãŠãšã©ãŒãçºçããå Žåãé¢æ°ã¯ã¹ã±ãžã¥ãŒã«ããæ©ãçµäºãã falseãè¿ããŸã ã ãã®å Žåããã€ã³ã¿ã®ä»¥åã®å€ã倱ãããã¡ã¢ãªãªãŒã¯ãçºçããŸãã
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãããã§2ã€ã®é¢é£ããèŠåãçæããŸãã
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãŒ 'object-> parameters'ã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã format.c 576
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ 'object-> raw_bits'ã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã format.c 578
WebRTCãããžã§ã¯ãã®åæ§ã®æ¬ é¥ã
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãself-> binary_far_historyãã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã delay_estimator.cc 303
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãself-> far_bit_countsãã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã delay_estimator.cc 306
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãself-> mean_bit_countsãã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã delay_estimator.cc 453
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãself-> bit_countsãã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã delay_estimator.cc 456
- V701 CWE-401 reallocïŒïŒãªãŒã¯ã®å¯èœæ§ïŒreallocïŒïŒãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšãå ã®ãã€ã³ã¿ãself-> histogramãã倱ãããŸãã reallocïŒïŒãäžæãã€ã³ã¿ãŒã«å²ãåœãŠãããšãæ€èšããŠãã ããã delay_estimator.cc 458
幞ããChromiumã«ã¯ãã®ã¿ã€ãã®ãšã©ãŒã¯ã»ãšãã©ãããŸããã å°ãªããšããä»ã®ãããžã§ã¯ãã§éåžžèŠããããã®ãããã¯ããã«å°ãªãã§ãã
ããŒã2ïŒæšå¥šäºé
ãããã¡ãµã€ãºãé »ç¹ã«å€æŽããå¿ èŠããããšãã«å¹ççãªã³ãŒããèšè¿°ã§ããããã reallocé¢æ°ãåžžã«æåŠã§ãããšã¯éããŸããã
ãããã£ãŠãç§ã¯ãããå®å šã«æŸæ£ããããšãæ¥ãã§å§ããŸããã æã«ã¯ããã¯äžåœã«ãªããŸãã ãã®é¢æ°ã«ã¯æ³šæããŠãäžèšã®ãšã©ãŒãã¿ãŒã³ãå¿ããªãããã«ããŠãã ããã
ãã ããå€ãã®å ŽåãC ++ã§ã¯ããã®é¢æ°ãå®å šã«çãã std :: vectorãstd :: stringãªã©ã®ã³ã³ããã䜿çšã§ããŸã ã ã³ã³ããã®å¹çã¯è¿å¹Žå€§å¹ ã«åäžããŠããŸãã ããšãã°ãPVS-Studioã³ã¢ã§ã¯ãèªäœã®æååã¯ã©ã¹ãšstd :: stringã®éã«ããã©ãŒãã³ã¹ã®éãããªããªã£ãããšãããããé©ããŸããã ããããäœå¹Žãåãèªäœã®æååã¯ã©ã¹ã«ãããã¢ãã©ã€ã¶ã®ããã©ãŒãã³ã¹ãçŽ10ïŒ åäžããŸããã ãã®ãããªå¹æã¯ãã以äžèŠããããç¬èªã®ã¯ã©ã¹ãåé€ããããšãå¯èœã«ãªããŸããã çŸåšã std ::æååã¯ã©ã¹ã¯10幎åãšãŸã£ããç°ãªããŸã ã ææ°ã®ã³ã³ãã€ã©ãŒæé©åæ©èœãšãããšãã°ç§»åã³ã³ã¹ãã©ã¯ã¿ãŒãªã©ã®èšèªã®é©æ°ã®ãããã§ãå¹çãå€§å¹ ã«åäžããŸããã
äžè¬çã«ãæ¥ãã§è¢ããŸããã malloc ã realloc ã freeé¢æ°ã䜿çšããŠã¡ã¢ãªãæåã§ç®¡çããªãã§ãã ããã ã»ãŒç¢ºå®ã«ã std :: vectorã¯ãã¿ã¹ã¯ã«ãšã£ãŠããã»ã©å¹æçã§ã¯ãããŸããã åæã«ã std :: vectorã䜿çšããæ¹ãã¯ããã«ç°¡åã§ãã ééããç¯ãããšãé£ãããªããŸãã ãããã¡ã€ã©ãŒããããå®éã«ããã°ã©ã ã®ããã«ããã¯ã®1ã€ã§ããããšã瀺ããå Žåã«ã®ã¿ãäœã¬ãã«é¢æ°ã«æ»ãããšã¯çã«ããªã£ãŠããŸãã
ãæž èŽããããšãããããŸããã PVS-Studioã¢ãã©ã€ã¶ãŒãããŠã³ããŒãããŠãè©Šããã ããã
ãã®èšäºãè±èªåã®èŽè¡ãšå ±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒAndrey Karpovã ChromiumïŒã¡ã¢ãªãªãŒã¯ ã