Merge lp:~mc-return/compiz/compiz.merge-fix957582-use-snprintf-instead-of-sprintf into lp:compiz/0.9.9

Proposed by MC Return
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 3571
Merged at revision: 3585
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix957582-use-snprintf-instead-of-sprintf
Merge into: lp:compiz/0.9.9
Diff against target: 12 lines (+1/-1)
1 file modified
libdecoration/decoration.c (+1/-1)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix957582-use-snprintf-instead-of-sprintf
Reviewer Review Type Date Requested Status
Stephen M. Webb Approve
Sam Spilsbury Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+145059@code.launchpad.net

Commit message

Followed a recommendation of Coverity and replaced sprintf () with snprintf () with a buffer size of 128, as the definition says char buf[128].

(LP: #957582)

Description of the change

I guess this sprintf would never overflow, but it does not hurt to silence Coverity and simply replace it either.

Sam, Daniel - you have to decide if you want those Coverity SECURE_CODING recommendations to be followed, then I'll fix the rest of them also, otherwise we should mark those bug reports as invalid or won't fix.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

This makes sense as is, although I would recommend using std::string and stringstream where possible in future if individual line performance is not a huge concern (eg, we are not in an inner loop).

I would also recommend fixing all of the SECURE_CODING stuff in one-review where it makes sense to, having a proliferation of reviews for each individual bug is going to be a huge overhead.

review: Approve
Revision history for this message
Stephen M. Webb (bregma) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdecoration/decoration.c'
2--- libdecoration/decoration.c 2012-09-10 07:42:57 +0000
3+++ libdecoration/decoration.c 2013-01-26 11:28:19 +0000
4@@ -2995,7 +2995,7 @@
5
6 utf8_string_atom = XInternAtom (xdisplay, "UTF8_STRING", 0);
7
8- sprintf (buf, "_COMPIZ_DM_S%d", screen);
9+ snprintf (buf, 128, "_COMPIZ_DM_S%d", screen);
10 dm_sn_atom = XInternAtom (xdisplay, buf, 0);
11
12 current_dm_sn_owner = XGetSelectionOwner (xdisplay, dm_sn_atom);

Subscribers

People subscribed via source and target branches