astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.03k stars 73 forks source link

Do not dereference garbage pointers in sel_buf (doOut) #121

Open jamesjer opened 3 years ago

jamesjer commented 3 years ago

We've been seeing segfaults in Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1947285. An analysis of the bug is available at that URL. Briefly, sel_buf contains garbage bytes when the while loop is entered, and those bytes can be dereferenced or passed to free().

spotrh commented 3 years ago

Worth noting that this solution solves the problem described in PR #117 , but in a way that doesn't break the pathing where sel_buf has data that needs to be freed.