Commit 5e81feda authored by Ben Collins's avatar Ben Collins

[PATCH] More 1394 updates

This incorporates security fixes from Alan that I brought from the
2.4.20-pre9 tree.
parent 8e2cc1ed
...@@ -196,7 +196,7 @@ struct packet_list { ...@@ -196,7 +196,7 @@ struct packet_list {
/* This implements a circular buffer for incoming samples. */ /* This implements a circular buffer for incoming samples. */
struct buffer { struct buffer {
int head, tail, length, size; size_t head, tail, length, size;
unsigned char data[0]; unsigned char data[0];
}; };
...@@ -623,9 +623,9 @@ static unsigned char *buffer_get_bytes(struct buffer *buffer, int size) ...@@ -623,9 +623,9 @@ static unsigned char *buffer_get_bytes(struct buffer *buffer, int size)
} }
static unsigned char *buffer_put_bytes(struct buffer *buffer, static unsigned char *buffer_put_bytes(struct buffer *buffer,
int max, int *actual) size_t max, size_t *actual)
{ {
int length; size_t length;
unsigned char *p; unsigned char *p;
p = &buffer->data[buffer->tail]; p = &buffer->data[buffer->tail];
...@@ -1089,7 +1089,8 @@ static ssize_t amdtp_write(struct file *file, const char *buffer, size_t count, ...@@ -1089,7 +1089,8 @@ static ssize_t amdtp_write(struct file *file, const char *buffer, size_t count,
{ {
struct stream *s = file->private_data; struct stream *s = file->private_data;
unsigned char *p; unsigned char *p;
int i, length; int i;
size_t length;
if (s->packet_pool == NULL) if (s->packet_pool == NULL)
return -EBADFD; return -EBADFD;
......
...@@ -2139,7 +2139,7 @@ static int dv1394_procfs_write( struct file *file, ...@@ -2139,7 +2139,7 @@ static int dv1394_procfs_write( struct file *file,
const char *buffer, unsigned long count, void *data) const char *buffer, unsigned long count, void *data)
{ {
int len = 0; int len = 0;
char new_value[64]; char new_value[65];
char *pos; char *pos;
struct video_card *video = (struct video_card*) data; struct video_card *video = (struct video_card*) data;
...@@ -2151,11 +2151,12 @@ static int dv1394_procfs_write( struct file *file, ...@@ -2151,11 +2151,12 @@ static int dv1394_procfs_write( struct file *file,
if (copy_from_user( new_value, buffer, len)) if (copy_from_user( new_value, buffer, len))
return -EFAULT; return -EFAULT;
new_value[len] = 0;
pos = strchr(new_value, '='); pos = strchr(new_value, '=');
if (pos != NULL) { if (pos != NULL) {
int val_len = len - (pos-new_value) - 1; int val_len = len - (pos-new_value) - 1;
char buf[64]; char buf[65];
memset(buf, 0, 64); memset(buf, 0, 65);
strncpy(buf, pos+1, val_len); strncpy(buf, pos+1, val_len);
if (buf[val_len-1] == '\n') buf[val_len-1] = 0; if (buf[val_len-1] == '\n') buf[val_len-1] = 0;
......
...@@ -887,13 +887,14 @@ static ssize_t mem_read(struct file *file, char *buffer, size_t count, ...@@ -887,13 +887,14 @@ static ssize_t mem_read(struct file *file, char *buffer, size_t count,
struct memdata *md = (struct memdata *)file->private_data; struct memdata *md = (struct memdata *)file->private_data;
ssize_t bcount; ssize_t bcount;
size_t alignfix; size_t alignfix;
int off = (int)*offset; /* avoid useless 64bit-arithmetic */ loff_t off = *offset; /* avoid useless 64bit-arithmetic */
ssize_t retval; ssize_t retval;
void *membase; void *membase;
if (*offset != off) /* Check for EOF before we trust wrap */ if (*offset != off) /* Check for EOF before we trust wrap */
return 0; return 0;
/* FIXME: Signed wrap is undefined in C - wants fixing up */
if (off + count > off) if (off + count > off)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment