summaryrefslogtreecommitdiff
path: root/src/rc/rc-logger.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-07 12:29:30 +0000
committerRoy Marples <roy@marples.name>2008-01-07 12:29:30 +0000
commit43d0f3fc76542d0859c9b84402c0483a22e02b68 (patch)
tree125bcc9bf644a6390718868312df2b6be1905e89 /src/rc/rc-logger.c
parent74e0e58b899accd2bd72a7d7303331e47089959f (diff)
downloadopenrc-43d0f3fc76542d0859c9b84402c0483a22e02b68.tar.gz
openrc-43d0f3fc76542d0859c9b84402c0483a22e02b68.tar.bz2
openrc-43d0f3fc76542d0859c9b84402c0483a22e02b68.tar.xz
rc_getline keeps expanding it's malloced buffer until it has read a whole line or EOF. All functions which read into static buffers have been changed to use fhis function to avoid any potential overflows and to ensure we really do read a long long config line.
Diffstat (limited to 'src/rc/rc-logger.c')
-rw-r--r--src/rc/rc-logger.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index 675a4d2..f4c610a 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -181,12 +181,12 @@ void rc_logger_open (const char *level)
write_time (log, "started");
else {
free (logbuf);
- logbuf_size = RC_LINEBUFFER * 10;
+ logbuf_size = BUFSIZ * 10;
logbuf = xmalloc (sizeof (char) * logbuf_size);
logbuf_len = 0;
}
- buffer = xmalloc (sizeof (char) * RC_LINEBUFFER);
+ buffer = xmalloc (sizeof (char) * BUFSIZ);
selfd = rc_logger_tty > signal_pipe[0] ? rc_logger_tty : signal_pipe[0];
while (1) {
FD_ZERO (&rset);
@@ -200,15 +200,15 @@ void rc_logger_open (const char *level)
if (s > 0) {
if (FD_ISSET (rc_logger_tty, &rset)) {
- memset (buffer, 0, RC_LINEBUFFER);
- bytes = read (rc_logger_tty, buffer, RC_LINEBUFFER);
+ memset (buffer, 0, BUFSIZ);
+ bytes = read (rc_logger_tty, buffer, BUFSIZ);
write (STDOUT_FILENO, buffer, bytes);
if (log)
write_log (fileno (log), buffer, bytes);
else {
if (logbuf_size - logbuf_len < bytes) {
- logbuf_size += RC_LINEBUFFER * 10;
+ logbuf_size += BUFSIZ * 10;
logbuf = xrealloc (logbuf, sizeof (char ) *
logbuf_size);
}