Followed recommendations of Coverity and replaced sprintf () with snprintf ()
with respective buffer sizes.
(LP: #957587, #1101499, #1101565, #1101571, #1101641, #1101605). Fixes: https://bugs.launchpad.net/bugs/957587, https://bugs.launchpad.net/bugs/1101499, https://bugs.launchpad.net/bugs/1101565, https://bugs.launchpad.net/bugs/1101571, https://bugs.launchpad.net/bugs/1101605, https://bugs.launchpad.net/bugs/1101641.
Approved by Sam Spilsbury.