summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-25 12:24:40 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-25 12:24:40 -0700
commitbd55f70b8740a630fa42d17e4f3345b3601542e2 (patch)
tree5d0f77ca1b162f1688feb176f1376145da5bbe1e
parent980f5d224fb747d059bd9692d1676142d19f2e07 (diff)
Convert sprintf calls to snprintf
Remaining sprintf calls in evargs.c are printing into buffers passed through multiple levels of function calls, and need arguments added to those functions to pass through buffer sizes as well. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--cfgscan.c76
-rw-r--r--printev.c2
-rw-r--r--xkbevd.c8
3 files changed, 43 insertions, 43 deletions
diff --git a/cfgscan.c b/cfgscan.c
index ac369ae..18c0559 100644
--- a/cfgscan.c
+++ b/cfgscan.c
@@ -61,45 +61,45 @@ tokText(int tok)
static char buf[32];
switch (tok) {
- case END_OF_FILE: sprintf(buf, "END_OF_FILE");break;
- case ERROR: sprintf(buf, "ERROR"); break;
-
- case BELL: sprintf(buf, "BELL"); break;
- case ACCESSX: sprintf(buf, "ACCESSX"); break;
- case MESSAGE: sprintf(buf, "MESSAGE"); break;
-
- case NONE: sprintf(buf, "NONE"); break;
- case IGNORE: sprintf(buf, "IGNORE"); break;
- case ECHO: sprintf(buf, "ECHO"); break;
- case PRINT_EV: sprintf(buf, "PRINT_EV"); break;
- case SHELL: sprintf(buf, "SHELL"); break;
- case SOUND: sprintf(buf, "SOUND"); break;
-
- case EQUALS: sprintf(buf, "EQUALS"); break;
- case PLUS: sprintf(buf, "PLUS"); break;
- case MINUS: sprintf(buf, "MINUS"); break;
- case DIVIDE: sprintf(buf, "DIVIDE"); break;
- case TIMES: sprintf(buf, "TIMES"); break;
- case OBRACE: sprintf(buf, "OBRACE"); break;
- case CBRACE: sprintf(buf, "CBRACE"); break;
- case OPAREN: sprintf(buf, "OPAREN"); break;
- case CPAREN: sprintf(buf, "CPAREN"); break;
- case OBRACKET: sprintf(buf, "OBRACKET");break;
- case CBRACKET: sprintf(buf, "CBRACKET");break;
- case DOT: sprintf(buf, "DOT"); break;
- case COMMA: sprintf(buf, "COMMA"); break;
- case SEMI: sprintf(buf, "SEMI"); break;
- case EXCLAM: sprintf(buf, "EXCLAM"); break;
- case INVERT: sprintf(buf, "INVERT"); break;
-
- case STRING: sprintf(buf, "STRING (%s)",scanStr); break;
- case INTEGER: sprintf(buf, "INTEGER (0x%x)",scanInt); break;
- case FLOAT: sprintf(buf, "FLOAT (%d.%d)",
+ case END_OF_FILE: snprintf(buf, sizeof(buf), "END_OF_FILE");break;
+ case ERROR: snprintf(buf, sizeof(buf), "ERROR"); break;
+
+ case BELL: snprintf(buf, sizeof(buf), "BELL"); break;
+ case ACCESSX: snprintf(buf, sizeof(buf), "ACCESSX"); break;
+ case MESSAGE: snprintf(buf, sizeof(buf), "MESSAGE"); break;
+
+ case NONE: snprintf(buf, sizeof(buf), "NONE"); break;
+ case IGNORE: snprintf(buf, sizeof(buf), "IGNORE"); break;
+ case ECHO: snprintf(buf, sizeof(buf), "ECHO"); break;
+ case PRINT_EV: snprintf(buf, sizeof(buf), "PRINT_EV"); break;
+ case SHELL: snprintf(buf, sizeof(buf), "SHELL"); break;
+ case SOUND: snprintf(buf, sizeof(buf), "SOUND"); break;
+
+ case EQUALS: snprintf(buf, sizeof(buf), "EQUALS"); break;
+ case PLUS: snprintf(buf, sizeof(buf), "PLUS"); break;
+ case MINUS: snprintf(buf, sizeof(buf), "MINUS"); break;
+ case DIVIDE: snprintf(buf, sizeof(buf), "DIVIDE"); break;
+ case TIMES: snprintf(buf, sizeof(buf), "TIMES"); break;
+ case OBRACE: snprintf(buf, sizeof(buf), "OBRACE"); break;
+ case CBRACE: snprintf(buf, sizeof(buf), "CBRACE"); break;
+ case OPAREN: snprintf(buf, sizeof(buf), "OPAREN"); break;
+ case CPAREN: snprintf(buf, sizeof(buf), "CPAREN"); break;
+ case OBRACKET: snprintf(buf, sizeof(buf), "OBRACKET"); break;
+ case CBRACKET: snprintf(buf, sizeof(buf), "CBRACKET"); break;
+ case DOT: snprintf(buf, sizeof(buf), "DOT"); break;
+ case COMMA: snprintf(buf, sizeof(buf), "COMMA"); break;
+ case SEMI: snprintf(buf, sizeof(buf), "SEMI"); break;
+ case EXCLAM: snprintf(buf, sizeof(buf), "EXCLAM"); break;
+ case INVERT: snprintf(buf, sizeof(buf), "INVERT"); break;
+
+ case STRING: snprintf(buf, sizeof(buf), "STRING (%s)",scanStr); break;
+ case INTEGER: snprintf(buf, sizeof(buf), "INTEGER (0x%x)",scanInt); break;
+ case FLOAT: snprintf(buf, sizeof(buf), "FLOAT (%d.%d)",
scanInt/XkbGeomPtsPerMM,
- scanInt%XkbGeomPtsPerMM);break;
- case IDENT: sprintf(buf, "IDENT (%s)",scanStr); break;
- case KEYNAME: sprintf(buf, "KEYNAME (%s)",scanStr); break;
- default: sprintf(buf, "UNKNOWN"); break;
+ scanInt%XkbGeomPtsPerMM); break;
+ case IDENT: snprintf(buf, sizeof(buf), "IDENT (%s)",scanStr); break;
+ case KEYNAME: snprintf(buf, sizeof(buf), "KEYNAME (%s)",scanStr); break;
+ default: snprintf(buf, sizeof(buf), "UNKNOWN"); break;
}
return buf;
}
diff --git a/printev.c b/printev.c
index ad0409b..8935d70 100644
--- a/printev.c
+++ b/printev.c
@@ -192,7 +192,7 @@ do_XkbAccessXNotify(FILE *file, XkbEvent *xkbev)
case XkbAXN_AXKWarning: detail= "warning"; break;
default: {
static char buf[20];
- sprintf(buf,"unknown(%d)",sk->detail);
+ snprintf(buf, sizeof(buf), "unknown(%d)", sk->detail);
detail= buf;
break;
}
diff --git a/xkbevd.c b/xkbevd.c
index 2fb21de..e498970 100644
--- a/xkbevd.c
+++ b/xkbevd.c
@@ -410,7 +410,7 @@ int ok;
return True;
case EchoAction:
if (cfg->action.text!=NULL) {
- sprintf(buf,"%s",cfg->action.text);
+ snprintf(buf,sizeof(buf),"%s",cfg->action.text);
cmd= SubstituteEventArgs(buf,ev);
printf("%s",cmd);
}
@@ -432,7 +432,7 @@ int ok;
uAction("Ignored\n");
return True;
}
- sprintf(buf,"%s %s%s",soundCmd,soundDir,cfg->action.text);
+ snprintf(buf,sizeof(buf),"%s %s%s",soundCmd,soundDir,cfg->action.text);
cmd= buf;
break;
default:
@@ -467,7 +467,7 @@ Bool ok;
if (cfgFileName==NULL) {
char *home;
home= (char *)getenv("HOME");
- sprintf(buf,DFLT_XKBEVD_CONFIG,(home?home:""));
+ snprintf(buf,sizeof(buf),DFLT_XKBEVD_CONFIG,(home?home:""));
cfgFileName= buf;
}
if (uStringEqual(cfgFileName,"-")) {
@@ -483,7 +483,7 @@ Bool ok;
uAction("Exiting\n");
exit(1);
}
- sprintf(buf,DFLT_SYS_XKBEVD_CONFIG,DFLT_XKB_CONFIG_ROOT);
+ snprintf(buf,sizeof(buf),DFLT_SYS_XKBEVD_CONFIG,DFLT_XKB_CONFIG_ROOT);
file= fopen(cfgFileName,"r");
if (file==NULL && !eventMask) {
if (verbose) {