don't make up buffer sizes, use standard LINE_MAX instead

This commit is contained in:
Lennart Poettering 2011-04-07 18:48:50 +02:00
parent f68319bbb8
commit 20c03b7be2
7 changed files with 14 additions and 15 deletions

View File

@ -218,7 +218,7 @@ static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_exec_output, exec_outp
static int bus_manager_append_tainted(Manager *m, DBusMessageIter *i, const char *property, void *data) { static int bus_manager_append_tainted(Manager *m, DBusMessageIter *i, const char *property, void *data) {
const char *t; const char *t;
char buf[64] = "", *e = buf, *p = NULL; char buf[LINE_MAX] = "", *e = buf, *p = NULL;
assert(m); assert(m);
assert(i); assert(i);

View File

@ -2681,7 +2681,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
m->n_deserializing ++; m->n_deserializing ++;
for (;;) { for (;;) {
char line[1024], *l; char line[LINE_MAX], *l;
if (!fgets(line, sizeof(line), f)) { if (!fgets(line, sizeof(line), f)) {
if (feof(f)) if (feof(f))

View File

@ -134,7 +134,7 @@ static int mount_one(const MountPoint *p) {
static int mount_cgroup_controllers(void) { static int mount_cgroup_controllers(void) {
int r; int r;
FILE *f; FILE *f;
char buf [256]; char buf[LINE_MAX];
/* Mount all available cgroup controllers that are built into the kernel. */ /* Mount all available cgroup controllers that are built into the kernel. */

View File

@ -209,7 +209,6 @@ finish:
return m; return m;
} }
#define BUMP_REQUEST_NR (16*1024) #define BUMP_REQUEST_NR (16*1024)
int bump_request_nr(const char *p) { int bump_request_nr(const char *p) {

View File

@ -2152,7 +2152,7 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
return 0; return 0;
for (;;) { for (;;) {
char line[1024], *l, *v; char line[LINE_MAX], *l, *v;
size_t k; size_t k;
if (!fgets(line, sizeof(line), f)) { if (!fgets(line, sizeof(line), f)) {

View File

@ -452,7 +452,7 @@ char **split_path_and_make_absolute(const char *p) {
int get_parent_of_pid(pid_t pid, pid_t *_ppid) { int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
int r; int r;
FILE *f; FILE *f;
char fn[132], line[256], *p; char fn[PATH_MAX], line[LINE_MAX], *p;
long unsigned ppid; long unsigned ppid;
assert(pid >= 0); assert(pid >= 0);
@ -2063,7 +2063,7 @@ int chvt(int vt) {
int read_one_char(FILE *f, char *ret, bool *need_nl) { int read_one_char(FILE *f, char *ret, bool *need_nl) {
struct termios old_termios, new_termios; struct termios old_termios, new_termios;
char c; char c;
char line[1024]; char line[LINE_MAX];
assert(f); assert(f);
assert(ret); assert(ret);
@ -2271,7 +2271,7 @@ int flush_fd(int fd) {
pollfd.events = POLLIN; pollfd.events = POLLIN;
for (;;) { for (;;) {
char buf[1024]; char buf[LINE_MAX];
ssize_t l; ssize_t l;
int r; int r;
@ -2897,7 +2897,7 @@ int getttyname_harder(int fd, char **r) {
int get_ctty_devnr(dev_t *d) { int get_ctty_devnr(dev_t *d) {
int k; int k;
char line[256], *p; char line[LINE_MAX], *p;
unsigned long ttynr; unsigned long ttynr;
FILE *f; FILE *f;
@ -2932,7 +2932,7 @@ int get_ctty_devnr(dev_t *d) {
int get_ctty(char **r, dev_t *_devnr) { int get_ctty(char **r, dev_t *_devnr) {
int k; int k;
char fn[128], *s, *b, *p; char fn[PATH_MAX], *s, *b, *p;
dev_t devnr; dev_t devnr;
assert(r); assert(r);