Bug 55936 - sd-journal: check if the pointers passed are the same
Summary: sd-journal: check if the pointers passed are the same
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium trivial
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-12 18:38 UTC by Thomas H.P. Andersen
Modified: 2013-05-15 01:56 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Check that the passed pointers are not the same (1.11 KB, text/plain)
2012-10-12 18:38 UTC, Thomas H.P. Andersen
Details

Description Thomas H.P. Andersen 2012-10-12 18:38:18 UTC
Created attachment 68501 [details]
Check that the passed pointers are not the same

sd_journal_get_cutoff_realtime_usec(sd_journal* j, uint64_t* from, uint64_t* to) checks that the parameters 'to' and 'from' are not both null at the same time. That makes sense as it would not produce any result. Another way to get a bad result is if the same pointer is passed as both 'to' and 'from'.

This is not a problem for any real code that I know of. I was just reading the docs and wondering what would happen.

The attached patch adds a check for this in sd_journal_get_cutoff_realtime_usec and sd_journal_get_cutoff_monotonic_usec.
Comment 1 Zbigniew Jedrzejewski-Szmek 2013-04-12 14:48:58 UTC
Normally we don't check such stuff, since there's just too many ways to get things wrong, but in this case, a) the check is very cheap compared to the rest of the function, b) it seems like an error that is relatively easy to make in a long list of arguments. I think you should go ahead and apply it.
Comment 2 Zbigniew Jedrzejewski-Szmek 2013-05-15 01:56:14 UTC
Applied in http://cgit.freedesktop.org/systemd/systemd/commit/?id=3988773.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.