Author: Ole Streicher <debian@liska.ath.cx>
Description: Correct warnings with -Werror=format-security and conversion
 from pointer to int.
--- a/fitsIO.c
+++ b/fitsIO.c
@@ -81,8 +81,9 @@
 {
    int i,status=0;
    int simple,extend;
-   long pcount, gcount, rowlen, varidat;
+   long pcount, gcount, rowlen;
    LONGLONG tbcol[FITS_COLMAX];
+   LONGLONG varidat;
    char tmpStr[80];
    char tmpKey[FLEN_KEYWORD];
    Tcl_HashEntry *thisEntry; 
@@ -1782,7 +1783,7 @@
 
    case TDOUBLE:
       dblData = (double *) ckalloc(nCol*nRow*sizeof(double));
-      memset (dblData, NULL, nCol*nRow*sizeof(double));
+      memset (dblData, 0, nCol*nRow*sizeof(double));
 
       ffgsfd(curFile->fptr, 
 	     1,
@@ -1826,7 +1827,7 @@
 
    case TLONGLONG:
       longlongData = (LONGLONG *) ckalloc(nCol*nRow*sizeof(LONGLONG));
-      memset (longlongData, NULL, nCol*nRow*sizeof(LONGLONG));
+      memset (longlongData, 0, nCol*nRow*sizeof(LONGLONG));
 
       ffgsfjj(curFile->fptr, 
 	      1,
@@ -1875,7 +1876,7 @@
 
    case TFLOAT:
       floatData = (float *) ckalloc(nCol*nRow*sizeof(float));
-      memset (floatData, NULL, nCol*nRow*sizeof(float));
+      memset (floatData, 0, nCol*nRow*sizeof(float));
 
       ffgsfe(curFile->fptr, 
 	     1,
@@ -1920,7 +1921,7 @@
    case TLONG:
    case TINT:
       intData = (int *) ckalloc(nRow*nCol*sizeof(int));
-      memset (intData, NULL, nCol*nRow*sizeof(int));
+      memset (intData, 0, nCol*nRow*sizeof(int));
       ffgsfk(curFile->fptr, 
 	     1,
 	     curFile->CHDUInfo.image.naxes,
@@ -1963,7 +1964,7 @@
 
    case TSHORT:
       shortData = (short *) ckalloc(nCol*nRow*sizeof(short));
-      memset (shortData, NULL, nCol*nRow*sizeof(short));
+      memset (shortData, 0, nCol*nRow*sizeof(short));
 
       ffgsfi(curFile->fptr, 
 	     1,
@@ -2007,7 +2008,7 @@
 
    case TBYTE:
       byteData = (unsigned char *) ckalloc(nCol*nRow*sizeof(unsigned char));
-      memset (byteData, NULL, nCol*nRow*sizeof(unsigned char));
+      memset (byteData, 0, nCol*nRow*sizeof(unsigned char));
 
       ffgsfb(curFile->fptr, 
 	     1,
@@ -3976,9 +3977,9 @@
     if ( ifCSV == 1 )
       fprintf(fPtr, "\"");
     if ( ifPrintRow == 1 ) {
-      sprintf(outputStr, "%d", m);
-      fprintf(fPtr, outputStr);
-      fprintf(fPtr, sepString);
+      sprintf(outputStr, "%lld", m);
+      fprintf(fPtr, "%s", outputStr);
+      fprintf(fPtr, "%s", sepString);
     }
 
     saveVectorTableRowToAscii(curFile, filename, fileStatus, m, 1, fCol, nCols, baseColNum, ifCSV,
@@ -4180,7 +4181,7 @@
 	} else if( anyf ) {
 	  /* */
 	} else {
-	  strcpy(outputStr,longlongValue[0]);
+	  sprintf(outputStr,colFormat,longlongValue[0]);
 	} 
 	break;
     
@@ -4191,9 +4192,9 @@
 	return TCL_ERROR;
     }
 
-    fprintf(fPtr, outputStr);
+    fprintf(fPtr, "%s", outputStr);
     if ( k != (fCol+nCols-1) )
-       fprintf(fPtr, sepString);
+	fprintf(fPtr, "%s", sepString);
   }
 
   return TCL_OK;
@@ -4406,9 +4407,9 @@
 	  fprintf(fPtr, rowFormatStr, outputStr);
 	} else {
 	  /* don't pad */
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	}
-	fprintf(fPtr, sepString);
+	fprintf(fPtr,"%s", sepString);
       }
       for (j=0; j< nCols; j++) {
 
@@ -4423,7 +4424,7 @@
                                      0, sepString, ifVariableVec, colFStr[j], dataType, fPtr, ifFixedFormat);
            if ( ifFixedFormat == 0 ) {
               if ( j < nCols-1 ) {
-	         fprintf(fPtr,sepString);
+	         fprintf(fPtr,"%s",sepString);
               }
            }
           
@@ -4716,7 +4717,7 @@
    	 if ( ifFixedFormat == 0 ) {
    	   if ( j != nCols-1 )
    	     /* print sepString if we're not on last column */
-   	     fprintf(fPtr, sepString);
+   	     fprintf(fPtr,"%s", sepString);
    	 }
         }
       }
@@ -4875,7 +4876,7 @@
 
    case TDOUBLE:
       dblData = (double *) ckalloc(nCols*nRows*sizeof(double));
-      memset (dblData, NULL, nCols*nRows*sizeof(double));
+      memset (dblData, 0, nCols*nRows*sizeof(double));
 
       ffgsfd(curFile->fptr, 
 	     0,
@@ -4905,8 +4906,8 @@
 	if ( ifPrintRow == 1 ) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -4916,9 +4917,9 @@
 	    sprintf(outputStr,"%#.10E", dblData[tmpIndex]);
 	    /* sprintf(outputStr,"%s", dblData[tmpIndex]); */
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -4929,7 +4930,7 @@
 
    case TLONGLONG:
       longlongData = (LONGLONG *) ckalloc(nCols*nRows*sizeof(LONGLONG));
-      memset (longlongData, NULL, nCols*nRows*sizeof(LONGLONG));
+      memset (longlongData, 0, nCols*nRows*sizeof(LONGLONG));
 
       ffgsfjj(curFile->fptr, 
 	     0,
@@ -4959,8 +4960,8 @@
 	if ( ifPrintRow == 1 ) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -4973,9 +4974,9 @@
 	    sprintf(outputStr,"%lld", longlongData[tmpIndex]);
 #endif
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -4986,7 +4987,7 @@
 
    case TFLOAT:
       floatData = (float *) ckalloc(nCols*nRows*sizeof(float));
-      memset (floatData, NULL, nCols*nRows*sizeof(float));
+      memset (floatData, 0, nCols*nRows*sizeof(float));
       ffgsfe(curFile->fptr, 
 	     0,
 	     curFile->CHDUInfo.image.naxes,
@@ -5015,8 +5016,8 @@
 	if ( ifPrintRow == 1) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -5025,9 +5026,9 @@
 	  } else {
 	    sprintf(outputStr,"%#.5f", floatData[tmpIndex]); 
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -5039,7 +5040,7 @@
 
    case TINT:
       intData = (int *) ckalloc(nRows*nCols*sizeof(int));
-      memset (intData, NULL, nCols*nRows*sizeof(int));
+      memset (intData, 0, nCols*nRows*sizeof(int));
       ffgsfk(curFile->fptr, 
 	     0,
 	     curFile->CHDUInfo.image.naxes,
@@ -5068,8 +5069,8 @@
 	if ( ifPrintRow == 1) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -5078,9 +5079,9 @@
 	  } else {
 	    sprintf(outputStr,"%d", intData[tmpIndex]); 
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -5092,7 +5093,7 @@
 
    case TSHORT:
       shortData = (short *) ckalloc(nCols*nRows*sizeof(short));
-      memset (shortData, NULL, nCols*nRows*sizeof(short));
+      memset (shortData, 0, nCols*nRows*sizeof(short));
       ffgsfi(curFile->fptr, 
 	     0,
 	     curFile->CHDUInfo.image.naxes,
@@ -5121,8 +5122,8 @@
 	if ( ifPrintRow == 1) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -5131,9 +5132,9 @@
 	  } else {
 	    sprintf(outputStr,"%d", shortData[tmpIndex]); 
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -5145,7 +5146,7 @@
 
    case TBYTE:
       byteData = (unsigned char *) ckalloc(nCols*nRows*sizeof(unsigned char));
-      memset (byteData, NULL, nCols*nRows*sizeof(unsigned char));
+      memset (byteData, 0, nCols*nRows*sizeof(unsigned char));
       ffgsfb(curFile->fptr, 
 	     0,
 	     curFile->CHDUInfo.image.naxes,
@@ -5174,8 +5175,8 @@
 	if ( ifPrintRow == 1) {
 	  int rowNum = fRow + j;
 	  sprintf(outputStr, "%d", rowNum);
-	  fprintf(fPtr, outputStr);
-	  fprintf(fPtr, sepString);
+	  fprintf(fPtr,"%s", outputStr);
+	  fprintf(fPtr,"%s", sepString);
 	}
 	for (i=0; i<nCols ; i++ ) {
 	  tmpIndex = j*nCols + i;
@@ -5184,9 +5185,9 @@
 	  } else {
 	    sprintf(outputStr,"%u", byteData[tmpIndex]); 
 	  }
-	  fprintf(fPtr, outputStr);
+	  fprintf(fPtr,"%s", outputStr);
 	  if ( i != nCols-1 )
-	    fprintf(fPtr, sepString);
+	    fprintf(fPtr,"%s", sepString);
 	}
 	if ( ifCSV == 1)
 	  fprintf(fPtr, "\"");
@@ -7120,13 +7121,13 @@
    uniqueNum = 0;
    if (isMerge == 0  ) {
       for (i=0; i<numRows; i++) {
-         sprintf(rowlist[i],"%d",columndata[i].rowindex);
+         sprintf(rowlist[i],"%ld",columndata[i].rowindex);
       }
       
    } else {
       for (i=0; i<numRows; i++) {
          if ( columndata[i].flag == 0 ) {
-         sprintf(rowlist[uniqueNum],"%d",columndata[i].rowindex);
+         sprintf(rowlist[uniqueNum],"%ld",columndata[i].rowindex);
          uniqueNum++;
          }
       }
