Closed Bug 1531309 Opened 4 years ago Closed 4 years ago

error: format not a string literal and no format arguments [-Werror=format-security]

Categories

(Core :: Audio/Video, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: stransky, Assigned: glandium)

References

Details

Attachments

(1 file)

Fedora uses hardened Firefox builds, it produces this error:

2315 dist/include/mozilla/Logging.h:256 col 59: error: format not a string literal and no format arguments [-Werror=format-security]
2318 /home/komat/CVS/firefox/firefox-65.0.1/dom/media/systemservices/CamerasChild.cpp:24 col 19: note: in expansion of macro ‘MOZ_LOG’

#define MOZ_LOG(_module, _level, _args)
do {
const ::mozilla::LogModule* moz_real_module = _module;
if (MOZ_LOG_TEST(moz_real_module, _level)) {
mozilla::detail::log_print(moz_real_module, _level,
MOZ_LOG_EXPAND_ARGS _args);
}
} while (0)

CamerasChild.cpp:460
int CamerasChild::FocusOnSelectedSource(CaptureEngine aCapEngine,
const int aCaptureId) {
LOG((PRETTY_FUNCTION)); << here we come

I'm uncertain why this is a lint issue, could you explain please?

Flags: needinfo?(stransky)

(In reply to Mark Banner (:standard8) from comment #1)

I'm uncertain why this is a lint issue, could you explain please?

I just used the same component as Bug 1514782 which I used as a template. Please move to appropriate component if I'm wrong.

Flags: needinfo?(stransky)

(In reply to Martin Stránský [:stransky] from comment #2)

(In reply to Mark Banner (:standard8) from comment #1)

I'm uncertain why this is a lint issue, could you explain please?
I just used the same component as Bug 1514782 which I used as a template. Please move to appropriate component if I'm wrong.

Sylvestre, could you explain please (or move them)?

Flags: needinfo?(sledru)
Component: Lint and Formatting → Audio/Video
Flags: needinfo?(sledru)
Product: Firefox Build System → Core
Assignee: nobody → mh+mozilla

PRETTY_FUNCTION and FUNCTION are not guaranteed to be a string
literal, and only string literals should be used as format strings. GCC
9 complains about this with -Werror=format-security.

Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/42478b7856c0
Don't use __PRETTY_FUNCTION__ or __FUNCTION__ as format strings. r=sylvestre
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.