[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeutils/klaptopdaemon [POSSIBLY UNSAFE]
From:       Claudiu Costin <claudiuc () kde ! org>
Date:       2003-08-19 21:16:36
[Download RAW message or body]

CVS commit by claudiu: 

Toshiba LCD control is now working.
CCMAIL: 62866-done@bugs.kde.org


  M +17 -7     acpi_helper.cpp   1.12 [POSSIBLY UNSAFE: printf]


--- kdeutils/klaptopdaemon/acpi_helper.cpp  #1.11:1.12
@@ -47,4 +47,6 @@
 #include <string.h>
         
+#define MAX_TOSHIBA_STRING 64
+        
 int
 main(int argc, char **argv)
@@ -172,5 +174,4 @@ main(int argc, char **argv)
         } else
         if (strcmp(argv[i], "--toshibalcd") == 0 || strcmp(argv[i], "-toshibalcd") == 0) {
-                char c;
 
                 i++;
@@ -182,11 +183,20 @@ main(int argc, char **argv)
                 if (toshibalcd_val > 7)
                         toshibalcd_val = 7;
-                c = '0'+toshibalcd_val;
                 fd = open("/proc/acpi/TOSHIBA1/lcd", O_RDWR);
-                if (fd < 0)
+                if (fd >= 0 ) {
+                    char c;
+                    
+                    c = '0'+toshibalcd_val;
+                    write(fd, &c, 1);
+                    close(fd);
+                } else {
                         fd = open("/proc/acpi/toshiba/lcd", O_RDWR);
                 if (fd >= 0) {
-                        write(fd, &c, 1);
+                        char str[MAX_TOSHIBA_STRING];
+                        
+                        snprintf(str,MAX_TOSHIBA_STRING-1,"brightness : %d",toshibalcd_val);
+                        write(fd,str,strlen(str));      
                         close(fd);
+                    }
                 }
                 setuid(getuid());       // drop all priority asap


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic