From 05d8a7f7a785eff3292f0f0537bb3902930f1b5c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 29 Oct 2011 11:08:17 -0700 Subject: Convert a bunch of sprintf to snprintf calls This batch is the straightforward set - others are more complex and need more analysis to determine right size to pass. Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- hw/dmx/examples/ev.c | 4 ++-- hw/dmx/glxProxy/glxscreens.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'hw/dmx') diff --git a/hw/dmx/examples/ev.c b/hw/dmx/examples/ev.c index ba45c2b25..ed23b8aa9 100644 --- a/hw/dmx/examples/ev.c +++ b/hw/dmx/examples/ev.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) #define test_bit(bit) (mask[(bit)/8] & (1 << ((bit)%8))) for (i = 0; i < 32; i++) { - sprintf(name, "/dev/input/event%d", i); + snprintf(name, sizeof(name), "/dev/input/event%d", i); if ((fd = open(name, O_RDONLY, 0)) >= 0) { ioctl(fd, EVIOCGVERSION, &version); ioctl(fd, EVIOCGNAME(sizeof(buf)), buf); @@ -92,7 +92,7 @@ int main(int argc, char **argv) } if (argc > 1) { - sprintf(name, "/dev/input/event%d", atoi(argv[1])); + snprintf(name, sizeof(name), "/dev/input/event%d", atoi(argv[1])); if ((fd = open(name, O_RDWR, 0)) >= 0) { printf("%s: open, fd = %d\n", name, fd); for (i = 0; i < LED_MAX; i++) { diff --git a/hw/dmx/glxProxy/glxscreens.c b/hw/dmx/glxProxy/glxscreens.c index 01e041c8f..baa4a65a7 100644 --- a/hw/dmx/glxProxy/glxscreens.c +++ b/hw/dmx/glxProxy/glxscreens.c @@ -120,8 +120,9 @@ static void CalcServerVersionAndExtensions( void ) __glXVersionMinor = GLX_SERVER_MINOR_VERSION; } - sprintf(GLXServerVersion, "%d.%d DMX %d back-end server(s)", - __glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens ); + snprintf(GLXServerVersion, sizeof(GLXServerVersion), + "%d.%d DMX %d back-end server(s)", + __glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens ); /* * set the ExtensionsString to the minimum extensions string */ -- cgit v1.2.3