compress: Take local copy of compr_config structure
PATCH 5/14 compress: Take local copy of compr_config structure
Take a copy of the compr_config structure passed by the client. This allows the client to use a structure in temporary memory and avoids the possibility that tinycompress can be broken by the client changing the content of its compr_config.
compress.c +4 -3
@@ -81,7 +81,7 @@ struct compress {int fd;unsigned int flags;char error[COMPR_ERR_MAX ]; -struct compr_config *config; +struct compr_config config;int running; };
@@ -209,7 +209,8 @@ struct compress *compress_open(unsigned int card, unsigned int device,if (!compress || !config)return &bad_compress; - compress->config = config; +/* take a local copy of config */ + compress->config = *config;snprintf (fn,sizeof (fn),"/dev/snd/comprC%uD%u" , card, device);
@@ -319,7 +320,7 @@ int compress_write(struct compress *compress, const void *buf, unsigned int sizereturn oops (compress, errno,"cannot get avail" );/* we will write only when avail > fragment size */ -if (avail.avail < compress->config->fragment_size) { +if (avail.avail < compress->config.fragment_size) {/* nothing to write so wait for 10secs */ ret =poll (&fds,1 ,1000000 );if (ret <0 )
Signature · 1 line
1.7.2.5
This patch is now obsolete - an equivalent change has already been submitted. So no rebased version.