summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exa/exa_render.c6
-rw-r--r--hw/dmx/examples/ev.c4
-rw-r--r--hw/dmx/glxProxy/glxscreens.c5
-rw-r--r--hw/kdrive/ephyr/ephyrhostvideo.c9
-rw-r--r--hw/kdrive/linux/linux.c2
-rw-r--r--hw/vfb/InitOutput.c3
-rw-r--r--hw/xfree86/common/xf86Option.c6
-rw-r--r--hw/xfree86/common/xf86sbusBus.c2
-rw-r--r--hw/xfree86/fbdevhw/fbdevhw.c6
-rw-r--r--hw/xfree86/os-support/bsd/bsd_init.c10
-rw-r--r--hw/xfree86/os-support/bus/Sbus.c12
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c2
-rw-r--r--hw/xfree86/x86emu/debug.c2
-rw-r--r--os/connection.c4
-rw-r--r--os/osinit.c2
-rw-r--r--os/rpcauth.c7
-rw-r--r--os/utils.c4
-rw-r--r--os/xdmcp.c4
-rw-r--r--randr/rrinfo.c2
-rw-r--r--xkb/xkbtext.c142
20 files changed, 119 insertions, 115 deletions
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 6f2af8a8f..3974afe87 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -103,13 +103,13 @@ exaPrintCompositeFallback(CARD8 op,
switch(op)
{
case PictOpSrc:
- sprintf(sop, "Src");
+ snprintf(sop, sizeof(sop), "Src");
break;
case PictOpOver:
- sprintf(sop, "Over");
+ snprintf(sop, sizeof(sop), "Over");
break;
default:
- sprintf(sop, "0x%x", (int)op);
+ snprintf(sop, sizeof(sop), "0x%x", (int)op);
break;
}
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
*/
diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c
index 600b50f74..69ad8a517 100644
--- a/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -140,7 +140,7 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
mesg, BUFSIZ);
(void) fprintf(a_fp, mesg, a_err_event->request_code);
if (a_err_event->request_code < 128) {
- sprintf(number, "%d", a_err_event->request_code);
+ snprintf(number, sizeof(number), "%d", a_err_event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
} else {
for (ext = dpy->ext_procs;
@@ -159,7 +159,8 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
fputs(" ", a_fp);
(void) fprintf(a_fp, mesg, a_err_event->minor_code);
if (ext) {
- sprintf(mesg, "%s.%d", ext->name, a_err_event->minor_code);
+ snprintf(mesg, sizeof(mesg), "%s.%d",
+ ext->name, a_err_event->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
(void) fprintf(a_fp, " (%s)", buffer);
}
@@ -182,8 +183,8 @@ ephyrHostXVLogXErrorEvent (Display *a_display,
bext = ext;
}
if (bext)
- sprintf(buffer, "%s.%d", bext->name,
- a_err_event->error_code - bext->codes.first_error);
+ snprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
+ a_err_event->error_code - bext->codes.first_error);
else
strcpy(buffer, "Value");
XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index a53db4965..194e7cd59 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -109,7 +109,7 @@ LinuxInit (void)
close(fd);
}
- sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
+ snprintf(vtname,sizeof(vtname),"/dev/tty%d",vtno); /* /dev/tty1-64 */
if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
{
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 121854781..3e5d05100 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -560,7 +560,8 @@ vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb)
char dummyBuffer[DUMMY_BUFFER_SIZE];
int currentFileSize, writeThisTime;
- sprintf(pvfb->mmap_file, "%s/Xvfb_screen%d", pfbdir, (int) (pvfb - vfbScreens));
+ snprintf(pvfb->mmap_file, sizeof(pvfb->mmap_file), "%s/Xvfb_screen%d",
+ pfbdir, (int) (pvfb - vfbScreens));
if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT|O_RDWR, 0666)))
{
perror("open");
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 9c528782f..d1d74f5a5 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -306,7 +306,7 @@ XF86OptionPtr
xf86ReplaceIntOption(XF86OptionPtr optlist, const char *name, const int val)
{
char tmp[16];
- sprintf(tmp,"%i",val);
+ snprintf(tmp,sizeof(tmp),"%i",val);
return xf86AddNewOption(optlist,name,tmp);
}
@@ -314,7 +314,7 @@ XF86OptionPtr
xf86ReplaceRealOption(XF86OptionPtr optlist, const char *name, const double val)
{
char tmp[32];
- snprintf(tmp,32,"%f",val);
+ snprintf(tmp,sizeof(tmp),"%f",val);
return xf86AddNewOption(optlist,name,tmp);
}
@@ -328,7 +328,7 @@ XF86OptionPtr
xf86ReplacePercentOption(XF86OptionPtr optlist, const char *name, const double val)
{
char tmp[16];
- sprintf(tmp, "%lf%%", val);
+ snprintf(tmp, sizeof(tmp), "%lf%%", val);
return xf86AddNewOption(optlist,name,tmp);
}
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index 181c6ab00..b7bb913fe 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -88,7 +88,7 @@ xf86SbusProbe(void)
xf86SbusInfo = malloc(sizeof(psdp));
*xf86SbusInfo = NULL;
for (i = 0; i < 32; i++) {
- sprintf(fbDevName, "/dev/fb%d", i);
+ snprintf(fbDevName, sizeof(fbDevName), "/dev/fb%d", i);
CheckSbusDevice(fbDevName, i);
}
if (sparcPromInit() >= 0) {
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 30a2a9133..d7b4d3c20 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -265,20 +265,20 @@ fbdev_open_pci(struct pci_device * pPci, char **namep)
int fd, i;
for (i = 0; i < 8; i++) {
- sprintf(filename,
+ snprintf(filename, sizeof(filename),
"/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
fd = open(filename, O_RDONLY, 0);
if (fd < 0) {
- sprintf(filename,
+ snprintf(filename, sizeof(filename),
"/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
fd = open(filename, O_RDONLY, 0);
}
if (fd >= 0) {
close(fd);
- sprintf(filename, "/dev/fb%d", i);
+ snprintf(filename, sizeof(filename), "/dev/fb%d", i);
fd = open(filename, O_RDWR, 0);
if (fd != -1) {
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index b58d6a790..7079d62b4 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -446,7 +446,7 @@ xf86OpenSyscons()
}
close(fd);
- sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
+ snprintf(vtname, sizeof(vtname), "/dev/ttyv%01x", xf86Info.vtno - 1);
if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
{
FatalError("xf86OpenSyscons: Cannot open %s (%s)",
@@ -550,13 +550,13 @@ xf86OpenPcvt()
}
close(fd);
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1);
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
{
ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
vtname, strerror(errno));
xf86Info.vtno = initialVT;
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1);
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
FatalError("xf86OpenPcvt: Cannot open %s (%s)",
vtname, strerror(errno));
@@ -602,9 +602,9 @@ xf86OpenWScons()
/* XXX Is this ok? */
for (i = 0; i < 8; i++) {
#if defined(__NetBSD__)
- sprintf(ttyname, "/dev/ttyE%d", i);
+ snprintf(ttyname, sizeof(ttyname), "/dev/ttyE%d", i);
#elif defined(__OpenBSD__)
- sprintf(ttyname, "/dev/ttyC%x", i);
+ snprintf(ttyname, sizeof(ttyname), "/dev/ttyC%x", i);
#endif
if ((fd = open(ttyname, 2)) != -1)
break;
diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c
index 7829d803f..c02d2cd55 100644
--- a/hw/xfree86/os-support/bus/Sbus.c
+++ b/hw/xfree86/os-support/bus/Sbus.c
@@ -446,14 +446,14 @@ promGetReg(int type)
if (prop && len >= 4) {
unsigned int *reg = (unsigned int *)prop;
if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS))
- sprintf (regstr, "@%x,%x", reg[0], reg[1]);
+ snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], reg[1]);
else if (type == PROM_NODE_PCI) {
if ((reg[0] >> 8) & 7)
- sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
+ snprintf (regstr, sizeof(regstr), "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7);
else
- sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f);
+ snprintf (regstr, sizeof(regstr), "@%x", (reg[0] >> 11) & 0x1f);
} else if (len == 4)
- sprintf (regstr, "@%x", reg[0]);
+ snprintf (regstr, sizeof(regstr), "@%x", reg[0]);
else {
unsigned int regs[2];
@@ -465,9 +465,9 @@ promGetReg(int type)
prop = promGetProperty("upa-portid", &len);
if (prop && len == 4) {
reg = (unsigned int *)prop;
- sprintf (regstr, "@%x,%x", reg[0], regs[1]);
+ snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], regs[1]);
} else
- sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]);
+ snprintf (regstr, sizeof(regstr), "@%x,%x", regs[0] >> 4, regs[1]);
}
}
return regstr;
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index f18271f38..5f3e3a9fb 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -146,7 +146,7 @@ xf86OpenConsole(void)
i=0;
while (vcs[i] != NULL) {
- sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
break;
i++;
diff --git a/hw/xfree86/x86emu/debug.c b/hw/xfree86/x86emu/debug.c
index 5eda90805..04d0741e0 100644
--- a/hw/xfree86/x86emu/debug.c
+++ b/hw/xfree86/x86emu/debug.c
@@ -172,7 +172,7 @@ void x86emu_decode_printf (char *x)
void x86emu_decode_printf2 (char *x, int y)
{
char temp[100];
- sprintf(temp,x,y);
+ snprintf(temp,sizeof(temp),x,y);
sprintf(M.x86.decoded_buf+M.x86.enc_str_pos,"%s",temp);
M.x86.enc_str_pos += strlen(temp);
}
diff --git a/os/connection.c b/os/connection.c
index 957b928dd..c5fc5a07e 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -386,7 +386,7 @@ CreateWellKnownSockets(void)
FD_ZERO (&WellKnownConnections);
- sprintf (port, "%d", atoi (display));
+ snprintf (port, sizeof(port), "%d", atoi (display));
if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial,
&ListenTransCount, &ListenTransConns) >= 0) &&
@@ -1266,7 +1266,7 @@ void ListenOnOpenFD(int fd, int noxauth) {
strcpy(port, display_env);
} else {
/* Just some default so things don't break and die. */
- sprintf(port, ":%d", atoi(display));
+ snprintf(port, sizeof(port), ":%d", atoi(display));
}
/* Make our XtransConnInfo
diff --git a/os/osinit.c b/os/osinit.c
index 45d202def..acea682ce 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -213,7 +213,7 @@ OsInit(void)
FILE *err;
if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
- sprintf (fname, ADMPATH, display);
+ snprintf (fname, sizeof(fname), ADMPATH, display);
else
strcpy (fname, devnull);
/*
diff --git a/os/rpcauth.c b/os/rpcauth.c
index ad6ebf986..989a49a06 100644
--- a/os/rpcauth.c
+++ b/os/rpcauth.c
@@ -137,13 +137,14 @@ SecureRPCCheck (unsigned short data_length, const char *data,
} else {
fullname = authdes_ezdecode(data, data_length);
if (fullname == (char *)0) {
- sprintf(rpc_error, "Unable to authenticate secure RPC client (why=%d)", why);
+ snprintf(rpc_error, sizeof(rpc_error),
+ "Unable to authenticate secure RPC client (why=%d)", why);
*reason = rpc_error;
} else {
if (ForEachHostInFamily (FamilyNetname, CheckNetName, fullname))
return rpc_id;
- sprintf(rpc_error, "Principal \"%s\" is not authorized to connect",
- fullname);
+ snprintf(rpc_error, sizeof(rpc_error),
+ "Principal \"%s\" is not authorized to connect", fullname);
*reason = rpc_error;
}
}
diff --git a/os/utils.c b/os/utils.c
index 1c75dfce4..c828f01d9 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -258,7 +258,7 @@ LockServer(void)
*/
tmppath = LOCK_DIR;
- sprintf(port, "%d", atoi(display));
+ snprintf(port, sizeof(port), "%d", atoi(display));
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
strlen(LOCK_TMP_PREFIX);
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
@@ -295,7 +295,7 @@ LockServer(void)
}
if (lfd < 0)
FatalError("Could not create lock file in %s\n", tmp);
- (void) sprintf(pid_str, "%10ld\n", (long)getpid());
+ snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long)getpid());
(void) write(lfd, pid_str, 11);
(void) fchmod(lfd, 0444);
(void) close(lfd);
diff --git a/os/xdmcp.c b/os/xdmcp.c
index f5331e1b9..46440718c 100644
--- a/os/xdmcp.c
+++ b/os/xdmcp.c
@@ -1489,7 +1489,7 @@ get_addr_by_name(
if (port == 0) {
pport = NULL;
} else if (port > 0 && port < 65535) {
- sprintf(portstr, "%d", port);
+ snprintf(portstr, sizeof(portstr), "%d", port);
} else {
FatalError("Xserver: port out of range: %d\n", port);
}
@@ -1612,7 +1612,7 @@ get_mcast_options(int argc, char **argv, int i)
}
if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
- sprintf(portstr, "%d", xdm_udp_port);
+ snprintf(portstr, sizeof(portstr), "%d", xdm_udp_port);
} else {
FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
}
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index fdf372607..02aea5245 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -35,7 +35,7 @@ RROldModeAdd (RROutputPtr output, RRScreenSizePtr size, int refresh)
RRModePtr *modes;
memset (&modeInfo, '\0', sizeof (modeInfo));
- sprintf (name, "%dx%d", size->width, size->height);
+ snprintf (name, sizeof(name), "%dx%d", size->width, size->height);
modeInfo.width = size->width;
modeInfo.height = size->height;
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index b3930f895..80348c785 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -119,7 +119,7 @@ char numBuf[20];
else if (vmodNames&&(vmodNames[ndx]!=None))
tmp= NameForAtom(vmodNames[ndx]);
if (tmp==NULL) {
- sprintf(numBuf,"%d",ndx);
+ snprintf(numBuf,sizeof(numBuf),"%d",ndx);
tmp = numBuf;
}
@@ -227,17 +227,17 @@ char buf[100];
if (format==XkbCFile) {
if (ndx<XkbNumModifiers)
- sprintf(buf,"%sMapIndex",modNames[ndx]);
+ snprintf(buf,sizeof(buf),"%sMapIndex",modNames[ndx]);
else if (ndx==XkbNoModifier)
- sprintf(buf,"XkbNoModifier");
- else sprintf(buf,"0x%02x",ndx);
+ snprintf(buf,sizeof(buf),"XkbNoModifier");
+ else snprintf(buf,sizeof(buf),"0x%02x",ndx);
}
else {
if (ndx<XkbNumModifiers)
strcpy(buf,modNames[ndx]);
else if (ndx==XkbNoModifier)
strcpy(buf,"none");
- else sprintf(buf,"ILLEGAL_%02x",ndx);
+ else snprintf(buf,sizeof(buf),"ILLEGAL_%02x",ndx);
}
rtrn= tbGetBuffer(strlen(buf)+1);
strcpy(rtrn,buf);
@@ -338,7 +338,7 @@ static char buf[32];
if (sym==NoSymbol)
strcpy(buf,"NoSymbol");
- else sprintf(buf, "0x%lx", (long)sym);
+ else snprintf(buf, sizeof(buf), "0x%lx", (long)sym);
return buf;
}
@@ -383,13 +383,13 @@ char *rtrn;
case XkbSI_AnyOf: rtrn= siMatchText[2]; break;
case XkbSI_AllOf: rtrn= siMatchText[3]; break;
case XkbSI_Exactly: rtrn= siMatchText[4]; break;
- default: sprintf(buf,"0x%x",type&XkbSI_OpMask);
+ default: snprintf(buf,sizeof(buf),"0x%x",type&XkbSI_OpMask);
return buf;
}
if (format==XkbCFile) {
if (type&XkbSI_LevelOneOnly)
- sprintf(buf,"XkbSI_LevelOneOnly|XkbSI_%s",rtrn);
- else sprintf(buf,"XkbSI_%s",rtrn);
+ snprintf(buf,sizeof(buf),"XkbSI_LevelOneOnly|XkbSI_%s",rtrn);
+ else snprintf(buf,sizeof(buf),"XkbSI_%s",rtrn);
rtrn= buf;
}
return rtrn;
@@ -640,12 +640,12 @@ char *rtrn;
if (type<=XkbSA_LastAction) {
rtrn= actionTypeNames[type];
if (format==XkbCFile) {
- sprintf(buf,"XkbSA_%s",rtrn);
+ snprintf(buf,sizeof(buf),"XkbSA_%s",rtrn);
return buf;
}
return rtrn;
}
- sprintf(buf,"Private");
+ snprintf(buf,sizeof(buf),"Private");
return buf;
}
@@ -712,10 +712,10 @@ char tbuf[32];
act= &action->group;
TryCopyStr(buf,"group=",sz);
if (act->flags&XkbSA_GroupAbsolute)
- sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act)+1);
else if (XkbSAGroup(act)<0)
- sprintf(tbuf,"%d",XkbSAGroup(act));
- else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAGroup(act));
TryCopyStr(buf,tbuf,sz);
if (act->type==XkbSA_LockGroup)
return TRUE;
@@ -738,13 +738,13 @@ char tbuf[32];
x= XkbPtrActionX(act);
y= XkbPtrActionY(act);
if ((act->flags&XkbSA_MoveAbsoluteX)||(x<0))
- sprintf(tbuf,"x=%d",x);
- else sprintf(tbuf,"x=+%d",x);
+ snprintf(tbuf,sizeof(tbuf),"x=%d",x);
+ else snprintf(tbuf,sizeof(tbuf),"x=+%d",x);
TryCopyStr(buf,tbuf,sz);
if ((act->flags&XkbSA_MoveAbsoluteY)||(y<0))
- sprintf(tbuf,",y=%d",y);
- else sprintf(tbuf,",y=+%d",y);
+ snprintf(tbuf,sizeof(tbuf),",y=%d",y);
+ else snprintf(tbuf,sizeof(tbuf),",y=+%d",y);
TryCopyStr(buf,tbuf,sz);
if (act->flags&XkbSA_NoAcceleration)
TryCopyStr(buf,",!accel",sz);
@@ -761,12 +761,12 @@ char tbuf[32];
act= &action->btn;
TryCopyStr(buf,"button=",sz);
if ((act->button>0)&&(act->button<6)) {
- sprintf(tbuf,"%d",act->button);
+ snprintf(tbuf,sizeof(tbuf),"%d",act->button);
TryCopyStr(buf,tbuf,sz);
}
else TryCopyStr(buf,"default",sz);
if (act->count>0) {
- sprintf(tbuf,",count=%d",act->count);
+ snprintf(tbuf,sizeof(tbuf),",count=%d",act->count);
TryCopyStr(buf,tbuf,sz);
}
if (action->type==XkbSA_LockPtrBtn) {
@@ -797,8 +797,8 @@ char tbuf[32];
if (act->affect==XkbSA_AffectDfltBtn) {
TryCopyStr(buf,"affect=button,button=",sz);
if ((act->flags&XkbSA_DfltBtnAbsolute)||(XkbSAPtrDfltValue(act)<0))
- sprintf(tbuf,"%d",XkbSAPtrDfltValue(act));
- else sprintf(tbuf,"+%d",XkbSAPtrDfltValue(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAPtrDfltValue(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAPtrDfltValue(act));
TryCopyStr(buf,tbuf,sz);
}
return TRUE;
@@ -814,10 +814,10 @@ char tbuf[64];
if (act->flags&XkbSA_ISODfltIsGroup) {
TryCopyStr(tbuf,"group=",sz);
if (act->flags&XkbSA_GroupAbsolute)
- sprintf(tbuf,"%d",XkbSAGroup(act)+1);
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act)+1);
else if (XkbSAGroup(act)<0)
- sprintf(tbuf,"%d",XkbSAGroup(act));
- else sprintf(tbuf,"+%d",XkbSAGroup(act));
+ snprintf(tbuf,sizeof(tbuf),"%d",XkbSAGroup(act));
+ else snprintf(tbuf,sizeof(tbuf),"+%d",XkbSAGroup(act));
TryCopyStr(buf,tbuf,sz);
}
else {
@@ -847,17 +847,17 @@ char tbuf[64];
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectGroup)==0) {
- sprintf(tbuf,"%sgroups",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sgroups",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectPtr)==0) {
- sprintf(tbuf,"%spointer",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%spointer",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if ((act->affect&XkbSA_ISONoAffectCtrls)==0) {
- sprintf(tbuf,"%scontrols",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%scontrols",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
@@ -875,8 +875,8 @@ char tbuf[32];
act= &action->screen;
if ((act->flags&XkbSA_SwitchAbsolute)||(XkbSAScreen(act)<0))
- sprintf(tbuf,"screen=%d",XkbSAScreen(act));
- else sprintf(tbuf,"screen=+%d",XkbSAScreen(act));
+ snprintf(tbuf,sizeof(tbuf),"screen=%d",XkbSAScreen(act));
+ else snprintf(tbuf,sizeof(tbuf),"screen=+%d",XkbSAScreen(act));
TryCopyStr(buf,tbuf,sz);
if (act->flags&XkbSA_SwitchApplication)
TryCopyStr(buf,",!same",sz);
@@ -903,67 +903,67 @@ char tbuf[32];
else {
int nOut= 0;
if (tmp&XkbRepeatKeysMask) {
- sprintf(tbuf,"%sRepeatKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sRepeatKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbSlowKeysMask) {
- sprintf(tbuf,"%sSlowKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sSlowKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbBounceKeysMask) {
- sprintf(tbuf,"%sBounceKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sBounceKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbStickyKeysMask) {
- sprintf(tbuf,"%sStickyKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sStickyKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbMouseKeysMask) {
- sprintf(tbuf,"%sMouseKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sMouseKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbMouseKeysAccelMask) {
- sprintf(tbuf,"%sMouseKeysAccel",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sMouseKeysAccel",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXKeysMask) {
- sprintf(tbuf,"%sAccessXKeys",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXKeys",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXTimeoutMask) {
- sprintf(tbuf,"%sAccessXTimeout",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXTimeout",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAccessXFeedbackMask) {
- sprintf(tbuf,"%sAccessXFeedback",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAccessXFeedback",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbAudibleBellMask) {
- sprintf(tbuf,"%sAudibleBell",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sAudibleBell",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbOverlay1Mask) {
- sprintf(tbuf,"%sOverlay1",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sOverlay1",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbOverlay2Mask) {
- sprintf(tbuf,"%sOverlay2",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sOverlay2",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
if (tmp&XkbIgnoreGroupLockMask) {
- sprintf(tbuf,"%sIgnoreGroupLock",(nOut>0?"+":""));
+ snprintf(tbuf,sizeof(tbuf),"%sIgnoreGroupLock",(nOut>0?"+":""));
TryCopyStr(buf,tbuf,sz);
nOut++;
}
@@ -990,12 +990,12 @@ char tbuf[32];
else if (act->flags&XkbSA_MessageOnPress)
TryCopyStr(buf,"KeyPress",sz);
else TryCopyStr(buf,"KeyRelease",sz);
- sprintf(tbuf,",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz);
return TRUE;
}
@@ -1016,9 +1016,9 @@ unsigned vmods,vmods_mask;
(xkb->names->keys[kc].name[0]!='\0')) {
char *kn;
kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
- sprintf(tbuf,"key=%s",kn);
+ snprintf(tbuf,sizeof(tbuf),"key=%s",kn);
}
- else sprintf(tbuf,"key=%d",kc);
+ else snprintf(tbuf,sizeof(tbuf),"key=%d",kc);
TryCopyStr(buf,tbuf,sz);
if ((act->mods_mask==0)&&(vmods_mask==0))
return TRUE;
@@ -1054,12 +1054,12 @@ XkbDeviceBtnAction * act;
char tbuf[32];
act= &action->devbtn;
- sprintf(tbuf,"device= %d",act->device); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),"device= %d",act->device); TryCopyStr(buf,tbuf,sz);
TryCopyStr(buf,",button=",sz);
- sprintf(tbuf,"%d",act->button);
+ snprintf(tbuf,sizeof(tbuf),"%d",act->button);
TryCopyStr(buf,tbuf,sz);
if (act->count>0) {
- sprintf(tbuf,",count=%d",act->count);
+ snprintf(tbuf,sizeof(tbuf),",count=%d",act->count);
TryCopyStr(buf,tbuf,sz);
}
if (action->type==XkbSA_LockDeviceBtn) {
@@ -1086,14 +1086,14 @@ XkbAnyAction * act;
char tbuf[32];
act= &action->any;
- sprintf(tbuf,"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz);
- sprintf(tbuf,",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz);
+ snprintf(tbuf,sizeof(tbuf),",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz);
return TRUE;
}
@@ -1135,7 +1135,7 @@ char buf[ACTION_SZ],*tmp;
int sz;
if (format==XkbCFile) {
- sprintf(buf,
+ snprintf(buf,sizeof(buf),
"{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
XkbActionTypeText(action->type,XkbCFile),
action->any.data[0],action->any.data[1],action->any.data[2],
@@ -1143,7 +1143,7 @@ int sz;
action->any.data[6]);
}
else {
- sprintf(buf,"%s(",XkbActionTypeText(action->type,XkbXKBFile));
+ snprintf(buf,sizeof(buf),"%s(",XkbActionTypeText(action->type,XkbXKBFile));
sz= ACTION_SZ-strlen(buf)+2; /* room for close paren and NULL */
if (action->type<(unsigned)XkbSA_NumActions)
(*copyActionArgs[action->type])(xkb,action,buf,&sz);
@@ -1163,8 +1163,8 @@ char buf[256],*tmp;
if (format==XkbCFile) {
if (behavior->type==XkbKB_Default)
- sprintf(buf,"{ 0, 0 }");
- else sprintf(buf,"{ %3d, 0x%02x }",behavior->type,behavior->data);
+ snprintf(buf,sizeof(buf),"{ 0, 0 }");
+ else snprintf(buf,sizeof(buf),"{ %3d, 0x%02x }",behavior->type,behavior->data);
}
else {
unsigned type,permanent;
@@ -1172,14 +1172,14 @@ char buf[256],*tmp;
permanent=((behavior->type&XkbKB_Permanent)!=0);
if (type==XkbKB_Lock) {
- sprintf(buf,"lock= %s",(permanent?"Permanent":"TRUE"));
+ snprintf(buf,sizeof(buf),"lock= %s",(permanent?"Permanent":"TRUE"));
}
else if (type==XkbKB_RadioGroup) {
int g;
char *tmp;
g= ((behavior->data)&(~XkbKB_RGAllowNone))+1;
if (XkbKB_RGAllowNone&behavior->data) {
- sprintf(buf,"allowNone,");
+ snprintf(buf,sizeof(buf),"allowNone,");
tmp= &buf[strlen(buf)];
}
else tmp= buf;
@@ -1197,12 +1197,12 @@ char buf[256],*tmp;
kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile);
else {
static char tbuf[8];
- sprintf(tbuf,"%d",kc);
+ snprintf(tbuf,sizeof(tbuf),"%d",kc);
kn= tbuf;
}
if (permanent)
- sprintf(buf,"permanentOverlay%d= %s",ndx,kn);
- else sprintf(buf,"overlay%d= %s",ndx,kn);
+ snprintf(buf,sizeof(buf),"permanentOverlay%d= %s",ndx,kn);
+ else snprintf(buf,sizeof(buf),"overlay%d= %s",ndx,kn);
}
}
tmp= tbGetBuffer(strlen(buf)+1);