Change sprintf to snprintf for buffer overflow protection
[snark14.git] / tools / Display / displayprojection.cpp
index c4773939193d537cb14c6988174b6acb91e87653..599ab6e285cd394c0b13bcd8cb3fc0bfceea5fcc 100644 (file)
@@ -162,7 +162,7 @@ displayprojection::displayprojection(QWidget* parent, const char* name, bool mod
 
     lowthresh = new QLineEdit(this, "lowthresh");
     lowthresh->setGeometry(QRect(5, 260, 80, 30));
-    char s[16];
+    char s[12];
     snprintf(s,sizeof(s)-1,"%7.4f", minval);
     lowthresh->setText(s);
 
@@ -184,7 +184,7 @@ displayprojection::displayprojection(QWidget* parent, const char* name, bool mod
 
     highthresh = new QLineEdit(this, "highthresh");
     highthresh->setGeometry(QRect(5, 355, 80, 30));
-    sprintf(s, "%7.4f", maxval);
+    snprintf(s, sizeof(s)-1, "%7.4f", maxval);
     highthresh->setText(s);
 
     sethighthreshbutton = new QPushButton(this, "sethighthreshbutton");
@@ -248,16 +248,16 @@ void displayprojection::updateClickedPixel(int cx, int cy) {
 
     ix = cx / zoomval;
     iy = cy / zoomval;
-    sprintf(s, "(%d,%d)", ix, iy);
+    snprintf(s, sizeof(s)-1, "(%d,%d)", ix, iy);
     pixelpos->setText(s);
-    sprintf(s, "%7.4f", proj[ix][iy]);
+    snprintf(s, sizeof(s)-1, "%7.4f", proj[ix][iy]);
     pixelvalue->setText(s);
 }
 
 void displayprojection::updateZoom() {
-    char s[4];
+    char s[7];
     int v = zoomslider->value();
-    sprintf(s, "%d", v);
+    snprintf(s, sizeof(s)-1, "%d", v);
     zoom->setText(s);
     zoomval = v;
     displaywidget->resize(prjnum*zoomval, usrays * zoomval);
@@ -307,7 +307,7 @@ void displayprojection::updateLowthresh() {
     }
     double fv = ((double) v) / 1000;
     lowthreshold = fv;
-    sprintf(s, "%7.4f", fv);
+    snprintf(s, sizeof(s)-1, "%7.4f", fv);
     lowthresh->setText(s);
     resetImage();
 }
@@ -349,7 +349,7 @@ void displayprojection::updateHighthresh() {
     }
     double fv = ((double) v) / 1000;
     highthreshold = fv;
-    sprintf(s, "%7.4f", fv);
+    snprintf(s, sizeof(s)-1, "%7.4f", fv);
     highthresh->setText(s);
     resetImage();
 }