public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] ubi-utils: fix warning in fprintf() code
@ 2009-01-12 16:08 Mike Frysinger
  2009-01-13  9:07 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2009-01-12 16:08 UTC (permalink / raw)
  To: linux-mtd

When building with gcc security warnings enabled, the ubimirror.c code
triggers this warning:
./src/ubimirror.c: In function 'main':
./src/ubimirror.c:206: error: format not a string literal and no format arguments

Since the buffer in question should be a straight string anyways, avoid
ugly printf exploits by outputting the string indirectly:
	printf("%s", buffer)

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 ubi-utils/src/ubimirror.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ubi-utils/src/ubimirror.c b/ubi-utils/src/ubimirror.c
index 2cc4596..a20e1af 100644
--- a/ubi-utils/src/ubimirror.c
+++ b/ubi-utils/src/ubimirror.c
@@ -203,7 +203,7 @@ main(int argc, char **argv) {
 		       err_buf, sizeof(err_buf));
 	if( rc ){
 		err_buf[sizeof err_buf - 1] = '\0';
-		fprintf(stderr, err_buf);
+		fprintf(stderr, "%s", err_buf);
 		if( rc < 0 )
 			rc = -rc;
 	}
-- 
1.6.1

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

* Re: [PATCH] ubi-utils: fix warning in fprintf() code
  2009-01-12 16:08 [PATCH] ubi-utils: fix warning in fprintf() code Mike Frysinger
@ 2009-01-13  9:07 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2009-01-13  9:07 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-mtd

On Mon, 2009-01-12 at 11:08 -0500, Mike Frysinger wrote:
> When building with gcc security warnings enabled, the ubimirror.c code
> triggers this warning:
> ./src/ubimirror.c: In function 'main':
> ./src/ubimirror.c:206: error: format not a string literal and no format arguments
> 
> Since the buffer in question should be a straight string anyways, avoid
> ugly printf exploits by outputting the string indirectly:
> 	printf("%s", buffer)
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Both patches are applied, thank you!

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

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

end of thread, other threads:[~2009-01-13  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-12 16:08 [PATCH] ubi-utils: fix warning in fprintf() code Mike Frysinger
2009-01-13  9:07 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox