diff options
author | Shaun Ruffell <sruffell@digium.com> | 2009-06-04 21:14:53 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2009-06-04 21:14:53 +0000 |
commit | 11e24b3828139533818137c1a8dbb1ce8d489c27 (patch) | |
tree | b7b8e987ce4624d91cf7f56c4bd02f54f1cb2942 | |
parent | ccfc59e0b37f3ec1ad0d4dbe6d228ffdad159e60 (diff) |
dahdi-base: Fix bug in procfs handling.
Fix bug in procfs handling where it was possible to get a warning in
lib/vsprintf.c when reading from /proc/dahdi/x.
Patch by: biohumanoid
(closes issue #15252)
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@6675 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | drivers/dahdi/dahdi-base.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 4741720..632d0d2 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -552,12 +552,16 @@ static int fill_alarm_string(char *buf, int count, int alarms) static int dahdi_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data) { - int x, len = 0; + int x, len = 0, real_count; long span; - /* In Linux 2.6, this MUST NOT EXECEED 1024 bytes in one read! */ + /* In Linux 2.6, page is always PROC_BLOCK_SIZE=(PAGE_SIZE-1024) bytes. + * 0<count<=PROC_BLOCK_SIZE . count=1 will produce an error in + * vsnprintf ('head -c 1 /proc/dahdi/1', 'dd bs=1'). + * An ugly hack. Good way: seq_printf (seq_file.c). */ + real_count = count; + count = PAGE_SIZE-1024; span = (long)data; - if (!span) return 0; @@ -678,10 +682,14 @@ static int dahdi_proc_read(char *page, char **start, off_t off, int count, int * /* stop if we've already generated enough */ if (len > off + count) break; + /* stop if we're NEAR danger limit. let it be -128 bytes. */ + if (len > count-128) + break; } + count = real_count; /* If everything printed so far is before beginning of request */ if (len <= off) { - off -= len; + off = 0; len = 0; } *start = page + off; |