å€æ°ã®ãšã©ãŒãã¿ãŒã³ãšæœåšçãªè匱æ§ãå¹æçã«æ€åºã§ããPVS-StudioããŒã«ã§äœ¿çšããããã¯ãããžãŒã®ç°¡åãªèª¬æã ãã®èšäºã§ã¯ãCããã³C ++ã³ãŒãã®ã¢ãã©ã€ã¶ãŒã®å®è£ ã«ã€ããŠèª¬æããŠããŸãããäžèšã®æ å ±ã¯ãCïŒããã³Javaã³ãŒãã®åæãæ åœããã¢ãžã¥ãŒã«ã«ãæå¹ã§ãã
ã¯ããã«
éçã³ãŒãã¢ãã©ã€ã¶ãŒã¯éåžžã«åçŽãªããã°ã©ã ã§ãããæ£èŠè¡šçŸã䜿çšããã³ãŒããã¿ãŒã³ã®æ€çŽ¢ã«åºã¥ããŠãããšãã誀解ããããŸãã ããã¯çå®ãšã¯çšé ãã ããã«ãæ£èŠè¡šçŸã䜿çšããŠãšã©ãŒã®å€§éšåãèå¥ããããšã¯ãåã«äžå¯èœã§ãã
ãã®ãšã©ãŒã¯ã10ã20幎åã«ååšããŠããããã€ãã®ããŒã«ã䜿çšããããã°ã©ããŒã®çµéšã«åºã¥ããŠçºçããŸããã å€ãã®å ŽåãããŒã«ã®äœæ¥ã¯ãã³ãŒããstrcpy ã strcatãªã©ã®é¢æ°ã®å±éºãªãã¿ãŒã³ãèŠã€ããããšã«ãªããŸããã ãã®ã¯ã©ã¹ã®ããŒã«ã®ä»£è¡šãšããŠRATSãšåŒã¶ããšãã§ããŸãã
ãã®ãããªããŒã«ã¯æçšã§ã¯ãããŸãããäžè¬çã«æãã§å¹æããããŸããã å€ãã®ããã°ã©ããŒãããŸã ã«èšæ¶ãæã£ãŠããã®ã¯ãéçã¢ãã©ã€ã¶ãŒãéåžžã«åœ¹ã«ç«ããªãããŒã«ã§ããããããå©ãããããä»äºã«å¹²æžãããšããããšã§ãã
æéãçµã¡ãéçã¢ãã©ã€ã¶ãŒã¯ã綿å¯ãªã³ãŒãåæãå®è¡ãã泚ææ·±ãã³ãŒãã¬ãã¥ãŒã®åŸã§ãã³ãŒãã«æ®ã£ãŠãããšã©ãŒãèŠã€ããè€éãªãœãªã¥ãŒã·ã§ã³ãæ§æãå§ããŸããã æ®å¿µãªãããéå»ã®åŠå®çãªçµéšã«ãããå€ãã®ããã°ã©ããŒã¯éçåæææ³ã圹ã«ç«ããªããšèããŠãããéçºããã»ã¹ã«å°å ¥ããããšãæ¥ãã§ããŸããã
ãã®èšäºã§ã¯ãç¶æ³ãå°ãä¿®æ£ããããšããŸãã èªè ã«ããšã©ãŒãæ€åºããããã«PVS-Studioéçã³ãŒãã¢ãã©ã€ã¶ãŒã§äœ¿çšãããŠãããã¯ãããžãŒãç解ããã®ã«15åãããããã«ãé¡ãããŸãã ãããããã®åŸãéç解æã®ããŒã«ãæ°ãã«èŠãŠãããããäœæ¥ã«é©çšããããšæãã§ãããã
ããŒã¿ãããŒåæ
ããŒã¿ã¹ããªãŒã ã®åæã«ãããããŸããŸãªãšã©ãŒãèŠã€ããããšãã§ããŸãã ãã®äžã«ã¯ãé åã®ç¯å²å€ãžã®åºå ¥ããã¡ã¢ãªãªãŒã¯ãåžžã«true / falseæ¡ä»¶ãnullãã€ã³ã¿ãŒã®éåç §ãªã©ããããŸãã
ãŸããããŒã¿åæã䜿çšããŠãå€éšããããã°ã©ã ã«éãããæªæ€èšŒããŒã¿ã䜿çšãããŠããç¶æ³ãæ€çŽ¢ã§ããŸãã æ»æè ã¯ããã®ãããªäžé£ã®å ¥åããŒã¿ãæºåããŠãããã°ã©ã ãå¿ èŠãªæ¹æ³ã§æ©èœãããããšãã§ããŸãã èšãæããã°ãäžååãªå ¥åå¶åŸ¡ã®ãšã©ãŒãè匱æ§ãšããŠäœ¿çšããå¯èœæ§ããããŸãã PVS-Studioã§æªæ€èšŒããŒã¿ã®äœ¿çšãæ€çŽ¢ããããã«ãç¹æ®ãªèšºæV1010ãå®è£ ãããæ¹åãç¶ããããŠããŸãã
ããŒã¿ãããŒã®åæ ïŒ Data-Flow Analysis ïŒã¯ãã³ã³ãã¥ãŒã¿ãŒããã°ã©ã ã®ããŸããŸãªãã€ã³ãã§å€æ°ã®å¯èœãªå€ãèšç®ããããšã§ãã ããšãã°ããã€ã³ã¿ãŒãéæ¥åç §ãããŠããããã®æç¹ã§ãã€ã³ã¿ãŒããŒãã«ãªãããšãããã£ãŠããå Žåãããã¯ãšã©ãŒã§ãããéçã¢ãã©ã€ã¶ãŒã¯ãããå ±åããŸãã
ããŒã¿ãããŒåæã䜿çšããŠãšã©ãŒãæ¢ãå®éçãªäŸãèŠãŠã¿ãŸãããã æ¥ä»ã®æ£ããããã§ãã¯ããããã«èšèšãããProtocol BuffersïŒprotobufïŒãããžã§ã¯ãã®é¢æ°ããããŸãã
static const int kDaysInMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; bool ValidateDateTime(const DateTime& time) { if (time.year < 1 || time.year > 9999 || time.month < 1 || time.month > 12 || time.day < 1 || time.day > 31 || time.hour < 0 || time.hour > 23 || time.minute < 0 || time.minute > 59 || time.second < 0 || time.second > 59) { return false; } if (time.month == 2 && IsLeapYear(time.year)) { return time.month <= kDaysInMonth[time.month] + 1; } else { return time.month <= kDaysInMonth[time.month]; } }
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãé¢æ°ã§2ã€ã®è«çãšã©ãŒãæ€åºãã次ã®ã¡ãã»ãŒãžã衚瀺ããŸãã
- V547 / CWE-571åŒ 'time.month <= kDaysInMonth [time.month] + 1'ã¯åžžã«trueã§ãã time.cc 83
- V547 / CWE-571åŒ 'time.month <= kDaysInMonth [time.month]'ã¯åžžã«trueã§ãã time.cc 85
éšååŒãtime.month <1 || time.month> 12 "ã æã®å€ãç¯å²[1..12]ã®å€ã«ããå Žåãé¢æ°ã¯äœæ¥ãåæ¢ããŸãã ã¢ãã©ã€ã¶ãŒã¯ãããèæ ®ããŠã2çªç®ã®ifã¹ããŒãã¡ã³ãã®å®è¡ãéå§ãããå Žåã æã®å€ãæ£ç¢ºã«[1..12]ã®ç¯å²ã«ããããšãèªèããŸãã åæ§ã«ã圌ã¯ä»ã®å€æ°ã®ç¯å²ïŒå¹Žãæ¥ãªã©ïŒãç¥ã£ãŠããŸãããä»ã§ã¯ãããã¯ç§ãã¡ã«ãšã£ãŠèå³æ·±ããã®ã§ã¯ãããŸããã
ããã§ãé åèŠçŽ ã«ã¢ã¯ã»ã¹ããããã®2ã€ã®åäžã®æŒç®åkDaysInMonth [time.month]ãèŠãŠã¿ãŸãããã
é åã¯éçã«èšå®ãããã¢ãã©ã€ã¶ãŒã¯ãã®ãã¹ãŠã®èŠçŽ ã®å€ãç¥ã£ãŠããŸãã
static const int kDaysInMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
æã«ã¯1ããçªå·ãä»ãããããããã¢ãã©ã€ã¶ãŒã¯é åã®å é ã§0ãèæ ®ããŸããã [28..31]ã®ç¯å²ã®å€ãé åããæœåºã§ããããšãããããŸããã
幎ãããã幎ãã©ããã«å¿ããŠãæ¥æ°ã«1ãè¿œå ãããŸãããããã¯ä»ã§ã¯èå³ã®å¯Ÿè±¡ã§ã¯ãããŸããã æ¯èŒèªäœã¯éèŠã§ãã
time.month <= kDaysInMonth[time.month] + 1; time.month <= kDaysInMonth[time.month];
ç¯å²[1..12]ïŒææ°ïŒã¯ããã®æã®æ¥æ°ãšæ¯èŒãããŸãã
æåã®å Žåãæã¯åžžã«2æïŒ time.month == 2 ïŒã§ããããšãèæ ®ãããšã次ã®ç¯å²ãæ¯èŒãããããšãããããŸãã
- 2 <= 29
- [1..12] <= [28..31]
ã芧ã®ãšãããæ¯èŒã®çµæã¯åžžã«çã§ãããPVS-Studioã¢ãã©ã€ã¶ãŒã¯èŠåããŠããŸãã å®éãã³ãŒãã«ã¯2ã€ã®åãã¿ã€ããã¹ãå«ãŸããŠããŸãã åŒã®å·ŠåŽã§ã¯ã æã§ã¯ãªãã æ¥ã¯ã©ã¹ã®ã¡ã³ããŒã䜿çšããå¿ èŠããããŸãã
æ£ããã³ãŒãã¯æ¬¡ã®ããã«ãªããŸãã
if (time.month == 2 && IsLeapYear(time.year)) { return time.day <= kDaysInMonth[time.month] + 1; } else { return time.day <= kDaysInMonth[time.month]; }
ããã§èª¬æãããšã©ãŒã¯ãã 2æ31æ¥ ãã®èšäºã§ã説æãããŠããŸãã
ã·ã³ããªãã¯å®è¡
åã®ã»ã¯ã·ã§ã³ã§ã¯ãã¢ãã©ã€ã¶ãŒãå€æ°ã®å¯èœãªå€ãèšç®ããæ¹æ³ãæ€èšããŸããã ãã ããããã€ãã®ãšã©ãŒãèŠã€ããããã«ãå€æ°ã®å€ãç¥ãå¿ èŠã¯ãããŸããã ã·ã³ããªãã¯å®è¡ã«ã¯ãã·ã³ããªãã¯æ¹çšåŒã®è§£æ³ãå«ãŸããŸãã
ãšã©ãŒããŒã¿ããŒã¹ã«é©åãªãã¢ãèŠã€ãããŸããã§ããã®ã§ãåæã³ãŒãã®äŸãæ€èšããŠãã ãã ã
int Foo(int A, int B) { if (A == B) return 10 / (A - B); return 1; }
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãèŠåV609 / CWE-369 Divide by zeroãçæããŸãã åæ¯ 'A-B' ==0ãtest.cpp 12
å€æ°Aããã³Bã®å€ã¯ãã¢ãã©ã€ã¶ãŒã«ãšã£ãŠäžæã§ãã ããããã¢ãã©ã€ã¶ãŒã¯åŒ10 /ïŒA-BïŒãèšç®ããæç¹ã§ãå€æ°AãšBãçããããšãç¥ã£ãŠããŸãã ãããã£ãŠã0ã«ããé€ç®ãçºçããŸãã
AãšBã®å€ã¯äžæã ãšèšããŸããã äžè¬çãªå Žåãããã¯äºå®ã§ãã ãã ããã¢ãã©ã€ã¶ãŒãå®éã®åŒæ°ã®ç¹å®ã®å€ãæã€é¢æ°åŒã³åºããæ€åºããå Žåãããã¯èæ ®ãããŸãã äŸãèããŠã¿ãŸãããïŒ
int Div(int X) { return 10 / X; } void Foo() { for (int i = 0; i < 5; ++i) Div(i); }
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãŒãé€ç®ãèŠåããŸãïŒV609 CWE-628ãŒãé€ç®ã åæ¯ 'X' ==0ã'Div 'é¢æ°ã¯å€' [0..4] 'ãåŠçããŸãã æåã®åŒæ°ã調ã¹ãŸãã è¡ã確èªïŒ106ã110ãconsoleapplication2017.cpp 106
ããã§ã¯ãããŒã¿ãããŒåæãã·ã³ããªãã¯å®è¡ãããã³èªåã¡ãœããã¢ãããŒã·ã§ã³ã®ãã¯ãããžãŒã®çµã¿åãããæ¢ã«æ©èœããŠããŸãïŒãã®ãã¯ãããžãŒã«ã€ããŠã¯æ¬¡ã®ã»ã¯ã·ã§ã³ã§èª¬æããŸãïŒã ã¢ãã©ã€ã¶ãŒã¯ãå€æ°Xã Divé¢æ°ã®é€æ°ãšããŠäœ¿çšãããŠããããšã確èªããŸãã ããã«åºã¥ããŠã Divé¢æ°çšã®ç¹å¥ãªæ³šéãèªåçã«æ§ç¯ãããŸãã ããã«ãå€ã®ç¯å²[0..4]ãåŒæ°XãšããŠé¢æ°ã«æž¡ãããããšãèæ ®ãããŸãã ã¢ãã©ã€ã¶ãŒã¯ã0ã«ããé€ç®ãçºçãããšçµè«ä»ããŸãã
ã¡ãœãã泚é
ç§ãã¡ã®ããŒã ã¯ã以äžã§æäŸãããæ°åã®é¢æ°ãšã¯ã©ã¹ã«æ³šéãä»ããŠããŸãã
- ãŠã£ãã
- Cæšæºã©ã€ãã©ãª
- æšæºãã³ãã¬ãŒãã©ã€ãã©ãªïŒSTLïŒã
- glibcïŒGNU Cã©ã€ãã©ãªïŒ
- Qt
- Mfc
- zlib
- libpng
- Openssl
- ãªã©ãªã©
ãã¹ãŠã®æ©èœã«ã¯æåã§æ³šéãä»ããããŸããããã«ããããšã©ãŒã®æ€åºã«é¢ããŠéèŠãªå€ãã®ç¹æ§ãèšå®ã§ããŸãã ããšãã°ã freadé¢æ°ã«æž¡ããããããã¡ãŒã®ãµã€ãºã¯ããã¡ã€ã«ããèªã¿åãäºå®ã®ãã€ãæ°ä»¥äžã§ãªããã°ãªããªãããšãæå®ãããŠããŸãã 2çªç®ã3çªç®ã®åŒæ°ãšé¢æ°ãè¿ãããšãã§ããå€ã®é¢ä¿ã瀺ãããŠããŸãã ãã¹ãŠæ¬¡ã®ããã«ãªããŸãã
ãã®æ³šéã®ãããã§ã freadé¢æ°ã䜿çšãã次ã®ã³ãŒãã¯2ã€ã®ãšã©ãŒãããã«æããã«ããŸãã
void Foo(FILE *f) { char buf[100]; size_t i = fread(buf, sizeof(char), 1000, f); buf[i] = 1; .... }
PVS-Studioã®èŠåïŒ
- V512 CWE-119ãfreadãé¢æ°ãåŒã³åºããšããããã¡ãŒãbufãããªãŒããŒãããŒããŸãã test.cpp 116
- V557 CWE-787ã¢ã¬ã€ã®ãªãŒããŒã©ã³ãå¯èœã§ãã ãiãã€ã³ããã¯ã¹ã®å€ã¯1000ã«éããå¯èœæ§ããããŸããtest.cpp 117
æåã«ãã¢ãã©ã€ã¶ãŒã¯2çªç®ãš3çªç®ã®å®åŒæ°ãä¹ç®ããé¢æ°ãæ倧1000ãã€ãã®ããŒã¿ãèªã¿åããããšãèšç®ããŸããã åæã«ããããã¡ãµã€ãºã¯100ãã€ããããªãããããªãŒããŒãããŒããå¯èœæ§ããããŸãã
第äºã«ãé¢æ°ã¯1000ãã€ããŸã§èªã¿åãããšãã§ãããããå€æ°iã®å¯èœãªå€ã®ç¯å²ã¯[0..1000]ã§ãã ãããã£ãŠãé åãžã®ã¢ã¯ã»ã¹ã¯ééã£ãã€ã³ããã¯ã¹ã§çºçããå¯èœæ§ããããŸãã
ãšã©ãŒã®å¥ã®ç°¡åãªäŸãèŠãŠã¿ãŸãããããšã©ãŒã®æ€åºã¯ã memseté¢æ°ã®ããŒã¯ã¢ããã®ãããã§å¯èœã«ãªããŸããã CryEngine V.ãããžã§ã¯ãã®ã³ãŒãã¹ããããã次ã«ç€ºããŸãã
void EnableFloatExceptions(....) { .... CONTEXT ctx; memset(&ctx, sizeof(ctx), 0); .... }
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ã¿ã€ããã¹ãèŠã€ããŸããïŒV575ãmemsetãé¢æ°ã¯ã0ãèŠçŽ ãåŠçããŸãã 3çªç®ã®åŒæ°ã調ã¹ãŸãã crythreadutil_win32.h 294
é¢æ°ã®2çªç®ãš3çªç®ã®åŒæ°ãæ··åããŸããã ãã®çµæãé¢æ°ã¯0ãã€ããåŠçããäœãããŸããã ã¢ãã©ã€ã¶ãŒã¯ãã®ç°åžžã«æ°ä»ããããã°ã©ããŒã«èŠåããŸãã 以åãã CryEngine Vã®åŸ æã®ãã§ã㯠ããšããèšäºã§ãã®ãšã©ãŒã«ã€ããŠæ¢ã«èª¬æããŸããã
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãæåã§èšå®ãã泚éã«éå®ãããŸããã ããã«ã圌ã¯ç¬èªã«é¢æ°ã®æ¬äœã調ã¹ãŠæ³šéãäœæããããšããŸãã ããã«ãããé¢æ°ã®äžé©åãªäœ¿çšã®ãšã©ãŒãèŠã€ããããšãã§ããŸãã ããšãã°ãã¢ãã©ã€ã¶ãŒã¯ãé¢æ°ãnullptrãè¿ãããšãã§ããããšãèšæ¶ããŠããŸãã ãã®é¢æ°ã«ãã£ãŠè¿ããããã€ã³ã¿ãŒãäºåãã§ãã¯ãªãã§äœ¿çšãããå Žåãã¢ãã©ã€ã¶ãŒã¯ããã«ã€ããŠèŠåããŸãã äŸïŒ
int GlobalInt; int *Get() { return (rand() % 2) ? nullptr : &GlobalInt; } void Use() { *Get() = 1; }
èŠåïŒV522 CWE-690æœåšçãªãã«ãã€ã³ã¿ãŒ 'GetïŒïŒ'ã®éåç §ãååšããå¯èœæ§ããããŸãã test.cpp 129
ã泚æ éã®æ¹æ³ã§èª¿ã¹ãã°ããã®ãšã©ãŒã®æ€çŽ¢ã«ã¢ãããŒãã§ããŸãã äœãèŠããŠã¯ãããŸãããGeté¢æ°ã®åŒã³åºããçºçãããã³ã«ãå®éã®åŒæ°ãç¥ã£ãŠåæããŠãã ããã ãã®ãããªã¢ã«ãŽãªãºã ã«ãããçè«çã«ã¯ããå€ãã®ãšã©ãŒãèŠã€ããããšãã§ããŸãããææ°é¢æ°çã«è€éã«ãªããŸãã ããã°ã©ã ã®åææéã¯æ°åäžåã«ãªããŸããããã®ã¢ãããŒãã¯å®çšçãªèŠ³ç¹ããè¡ãæ¢ãŸãã ãšèããŠããŸãã PVS-Studioã§ã¯ãé¢æ°ã®èªå泚éã®æ¹åæ§ãéçºããŠããŸãã
ãã¿ãŒã³ãããã³ã°
ãã¿ãŒã³ãšã®ãã¯ãããžãŒãããã³ã°ã¯ãäžèŠãããšãæ£èŠè¡šçŸã䜿çšããæ€çŽ¢ã®ããã«èŠããŸãã å®éãããã¯ããã§ã¯ãªãããã¹ãŠãã¯ããã«è€éã§ãã
ãŸãããã§ã«è¿°ã¹ãããã« ãæ£èŠè¡šçŸã¯äžè¬ã«äŸ¡å€ããããŸããã 第äºã«ãã¢ãã©ã€ã¶ãŒã¯ããã¹ãè¡ã§ã¯ãªããããè€éã§é«ã¬ãã«ã®ãšã©ãŒãã¿ãŒã³ãèªèã§ããæ§æããªãŒã§æ©èœããŸãã
2ã€ã®äŸãèããŠã¿ãŸãããã1ã€ã¯ããåçŽã§ããã1ã€ã¯ããè€éã§ãã ç§ãèŠã€ããæåã®ãšã©ãŒã¯ãAndroidã®ãœãŒã¹ã³ãŒãããã§ãã¯ããããšã§ããã
void TagMonitor::parseTagsToMonitor(String8 tagNames) { std::lock_guard<std::mutex> lock(mMonitorMutex); if (ssize_t idx = tagNames.find("3a") != -1) { ssize_t end = tagNames.find(",", idx); char* start = tagNames.lockBuffer(tagNames.size()); start[idx] = '\0'; .... } .... }
PVS-Studioã¢ãã©ã€ã¶ãŒã¯ãC ++ã®æäœã®åªå é äœã«é¢ããããã°ã©ããŒã®èª€è§£ã«é¢é£ããå€å žçãªãšã©ãŒãã¿ãŒã³ãèªèããŸããV593/ CWE-783ãA = BïŒ= Cãã®è¡šçŸãæ€èšããŠãã ããã åŒã¯æ¬¡ã®ããã«èšç®ãããŸãïŒ 'A =ïŒBïŒ= CïŒ'ã TagMonitor.cpp 50
ãã®è¡ãããèŠãŠãã ããïŒ
if (ssize_t idx = tagNames.find("3a") != -1) {
ããã°ã©ããŒã¯ãå²ãåœãŠãæåã«å®è¡ããããã®åŸã®ã¿-1ãšã®æ¯èŒãå®è¡ããããšæ³å®ããŸãã å®éãæ¯èŒãæåã«ãªããŸãã ã¯ã©ã·ã㯠ãã®ãšã©ãŒã«ã€ããŠã¯ãAndroidæ€èšŒã«é¢ããèšäºã§è©³ãã説æããŠããŸã ïŒããã®ä»ã®ãšã©ãŒãã®ç« ãåç §ïŒã
ããã§ãé«ã¬ãã«ã®ãã¿ãŒã³ãããã³ã°ãªãã·ã§ã³ãæ€èšããŸãã
static inline void sha1ProcessChunk(....) { .... quint8 chunkBuffer[64]; .... #ifdef SHA1_WIPE_VARIABLES .... memset(chunkBuffer, 0, 64); #endif }
PVS-StudioèŠåïŒV597 CWE-14ã³ã³ãã€ã©ã¯ããmemsetãé¢æ°åŒã³åºããåé€ã§ããŸããããã¯ããchunkBufferããããã¡ãŒã®ãã©ãã·ã¥ã«äœ¿çšãããŸãã RtlSecureZeroMemoryïŒïŒé¢æ°ã䜿çšããŠããã©ã€ããŒãããŒã¿ãæ¶å»ããå¿ èŠããããŸãã sha1.cpp 189
åé¡ã®æ¬è³ªã¯ã memseté¢æ°ã䜿çšããŠãããã¡ããŒãã§åããåŸããã®ãããã¡ã¯ã©ãã§ã䜿çšãããªãããšã§ãã æé©åãã©ã°ã䜿çšããŠã³ãŒããã³ã³ãã€ã«ãããšãã³ã³ãã€ã©ã¯ãã®é¢æ°åŒã³åºããåé·ã§ãããšå€æããåé€ããŸãã C ++èšèªã®èŠ³ç¹ããã¯ãé¢æ°ã®åŒã³åºãã«ã¯ããã°ã©ã äžã§èŠ³å¯å¯èœãªåäœããªãããã圌ã«ã¯ããã«å¯Ÿããæš©å©ããããŸãã chunkBufferãããã¡ãŒãåããçŽåŸã«ã sha1ProcessChunké¢æ°ã¯çµäºããŸãã ãããã¡ã¯ã¹ã¿ãã¯äžã«äœæããããããé¢æ°ãçµäºãããšäœ¿çšã§ããªããªããŸãã ãããã£ãŠãã³ã³ãã€ã©ãŒã®èŠ³ç¹ããã¯ããŒãã§åããŠãæå³ããããŸããã
ãã®çµæãã¹ã¿ãã¯äžã®ã©ããã«ãã©ã€ããŒãããŒã¿ãæ®ãããã©ãã«ã«ã€ãªããå¯èœæ§ããããŸãã ãã®ãããã¯ã®è©³çŽ°ã«ã€ããŠã¯ãã ãã©ã€ããŒãããŒã¿ã®å®å šãªã¯ãªãŒãã³ã° ããåç §ããŠãã ããã
ããã¯ãé«åºŠãªãã¿ãŒã³ãããã³ã°ã®äŸã§ãã ãŸããã¢ãã©ã€ã¶ãŒã¯ããã®è匱æ§ã®ååšãèªèããŠããå¿ èŠããããŸããããã¯ãCommon Weakness Enumerationã«åŸã£ãŠCWE-14ïŒCompiler Removal of Code to Clear BuffersãšããŠåé¡ãããŠããŸãã
第äºã«ãã¹ã¿ãã¯äžã§ãããã¡ãäœæããããã¹ãŠã®å Žæãã³ãŒãå ã§èŠã€ããå¿ èŠãããã memseté¢æ°ã䜿çšããŠæ¶å»ãããä»ã®å Žæã§ã¯äœ¿çšãããŸããã
ãããã«
ã芧ã®ãšãããéç解æã¯éåžžã«èå³æ·±ãæçšãªæ¹æ³è«ã§ãã ããã«ãããåæ段éã§å€æ°ã®ãšã©ãŒãšæœåšçãªè匱æ§ãæé€ã§ããŸãïŒ SASTãåç §ïŒã ãŸã éç解æãå®å šã«è¡ã£ãŠããªãå Žåã¯ã ããã°ãã芧ãã ãããããŸããŸãªãããžã§ã¯ãã§PVS-Studioã䜿çšããŠæ€åºããããšã©ãŒãå®æçã«åæããŠããŸãã ããªãã¯åã«ç¡é¢å¿ã§ããããšã¯ã§ããŸããã
ã客æ§ã®äžã«è²Žç€Ÿãã玹ä»ããã客æ§ã®ã¢ããªã±ãŒã·ã§ã³ãããè¯ããããä¿¡é Œæ§ãé«ããããå®å šã«ãããæäŒãããããŠããã ããŸãã
ãã®èšäºãè±èªåã®èŽè¡ãšå ±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒAndrey Karpovã ãã°ãæœåšçãªè匱æ§ãèŠã€ããããã«PVS-Studioã³ãŒãã¢ãã©ã€ã¶ãŒã§äœ¿çšããããã¯ãããžãŒ ã