[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/ksysguard/ksysguardd/Linux
From: John Tapsell <john.tapsell () kdemail ! net>
Date: 2010-01-19 15:38:04
Message-ID: 1263915484.270953.25099.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1077181 by johnflux:
Sanitize disk device names
Some people have device names like "_PNG\r\n" :-/
BUG:222692
BUGCC:206049
M +12 -0 diskstat.c
M +12 -2 diskstats.c
--- trunk/KDE/kdebase/workspace/ksysguard/ksysguardd/Linux/diskstat.c #1077180:1077181
@@ -28,6 +28,7 @@
#include <sys/vfs.h>
#include <time.h>
#include <unistd.h>
+#include <ctype.h>
#include "Command.h"
#include "ccont.h"
@@ -48,6 +49,16 @@
static struct SensorModul* DiskStatSM;
char *getMntPnt( const char* cmd );
+static void sanitize(char *str) {
+ if(str == NULL)
+ return;
+ while (*str != 0) {
+ if(*str == '\t' || *str == '\n' || *str == '\r' || *str == ' ' || !isascii(*str) )
+ *str = '?';
+ ++str;
+ }
+}
+
char *getMntPnt( const char* cmd )
{
static char device[ 1025 ];
@@ -196,6 +207,7 @@
else
strncpy( disk_info->mntpnt, mnt_info->mnt_dir, sizeof( disk_info->mntpnt ) );
disk_info->mntpnt[ sizeof(disk_info->mntpnt) - 1] = 0;
+ sanitize(disk_info->mntpnt);
disk_info->blocks = fs_info.f_blocks;
disk_info->bfree = fs_info.f_bfree;
--- trunk/KDE/kdebase/workspace/ksysguard/ksysguardd/Linux/diskstats.c #1077180:1077181
@@ -30,8 +30,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <ctype.h>
-
#include "Command.h"
#include "ksysguardd.h"
@@ -91,6 +91,16 @@
static void cleanup26DiskList( void );
static int process26DiskIO( const char* buf );
+static void sanitize(char *str) {
+ if(str == NULL)
+ return;
+ while (*str != 0) {
+ if(*str == '\t' || *str == '\n' || *str == '\r' || *str == ' ' || !isascii(*str) )
+ *str = '?';
+ ++str;
+ }
+}
+
void initDiskstats( struct SensorModul* sm ) {
char format[ 32 ];
char buf[ 1024 ];
@@ -154,8 +164,8 @@
while (sscanf(iostatBufP, format, buf) == 1) {
buf[sizeof(buf) - 1] = '\0';
+ sanitize(buf);
iostatBufP += strlen(buf) + 1; /* move IOstatBufP to next line */
-
process26DiskIO(buf);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic