äžçäžã§äœäººãåå¹ã䜿çšããŠããŸããïŒ ããããããããã æè²ç®çãŸãã¯åã«ãªãªãžãã«ã®å£°åªã®æã®ããã«ãã»ãšãã©ãã¹ãŠã®æ ç»ãšå€ãã®èšèªã®åå¹ãã€ã³ã¿ãŒãããã§èŠã€ããããšãã§ããŸãã ãããã¯ãã¹ãŠç¹å¥ãªããã°ã©ã ã§äœæãããŸãã ã»ãšãã©ã®ããã°ã©ã ãšåæ§ã«ãåå¹ç·šéã¯ãã°ãšãã圢ã§é©ãããšãªãå®è¡ã§ããŸããã§ããã
ã¯ããã«
åå¹ç·šéã¯ãæ©èœã®èšå€§ãªãªã¹ããåããç¡æã®ãšãã£ã¿ãŒã§ãã ããã¯ã倧èŠæš¡ãªãªãŒãã³ãœãŒã¹ã®CïŒãããžã§ã¯ãã§ãã ãã®ããã°ã©ã ã¯éåžžã«äººæ°ããããæ€çŽ¢ãšã³ãžã³ã®çµæã®æåã®è¡ã§çºè¡ãããå€ãã®è³ããããžã§ã¯ãã®ãŠã§ããµã€ãã«ãªã¹ããããŠããŸãã GitHubã®ãªããžããªã§ããããžã§ã¯ãã掻çºã«éçºãããŠãããå€ãã®ã¹ã¿ãŒãšãã©ãŒã¯ãããããšãããããŸãã äžè¬ã«ãããã¯éçºã«åå ããã®ã«é©ãããããžã§ã¯ãã§ãã ã»ãšãã©ã®åœ¢åŒã¯ããã¹ã圢åŒã§ã¯ãªããããæåã¯åå¹ã解æããããã®ã©ã€ãã©ãªãæ¢ããŠããŸããããä»ã¯å°ãåŸã§ãããžã§ã¯ãã«æ»ããŸãã
310ã®åé¡ã¯ãGitHubã®ãããžã§ã¯ãããŒãžã§å ¬éãããŠããŸãã ãããããåæã®çµæã§äœæ¥ããããšã¯äœããä¿®æ£ããã®ã«åœ¹ç«ã¡ãŸãã ã³ãŒãã®èª¿æ»ã«äœ¿çšãããPVS-Studioéçã¢ãã©ã€ã¶ãŒã¯ã460åã®èŠåïŒãã¹ãŠã®éèŠåºŠã¬ãã«ã®åèšïŒãçºè¡ããŸããã ã»ãšãã©ãã¹ãŠãä¿®æ£å¯èœã§ãããä¿®æ£ããå¿ èŠããããŸãã ããã¯ãã¢ãã©ã€ã¶ãŒã«æšå¥šããã蚺æãã»ãšãã©ãªãããã§ãã èŠã€ãã£ãçµæã¯éåžžãã³ãŒãã®å®éã®åé¡ã瀺ããŠããŸãã èšäºã§ã¯ã³ãŒãäŸã瀺ããŸãããäœæ¥ã«å€§ããªåœ±é¿ãäžããå¯èœæ§ã®ãããšã©ãŒã®ã¿ãéžæããŸãã
å€ããå°ãªããæ確ãªã³ãŒãã¹ããããã«ã€ããŠã¯ãä¿®æ£ãå ãããã«ãªã¯ãšã¹ããéä¿¡ããŸãã ãã ãããããžã§ã¯ãã®äœæè ã¯ãåæã®ãã¹ãŠã®çµæãææ¡ããèªåã§ãããžã§ã¯ãã確èªããæ¹ãé©åã§ãã
ã¹ã¿ã€ã«ãç¡èŠãã
åå¹ã¹ã¿ã€ã«ãèšå®ããããã®ãã©ãŒã ã®ãã©ã°ã¡ã³ãã¯æ¬¡ã®ããã«ãªããŸãã
ãããŠããã®ãã©ãŒã ã«é¢é£ä»ããããŠããã³ãŒãã«é¢ããã¢ãã©ã€ã¶ãŒã®èŠåã¯æ¬¡ã®ãšããã§ãã
V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ300ã302ãSubStationAlphaStyles.cs 300
public static void AddStyle(ListView lv, SsaStyle ssaStyle, Subtitle subtitle, bool isSubstationAlpha) { .... if (ssaStyle.Bold || ssaStyle.Italic) subItem.Font = new Font(...., FontStyle.Bold | FontStyle.Italic); else if (ssaStyle.Bold) subItem.Font = new Font(...., FontStyle.Bold); else if (ssaStyle.Italic) subItem.Font = new Font(...., FontStyle.Italic); else if (ssaStyle.Italic) subItem.Font = new Font(...., FontStyle.Regular); .... }
åèšã§ãã¢ãã©ã€ã¶ã¯ãã®ã³ãŒããã©ã°ã¡ã³ãã«å¯ŸããŠ4ã€ã®èŠåãçºè¡ããŸããã ã»ãŒãã¹ãŠã®è¡ã«ãšã©ãŒããããããããã¯é©ãããšã§ã¯ãããŸããã ããã«ã ssaStyle.Underlineã®ãªãã·ã§ã³ã¯ããã§ã¯èæ ®ãããŸããïŒ
ã³ãŒãã¯æ¬¡ã®ããã«æžãçŽããéåžžã«æ éã«è¡ãæ¹ãé©åã§ãã
.... if (ssaStyle.Bold) fontStyles |= FontStyle.Bold; .... subItem.Font = new Font(...., fontStyles); ....
ããã¹ãã®æåŸã®æ®µèœã¯åé€ãããŸãã
V3022 CWE-570åŒ '_networkSessionïŒ= Null && _networkSession.LastSubtitleïŒ= Null && i <_networkSession.LastSubtitle.Paragraphs.Count'ã¯åžžã«falseã§ãã Main.cs 7242
private void DeleteSelectedLines() { .... if (_networkSession != null) // <= { _networkSession.TimerStop(); NetworkGetSendUpdates(indices, 0, null); } else { indices.Reverse(); foreach (int i in indices) { _subtitle.Paragraphs.RemoveAt(i); if (_networkSession != null && // <= _networkSession.LastSubtitle != null && i < _networkSession.LastSubtitle.Paragraphs.Count) _networkSession.LastSubtitle.Paragraphs.RemoveAt(i); } .... } .... }
_networkSessionå€æ°ã¯æåã®æ¡ä»¶ã§ãã§ã«ãã§ãã¯ãããŠããããã elseãã©ã³ãã§ã¯nullã§ããããšãä¿èšŒãããŠããŸã ã ãã®ãã§ãã¯ã®çµã¿åããã«ããã誀ã£ãç¶æ ãšå°éäžèœãªã³ãŒããçºçããŸããã
ã¿ã€ããã¹ã«ããæ©èœã®æ倱
V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªïŒ113ã115ãSsaStyle.cs 113
public string ToRawSsa(string styleFormat) { var sb = new StringBuilder(); sb.Append("Style: "); var format = ....; for (int i = 0; i < format.Length; i++) { string f = format[i].Trim(); if (f == "name") sb.Append(Name); .... else if (f == "shadow") // <= sb.Append(OutlineWidth); // <= else if (f == "shadow") // <= sb.Append(ShadowWidth); // <= .... } .... }
æ¡ä»¶ã®ã«ã¹ã±ãŒãã®ã¿ã€ããã¹ã«ãããå°éäžèœãªã³ãŒãåå²ãçºçããŸãã å€ãã®å Žåããã®ã³ãŒãã¯Copy-Pasteããã°ã©ãã³ã°ã®çµæã§ãã äžèšã®äŸã§ã¯ã2çªç®ã«éè€ããæ¡ä»¶ãæºããããããšã¯ãããŸããã ãããŠãããã¯ç§ãèšäºã®ããã«éžãã æãåçŽã§æãã³ã³ãã¯ããªäŸã§ãã ãããžã§ã¯ãã«ã¯ãå¥ã®ã»ã¯ã·ã§ã³ã§åé¡ã説æããããã®å€ãã®äŸããããŸããã
ä¿®æ£ãå¿ èŠãªCopy-Pasteã³ãŒãã®å šãªã¹ãã¯æ¬¡ã®ãšããã§ãã
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ268ã270ãExportCustomTextFormat.cs 268
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ278ã280ãExportCustomTextFormat.cs 278
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ220ã252ãSetSyncPoint.cs 220
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ712ã743ãExportPngXml.cs 712
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ712ã743ãExportPngXml.cs 712
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã ãã§ãã¯è¡ïŒ162ã178ãLambdaCap.cs 162
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªïŒ166ã182ãLambdaCap.cs 166
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªïŒ170ã186ãLambdaCap.cs 170
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªïŒ174ã190ãLambdaCap.cs 174
- V3003 CWE-570ãifïŒAïŒ{...} else ifïŒAïŒ{...}ããã¿ãŒã³ã®äœ¿çšãæ€åºãããŸããã è«çãšã©ãŒãååšããå¯èœæ§ããããŸãã è¡ã確èªããŠãã ããïŒ398ã406ãEbu.cs 398
- V3021 CWE-561åäžã®æ¡ä»¶åŒãæã€2ã€ã®ãifãã¹ããŒãã¡ã³ãããããŸãã æåã®ãifãã¹ããŒãã¡ã³ãã«ã¯ã¡ãœããã®æ»ãå€ãå«ãŸããŸãã ããã¯ã2çªç®ã®ãifãã¹ããŒãã¡ã³ããç¡æå³ã§ããããšãæå³ããŸãFinalCutProTest2Xml.cs 22
- V3021 CWE-561åäžã®æ¡ä»¶åŒãæã€2ã€ã®ãifãã¹ããŒãã¡ã³ãããããŸãã æåã®ãifãã¹ããŒãã¡ã³ãã«ã¯ã¡ãœããã®æ»ãå€ãå«ãŸããŸãã ããã¯ã2çªç®ã®ãifãã¹ããŒãã¡ã³ããç¡æå³ã§ããããšãæå³ããŸãFinalCutProTextXml.cs 21
- V3021 CWE-561åäžã®æ¡ä»¶åŒãæã€2ã€ã®ãifãã¹ããŒãã¡ã³ãããããŸãã æåã®ãifãã¹ããŒãã¡ã³ãã«ã¯ã¡ãœããã®æ»ãå€ãå«ãŸããŸãã ããã¯ã2çªç®ã®ãifãã¹ããŒãã¡ã³ããç¡æå³ã§ããããšãæå³ããŸãFinalCutProXml.cs 22
720x480ã®ç»åã«åé¡ããã
V3022 CWE-570åŒ 'param.Bitmap.Width == 720 && param.Bitmap.Width == 480'ã¯åžžã«falseã§ãã ãããã '||' ããã§æŒç®åã䜿çšããå¿ èŠããããŸãã ExportPngXml.cs 1808
private static string FormatFabTime(TimeCode time, MakeBitmapParameter param) { if (param.Bitmap.Width == 720 && param.Bitmap.Width == 480) return $"...."; // drop frame if (Math.Abs(param.... - 24 * (999 / 1000)) < 0.01 || Math.Abs(param.... - 29 * (999 / 1000)) < 0.01 || Math.Abs(param.... - 59 * (999 / 1000)) < 0.01) return $"...."; return $"...."; }
å¹ ãšé«ãã®æ··ä¹±ã¯ãå žåçãªã¿ã€ããã¹ã®äŸã§ãã ãããããã®æ©èœã§ã¯äœãä»ã®ãã®ãçãããã 4ã€ã®ãããã§çœ®ãæããè¡ã®ç¥èªã¯ãã¹ãŠåãè¡ã§ãïŒ {time.HoursïŒ00}; {time.MinutesïŒ00}; {time.SecondsïŒ00}; {SubtitleFormat.MillisecondsToFramesMaxFrameRateïŒtime.MillisecondsïŒ ïŒ00} ã ã€ãŸã 2ã€ã®æ¡ä»¶ãååšããŠãé¢æ°ã®çµæã«ã¯åœ±é¿ããŸãããé¢æ°ã¯åžžã«åããã®ãè¿ããŸãã
ãããªã§ãŒã·ã«ã®èªã¿èŸŒã¿ã¯åžžã«æåããŠããŸã
V3009 CWE-393ãã®ã¡ãœãããåžžã«ãtrueããšããåãå€ãè¿ãã®ã¯å¥åŠã§ãã Main.cs 10153
private bool LoadTextSTFromMatroska( MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode) { .... _fileDateTime = new DateTime(); _converted = true; if (batchMode) return true; SubtitleListview1.Fill(_subtitle, _subtitleAlternate); if (_subtitle.Paragraphs.Count > 0) SubtitleListview1.SelectIndexAndEnsureVisible(0); ShowSource(); return true; }
åžžã«trueãè¿ãé¢æ°ãèŠã€ãããŸããã ããã¯ããããééãã§ãã ãã®é¢æ°ã®å€ã¯ãããã°ã©ã ã®4ã€ã®å Žæã§ãã§ãã¯ãããŸãã LoadDvbFromMatroskaïŒïŒãªã©ã®ã³ãŒãå ã®åæ§ã®é¢æ°ãè¿ãã«ãããç°ãªãå€ãè¿ããŸãã
圹ã«ç«ããªãããŸãã¯èª€ã£ãã³ãŒã
V3022 CWE-571åŒ 'listBoxVobFiles.Items.Count> 0'ã¯åžžã«trueã§ãã DvdSubRip.cs 533
private void DvdSubRip_Shown(object sender, EventArgs e) { if (string.IsNullOrEmpty(_initialFileName)) return; if (_initialFileName.EndsWith(".ifo", ....)) { OpenIfoFile(_initialFileName); } else if (_initialFileName.EndsWith(".vob", ....)) { listBoxVobFiles.Items.Add(_initialFileName); buttonStartRipping.Enabled = listBoxVobFiles.Items.Count > 0; } _initialFileName = null; }
ã¢ã€ãã ãlistBoxVobFilesãªã¹ãã«è¿œå ããããªã¹ãã空ãã©ããã確èªãããŸãã æããã«ãå°ãªããšã1ã€ã®èŠçŽ ããããŸãã ãããŠããã®ãããªãã§ãã¯ã¯30以äžããããããžã§ã¯ãã§ã¯åžžã«trueãŸãã¯falseã§ãã
楜ããäŸã§ãã
V3005 ãpositionInfoãå€æ°ã¯ããèªäœã«å²ãåœãŠãããŸãã WebVTT.cs 79
internal static string GetPositionInfoFromAssTag(Paragraph p) { .... if (!string.IsNullOrEmpty(line)) { if (positionInfo == null) positionInfo = " line:" + line; else positionInfo = positionInfo += " line:" + line; } .... }
èšé²ãªãã·ã§ã³ãA = A + nããšãA + = nããéžæããŠããã®ã³ãŒãã®äœæè ã¯åŠ¥åãªãã·ã§ã³ãA = A + = nããéžæããŸããïŒD
ãããã«
ç¹å®ã®ã¢ãã©ã€ã¶ãŒèŠåãä¿®æ£ããæ¹æ³ãç解ããã«ã¯ãåå¹åœ¢åŒãšãã®åŠçã®æ©èœã«ã€ããŠå°ãç解ããå¿ èŠããããŸãã ãããã£ãŠããããžã§ã¯ãããµããŒããããã«ãªã¯ãšã¹ãã«GitHubã®ãããžã§ã¯ãã®äœæè ãžã®ä¿®æ£ãæ®ããã人ãããå ŽåãPVS-Studioã®é«/äžã¬ãã«ã®èŠåãå«ãHTMLã¬ããŒããããŠã³ããŒãããããã®ãªã³ã¯ããããŸã ã
è±èªã話ãèŽè¡ãšãã®èšäºãå ±æãããå Žåã¯ã翻蚳ãžã®ãªã³ã¯ã䜿çšããŠãã ããïŒSvyatoslav Razmyslovã åå¹ãåçŽã«ç·šéããªã
èšäºãèªãã§è³ªåããããŸããïŒ
å€ãã®å Žåãèšäºã«ã¯åã質åãå¯ããããŸãã ããã§åçãåéããŸããïŒ PVS-StudioããŒãžã§ã³2015ã«é¢ããèšäºã®èªè
ããã®è³ªåãžã®åç ã ãªã¹ããã芧ãã ããã