Commit a48c1a86 authored by David Kilzer's avatar David Kilzer Committed by Nick Wellnhofer

Replace sprintf with snprintf

Fixes bug #758202
https://bugzilla.gnome.org/show_bug.cgi?id=758202
parent 7219c6c3
......@@ -703,9 +703,9 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
val = (long)((char *)cur - (char *)&base_address);
if (val >= 0) {
sprintf((char *)str, "idp%ld", val);
snprintf((char *)str, sizeof(str), "idp%ld", val);
} else {
sprintf((char *)str, "idm%ld", -val);
snprintf((char *)str, sizeof(str), "idm%ld", -val);
}
valuePush(ctxt, xmlXPathNewString(str));
}
......
......@@ -2087,9 +2087,9 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
break;
}
t=templ2?templ2->time:totalt;
sprintf(times_str,"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC);
sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
sprintf(called_str,"%6d/%d",
snprintf(times_str,sizeof(times_str),"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(called_str,sizeof(called_str),"%6d/%d",
templ1->templCountTab[j], /* number of times caller calls 'this' */
templ1->nbCalls); /* total number of calls to 'this' */
......@@ -2098,10 +2098,10 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
(templ2?(templ2->name?(char *)templ2->name:pretty_templ_match(templ2)):"-"),k);
}
/* this */
sprintf(ix_str,"[%d]",i);
sprintf(timep_str,"%6.2f",(float)templ1->time*100.0/totalt);
sprintf(times_str,"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SEC);
sprintf(timec_str,"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(ix_str,sizeof(ix_str),"[%d]",i);
snprintf(timep_str,sizeof(timep_str),"%6.2f",(float)templ1->time*100.0/totalt);
snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC);
fprintf(output, "%-5s %-6s %-8s %-8s %6d %s [%d]\n",
ix_str, timep_str,times_str,timec_str,
templ1->nbCalls,
......@@ -2123,9 +2123,9 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
templ2 = templates[k];
for (l = 0; l < templ2->templNr; l++) {
if (templ2->templCalledTab[l] == templ1) {
sprintf(times_str,"%8.3f",(float)templ2->time/XSLT_TIMESTAMP_TICS_PER_SEC);
sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
sprintf(called_str,"%6d/%d",
snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ2->time/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
snprintf(called_str,sizeof(called_str),"%6d/%d",
templ2->templCountTab[l], /* number of times 'this' calls callee */
total); /* total number of calls from 'this' */
fprintf(output, " %-8s %-8s %-12s %s [%d]\n",
......@@ -2245,19 +2245,19 @@ xsltGetProfileInformation(xsltTransformContextPtr ctxt)
for (i = 0; i < nb; i++) {
child = xmlNewChild(root, NULL, BAD_CAST "template", NULL);
sprintf(buf, "%d", i + 1);
snprintf(buf, sizeof(buf), "%d", i + 1);
xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf);
xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match);
xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name);
xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode);
sprintf(buf, "%d", templates[i]->nbCalls);
snprintf(buf, sizeof(buf), "%d", templates[i]->nbCalls);
xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf);
sprintf(buf, "%ld", templates[i]->time);
snprintf(buf, sizeof(buf), "%ld", templates[i]->time);
xmlSetProp(child, BAD_CAST "time", BAD_CAST buf);
sprintf(buf, "%ld", templates[i]->time / templates[i]->nbCalls);
snprintf(buf, sizeof(buf), "%ld", templates[i]->time / templates[i]->nbCalls);
xmlSetProp(child, BAD_CAST "average", BAD_CAST buf);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment