chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bootchart: fix a potential buffer overrun
[elogind.git]
/
src
/
bootchart
/
store.c
diff --git
a/src/bootchart/store.c
b/src/bootchart/store.c
index 0253ebb5af0af277dc1024f785cf1806913df379..b2652c8d936fc0145cf274502308de102e5815be 100644
(file)
--- a/
src/bootchart/store.c
+++ b/
src/bootchart/store.c
@@
-34,6
+34,7
@@
#include <time.h>
#include "util.h"
#include <time.h>
#include "util.h"
+#include "strxcpyx.h"
#include "store.h"
#include "bootchart.h"
#include "store.h"
#include "bootchart.h"
@@
-89,7
+90,7
@@
static char *bufgetline(char *buf) {
return c;
}
return c;
}
-static int pid_cmdline_str
ncpy(char *buffer, int pid, size_t buf_len
) {
+static int pid_cmdline_str
scpy(char *buffer, size_t buf_len, int pid
) {
char filename[PATH_MAX];
int _cleanup_close_ fd=-1;
ssize_t n;
char filename[PATH_MAX];
int _cleanup_close_ fd=-1;
ssize_t n;
@@
-113,7
+114,7
@@
static int pid_cmdline_strncpy(char *buffer, int pid, size_t buf_len) {
void log_sample(int sample) {
static int vmstat;
static int schedstat;
void log_sample(int sample) {
static int vmstat;
static int schedstat;
- char buf[409
5
];
+ char buf[409
6
];
char key[256];
char val[256];
char rt[256];
char key[256];
char val[256];
char rt[256];
@@
-286,11
+287,11
@@
schedstat_next:
if (!sscanf(buf, "%s %*s %*s", key))
continue;
if (!sscanf(buf, "%s %*s %*s", key))
continue;
- str
ncpy(ps->name, key, 256
);
+ str
scpy(ps->name, sizeof(ps->name), key
);
/* cmdline */
if (arg_show_cmdline)
/* cmdline */
if (arg_show_cmdline)
- pid_cmdline_str
ncpy(ps->name, pid, 256
);
+ pid_cmdline_str
scpy(ps->name, sizeof(ps->name), pid
);
/* discard line 2 */
m = bufgetline(buf);
/* discard line 2 */
m = bufgetline(buf);
@@
-449,11
+450,11
@@
catch_rename:
if (!sscanf(buf, "%s %*s %*s", key))
continue;
if (!sscanf(buf, "%s %*s %*s", key))
continue;
- str
ncpy(ps->name, key, 256
);
+ str
scpy(ps->name, sizeof(ps->name), key
);
/* cmdline */
if (arg_show_cmdline)
/* cmdline */
if (arg_show_cmdline)
- pid_cmdline_str
ncpy(ps->name, pid, 256
);
+ pid_cmdline_str
scpy(ps->name, sizeof(ps->name), pid
);
}
}
}
}
}
}