Bug 55936

Summary: sd-journal: check if the pointers passed are the same
Product: systemd Reporter: Thomas H.P. Andersen <phomes>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: trivial    
Priority: medium CC: phomes
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Check that the passed pointers are not the same

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.