[alsa-devel] [PATCH TINYCOMPRESS 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.
diff --git a/compress.c b/compress.c index c4f215c..871c19e 100644 --- a/compress.c +++ b/compress.c @@ -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 size return 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)
This patch is now obsolete - an equivalent change has already been submitted. So no rebased version.
participants (1)
-
Richard Fitzgerald