[hackers] [slstatus] Check printf() for output errors || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Tue, 22 May 2018 13:25:58 +0200 (CEST)

commit 9c9ce8a125f35bab61c829bdd58bdf77b8352d5e
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Tue May 22 12:50:43 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Tue May 22 13:25:47 2018 +0200

    Check printf() for output errors
    
    This way cases like
    
            $ slstatus -s > /dev/full
    
    are properly caught and the program terminated with the proper return
    code.

diff --git a/slstatus.c b/slstatus.c
index b3abafb..9bd9e81 100644
--- a/slstatus.c
+++ b/slstatus.c
_AT_@ -102,7 +102,9 @@ main(int argc, char *argv[])
                 }
 
                 if (sflag) {
- printf("%s\n", status);
+ if (printf("%s\n", status) < 0) {
+ die("printf:");
+ }
                 } else {
                         if (XStoreName(dpy, DefaultRootWindow(dpy), status) < 0) {
                                 die("XStoreName: Allocation failed");
Received on Tue May 22 2018 - 13:25:58 CEST

This archive was generated by hypermail 2.3.0 : Tue May 22 2018 - 13:36:23 CEST