alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH TINYCOMPRESS 5/14] compress: Take local copy of compr_config structure
@ 2013-02-10  0:09 Richard Fitzgerald
  2013-02-22 16:01 ` Richard Fitzgerald
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-10  0:09 UTC (permalink / raw)
  To: vinod.koul; +Cc: alsa-devel

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)
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH TINYCOMPRESS 5/14] compress: Take local copy of compr_config structure
  2013-02-10  0:09 [PATCH TINYCOMPRESS 5/14] compress: Take local copy of compr_config structure Richard Fitzgerald
@ 2013-02-22 16:01 ` Richard Fitzgerald
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-22 16:01 UTC (permalink / raw)
  To: vinod.koul; +Cc: alsa-devel

This patch is now obsolete - an equivalent change has already been submitted.
So no rebased version.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-22 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10  0:09 [PATCH TINYCOMPRESS 5/14] compress: Take local copy of compr_config structure Richard Fitzgerald
2013-02-22 16:01 ` Richard Fitzgerald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).