dmx: Fix some snprintf warnings.
snprintf doesn't terminate the string if it truncates, so things like this are lurking crashers: ../hw/dmx/dmxprop.c: In function ‘dmxPropertyIdentifier.part.0’: ../hw/dmx/dmxprop.c:94:36: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 123 [-Wformat-truncation=] snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display); ^~ ~~~~~~~~ ../hw/dmx/dmxprop.c:94:5: note: ‘snprintf’ output 7 or more bytes (assuming 262) into a destination of size 128 snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../hw/dmx/dmxprop.c: In function ‘dmxPropertyWindow’: ../hw/dmx/dmxprop.c:372:36: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 127 [-Wformat-truncation=] snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index); ^~ ../hw/dmx/dmxprop.c:372:5: note: ‘snprintf’ output between 3 and 140 bytes into a destination of size 128 snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We could be more precise about termination, but meh. Signed-off-by: Adam Jackson <ajax@redhat.com> Acked-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
4c1453393f
commit
c3b190f9da
|
@ -84,7 +84,7 @@ dmxPropertyIdentifier(void)
|
|||
/* RATS: These buffers are only used in
|
||||
* length-limited calls. */
|
||||
char hostname[256];
|
||||
static char buf[128];
|
||||
static char buf[512];
|
||||
static int initialized = 0;
|
||||
|
||||
if (initialized++)
|
||||
|
@ -346,7 +346,7 @@ dmxPropertyWindow(DMXScreenInfo * dmxScreen)
|
|||
Display *dpy = dmxScreen->beDisplay;
|
||||
Window win = dmxScreen->scrnWin;
|
||||
DMXScreenInfo *other;
|
||||
char buf[128]; /* RATS: only used with snprintf */
|
||||
char buf[1024]; /* RATS: only used with snprintf */
|
||||
|
||||
if (!dpy)
|
||||
return; /* FIXME: What should be done here if Xdmx is started
|
||||
|
|
Loading…
Reference in New Issue
Block a user