Files
sousa-gecko/build/clang-plugin/NonTerminatedStringChecker.h
T
Nika Layzell 6380bc71ea Bug 2020817 - Part 2: Add a MOZ_NON_TERMINATED_STRING static analysis, r=xpcom-reviewers,emilio
This static analysis will identify and reject callers where folks are passing
nsTStringRepr::BeginReading() or ::Data() to printf-style functions. These
functions are not guaranteed to return a null terminated string, so should not
be used in these places.

Most places which hit this analysis should not actually be security bugs, but
we should fix them anyways, as people will use them as examples of what to do
and write bad code based off of them.

Differential Revision: https://phabricator.services.mozilla.com/D286156
2026-03-25 08:22:59 +00:00

20 lines
651 B
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NonTerminatedStringChecker_h_
#define NonTerminatedStringChecker_h_
#include "plugin.h"
class NonTerminatedStringChecker : public BaseCheck {
public:
NonTerminatedStringChecker(StringRef CheckName,
ContextType *Context = nullptr)
: BaseCheck(CheckName, Context) {}
void registerMatchers(MatchFinder *AstMatcher) override;
void check(const MatchFinder::MatchResult &Result) override;
};
#endif