080a160c7b9595d516c9c70e83689a09b60839d0 galt Mon Jun 3 12:16:53 2013 -0700 fix SQL Injection diff --git src/hg/qaPushQ/qaPushQ.c src/hg/qaPushQ/qaPushQ.c index 389734c..44edbb2 100644 --- src/hg/qaPushQ/qaPushQ.c +++ src/hg/qaPushQ/qaPushQ.c @@ -254,31 +254,31 @@ if (sscanf(d,"%d",&dd) != 1) return FALSE; if (yyyy < 1900) return FALSE; if (yyyy > 2100) return FALSE; if ( mm > 12 ) return FALSE; if ( mm < 1 ) return FALSE; if ( dd > 31 ) return FALSE; if ( dd < 1 ) return FALSE; return TRUE; } void encryptPWD(char *password, char *salt, char *buf, int bufsize) /* encrypt a password */ { /* encrypt user's password. */ -safef(buf,bufsize,crypt(password, salt)); +safef(buf,bufsize,"%s",crypt(password, salt)); } void encryptNewPWD(char *password, char *buf, int bufsize) /* encrypt a new password */ { unsigned long seed[2]; char salt[] = "$1$........"; const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRST" "UVWXYZabcdefghijklmnopqrstuvwxyz"; int i; /* Generate a (not very) random seed. */ seed[0] = time(NULL); seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000); @@ -313,52 +313,52 @@ bool mySqlGetLock(char *name, int timeout) /* Tries to acquire (for 10 seconds) and set an advisory lock. * note: mysql returns 1 if successful, * 0 if name already locked or NULL if error occurred * blocks another client from obtaining a lock with the same name * lock is automatically released by mysql when connection is closed or detected broken * may even detect program crash and release lock. */ { char query[256]; struct sqlResult *rs; char **row = NULL; bool result = FALSE; -safef(query, sizeof(query), "select get_lock('%s', %d)", name, timeout); +sqlSafef(query, sizeof(query), "select get_lock('%s', %d)", name, timeout); rs = sqlGetResult(conn, query); row=sqlNextRow(rs); if (row[0] == NULL) { safef(msg, sizeof(msg), "Attempt to GET_LOCK of %s caused an error\n",name); htmShell(TITLE, doMsg, NULL); exit(0); } if (sameWord(row[0], "1")) result = TRUE; else if (sameWord(row[0], "0")) result = FALSE; sqlFreeResult(&rs); return result; } void mySqlReleaseLock(char *name) /* Releases an advisory lock created by GET_LOCK in mySqlGetLock */ { char query[256]; -safef(query, sizeof(query), "select release_lock('%s')", name); +sqlSafef(query, sizeof(query), "select release_lock('%s')", name); sqlUpdate(conn, query); } void setLock() /* set a lock to reduce concurrency problems */ { mySqlGetLock("qapushq",10); /* just an advisory semaphore, really */ } void releaseLock() /* release the advisory lock */ { mySqlReleaseLock("qapushq"); @@ -966,58 +966,52 @@ errAbort("drawDisplayLine: unexpected case enum %d.",col); } } void doDisplay() /* handle display request, shows pushQ records, also this is the default action */ { struct pushQ *ki, *kiList = NULL; struct sqlResult *sr; char **row; -char query[256]; +struct dyString *dy = dyStringNew(0); char lastP = ' '; int c = 0; -char monthsql[256]; char comment[256]; /* initialize column display order */ initColsFromString(); -safef(monthsql,sizeof(monthsql),"%s",""); +/* Get a list of all (or in month). */ +sqlDyStringPrintf(dy, "select * from %s", pushQtbl); if (!sameString(month,"")) { - safef(monthsql,sizeof(monthsql)," where priority='L' and qadate like '%s%%' ",month); + sqlDyStringPrintf(dy," where priority='L' and qadate like '%s%%' ",month); } - -/* Get a list of all (or in month). */ -safef(query, sizeof(query), "select * from %s%s%s", - pushQtbl, - monthsql, - " order by priority, rank, qadate desc, qid desc limit 200" - ); - -sr = sqlGetResult(conn, query); +dyStringAppend(dy, " order by priority, rank, qadate desc, qid desc limit 200"); +sr = sqlGetResult(conn, dy->string); while ((row = sqlNextRow(sr)) != NULL) { ki = pushQLoad(row); slAddHead(&kiList, ki); } +dyStringFree(&dy); sqlFreeResult(&sr); slReverse(&kiList); /* #rows returned slCount(kiList) */ if (sameString(utsName.nodename,"hgwdev")) { printf("
Machine: %s THIS IS NOT THE REAL PUSHQ- GO TO HGWBETA
\n",utsName.nodename); } if (!sameString(msg,"")) { printf("%s
\n",msg); @@ -1134,72 +1128,72 @@ printf(""); pushQFreeList(&kiList); } struct pushQ *loadPushQ(char *qid) /* Return pushQ struct loading q with existing values. * Use pushQFree() when done.*/ { char **row; struct sqlResult *sr; char query[256]; struct pushQ *q = NULL; -safef(query, sizeof(query), "select * from %s where qid = '%s'",pushQtbl,qid); +sqlSafef(query, sizeof(query), "select * from %s where qid = '%s'",pushQtbl,qid); sr = sqlGetResult(conn, query); row = sqlNextRow(sr); if (row) q = pushQLoad(row); sqlFreeResult(&sr); return q; } struct pushQ *mustLoadPushQ(char *qid) /* Load pushQ or die */ { struct pushQ *q = loadPushQ(qid); if (!q) errAbort("loadPushQ: Queue Id %s not found.",qid); return q; } void doPushDone() /* Mark record pushState=D, move priority to L for Log, and set rank=0 */ { struct pushQ *q; char query[256]; q=mustLoadPushQ(cgiString("qid")); if (sameString(q->lockUser,"") && sameString(q->pushState,"Y")) { /* not already locked and pushState=Y */ - safef(q->lastdate, sizeof(q->lastdate), q->qadate); + safef(q->lastdate, sizeof(q->lastdate), "%s", q->qadate); strftime (q->qadate , sizeof(q->qadate ), "%Y-%m-%d", loctime); /* today's date */ - safef(query, sizeof(query), + sqlSafef(query, sizeof(query), "update %s set rank = 0, priority ='L', pushState='D', qadate='%s', lastdate='%s' " "where qid = '%s' ", pushQtbl, q->qadate, q->lastdate, q->qid); sqlUpdate(conn, query); /* first close the hole where it was */ - safef(query, sizeof(query), + sqlSafef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank > %d ", pushQtbl, q->priority, q->rank); sqlUpdate(conn, query); } else { if (sameString(q->lockUser,"")) { safef(msg, sizeof(msg), "Unable to mark record %s done-> Record is locked by %s->",q->qid,q->lockUser); } else { safef(msg, sizeof(msg), "Invalid operation for qid %s, pushState is not Y, = %s->",q->qid,q->pushState); } } @@ -1207,55 +1201,55 @@ pushQFree(&q); doDisplay(); } void XdoPromote(int change) /* Promote the ranking of this Q item * >0 means promote, <0 means demote */ { struct pushQ *q; char query[256]; char newQid[sizeof(q->qid)] = ""; -safef(newQid, sizeof(newQid), cgiString("qid")); +safef(newQid, sizeof(newQid), "%s", cgiString("qid")); q = mustLoadPushQ(newQid); if ((q->rank > 1) && (change>0)) { /* swap places with rank-1 */ - safef(query, sizeof(query), "update %s set rank = rank + 1 where priority ='%s' and rank = %d ", + sqlSafef(query, sizeof(query), "update %s set rank = rank + 1 where priority ='%s' and rank = %d ", pushQtbl, q->priority, q->rank-1); sqlUpdate(conn, query); q->rank--; - safef(query, sizeof(query), "update %s set rank = %d where qid ='%s'", + sqlSafef(query, sizeof(query), "update %s set rank = %d where qid ='%s'", pushQtbl, q->rank, q->qid); sqlUpdate(conn, query); } if (change<0) { /* swap places with rank+1 */ - safef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank = %d ", + sqlSafef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank = %d ", pushQtbl, q->priority, q->rank+1); if (sqlUpdateRows(conn, query, NULL)>0) { q->rank++; - safef(query, sizeof(query), "update %s set rank = %d where qid ='%s'", + sqlSafef(query, sizeof(query), "update %s set rank = %d where qid ='%s'", pushQtbl, q->rank, q->qid); sqlUpdate(conn, query); } } pushQFree(&q); doDisplay(); } void doPromote() { XdoPromote(1); } @@ -1263,217 +1257,157 @@ void doDemote() { XdoPromote(-1); } int getNextAvailQid() /* adding new pushQ rec, get next available qid number */ { struct pushQ q; int newqid = 0; char query[256]; char *quickres = NULL; -safef(query, sizeof(query), "select max(qid) from %s",pushQtbl); +sqlSafef(query, sizeof(query), "select max(qid) from %s",pushQtbl); quickres = sqlQuickString(conn, query); if (quickres != NULL) { - safef(q.qid, sizeof(q.qid), quickres); + safef(q.qid, sizeof(q.qid), "%s", quickres); sscanf(q.qid,"%d",&newqid); freez(&quickres); } newqid++; return newqid; } int getNextAvailRank(char *priority) /* get next available rank at end of priority section */ { struct pushQ q; char query[256]; char *quickres = NULL; -safef(query, sizeof(query), +sqlSafef(query, sizeof(query), "select rank from %s where priority='%s' order by rank desc limit 1", pushQtbl, priority); quickres = sqlQuickString(conn, query); if (quickres == NULL) { q.rank = 0; } else { sscanf(quickres,"%d",&q.rank); freez(&quickres); } q.rank++; return q.rank; } void doTop() { struct pushQ *q; char query[256]; char newQid[sizeof(q->qid)] = ""; -safef(newQid, sizeof(newQid), cgiString("qid")); +safef(newQid, sizeof(newQid), "%s", cgiString("qid")); q = mustLoadPushQ(newQid); /* first close the hole where it was */ -safef(query, sizeof(query), "update %s set rank = rank + 1 where priority ='%s' and rank < %d ", +sqlSafef(query, sizeof(query), "update %s set rank = rank + 1 where priority ='%s' and rank < %d ", pushQtbl, q->priority, q->rank); sqlUpdate(conn, query); q->rank = 1; -safef(query, sizeof(query), "update %s set rank = %d where qid = '%s' ", +sqlSafef(query, sizeof(query), "update %s set rank = %d where qid = '%s' ", pushQtbl, q->rank, q->qid); sqlUpdate(conn, query); pushQFree(&q); doDisplay(); } void doBottom() { struct pushQ *q; char query[256]; char newQid[sizeof(q->qid)] = ""; -safef(newQid, sizeof(newQid), cgiString("qid")); +safef(newQid, sizeof(newQid), "%s", cgiString("qid")); q = mustLoadPushQ(newQid); /* first close the hole where it was */ -safef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank > %d ", +sqlSafef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank > %d ", pushQtbl, q->priority, q->rank); sqlUpdate(conn, query); q->rank = getNextAvailRank(q->priority); -safef(query, sizeof(query)," update %s set rank = %d where qid = '%s' ", +sqlSafef(query, sizeof(query), "update %s set rank = %d where qid = '%s' ", pushQtbl, q->rank, q->qid); sqlUpdate(conn, query); pushQFree(&q); doDisplay(); } /* too bad this isn't part of autoSql's code generation */ -void pushQUpdateEscaped(struct sqlConnection *conn, struct pushQ *el, char *tableName, int updateSize) +void pushQUpdate(struct sqlConnection *conn, struct pushQ *el, char *tableName, int updateSize) /* Update pushQ row to the table specified by tableName. * As blob fields may be arbitrary size updateSize specifies the approx size. * of a string that would contain the entire query. Automatically * escapes all simple strings (not arrays of string) but may be slower than pushQSaveToDb(). * For example automatically copies and converts: * "autosql's features include" --> "autosql\'s features include" * before inserting into database. */ { struct dyString *update = newDyString(updateSize); -char *qid, *pqid, *priority, *qadate, *newYN, *track, *dbs, *tbls, *cgis, *files, *currLoc, *makeDocYN, *onlineHelp, *ndxYN, *joinerYN, *stat, *featureBits, *sponsor, *reviewer, *extSource, *openIssues, *notes, *pushState, *initdate, *lastdate, *lockUser, *lockDateTime, *releaseLog, *releaseLogUrl, *importance; -qid = sqlEscapeString(el->qid); -pqid = sqlEscapeString(el->pqid); -priority = sqlEscapeString(el->priority); -qadate = sqlEscapeString(el->qadate); -newYN = sqlEscapeString(el->newYN); -track = sqlEscapeString(el->track); -dbs = sqlEscapeString(el->dbs); -tbls = sqlEscapeString(el->tbls); -cgis = sqlEscapeString(el->cgis); -files = sqlEscapeString(el->files); -currLoc = sqlEscapeString(el->currLoc); -makeDocYN = sqlEscapeString(el->makeDocYN); -onlineHelp = sqlEscapeString(el->onlineHelp); -ndxYN = sqlEscapeString(el->ndxYN); -joinerYN = sqlEscapeString(el->joinerYN); -stat = sqlEscapeString(el->stat); -featureBits = sqlEscapeString(el->featureBits); -sponsor = sqlEscapeString(el->sponsor); -reviewer = sqlEscapeString(el->reviewer); -extSource = sqlEscapeString(el->extSource); -openIssues = sqlEscapeString(el->openIssues); -notes = sqlEscapeString(el->notes); -pushState = sqlEscapeString(el->pushState); -initdate = sqlEscapeString(el->initdate); -lastdate = sqlEscapeString(el->lastdate); -lockUser = sqlEscapeString(el->lockUser); -lockDateTime = sqlEscapeString(el->lockDateTime); -releaseLog = sqlEscapeString(el->releaseLog); -releaseLogUrl = sqlEscapeString(el->releaseLogUrl); -importance = sqlEscapeString(el->importance); /* had to split this up because dyStringPrintf only up to 4000 chars at one time */ -dyStringPrintf(update, +sqlDyStringPrintf(update, "update %s set " "pqid='%s',priority='%s',rank=%u,qadate='%s',newYN='%s',track='%s',", - tableName, pqid, priority, el->rank, qadate, newYN, track); -dyStringPrintf(update, "dbs='%s',",dbs); -dyStringPrintf(update, "tbls='%s',",tbls); -dyStringPrintf(update, "cgis='%s',",cgis); -dyStringPrintf(update, "files='%s',",files); -dyStringPrintf(update, "sizeMB=%u,currLoc='%s'," + tableName, el->pqid, el->priority, el->rank, el->qadate, el->newYN, el->track); +sqlDyStringPrintf(update, "dbs='%s',",el->dbs); +sqlDyStringPrintf(update, "tbls='%s',",el->tbls); +sqlDyStringPrintf(update, "cgis='%s',",el->cgis); +sqlDyStringPrintf(update, "files='%s',",el->files); +sqlDyStringPrintf(update, "sizeMB=%u,currLoc='%s'," "makeDocYN='%s',onlineHelp='%s',ndxYN='%s',joinerYN='%s',stat='%s'," "sponsor='%s',reviewer='%s',extSource='%s',", - el->sizeMB , currLoc, makeDocYN, - onlineHelp, ndxYN, joinerYN, stat, - sponsor, reviewer, extSource); -dyStringPrintf(update, "openIssues='%s',",openIssues); -dyStringPrintf(update, "notes='%s',",notes); -dyStringPrintf(update, "pushState='%s', initdate='%s', lastdate='%s', bounces='%u',lockUser='%s'," + el->sizeMB , el->currLoc, el->makeDocYN, + el->onlineHelp, el->ndxYN, el->joinerYN, el->stat, + el->sponsor, el->reviewer, el->extSource); +sqlDyStringPrintf(update, "openIssues='%s',",el->openIssues); +sqlDyStringPrintf(update, "notes='%s',",el->notes); +sqlDyStringPrintf(update, "pushState='%s', initdate='%s', lastdate='%s', bounces='%u',lockUser='%s'," "lockDateTime='%s',releaseLog='%s',featureBits='%s',releaseLogUrl='%s'," "importance='%s' where qid='%s'", - pushState, initdate, lastdate, el->bounces, lockUser, lockDateTime, - releaseLog, featureBits, releaseLogUrl, importance, qid ); + el->pushState, el->initdate, el->lastdate, el->bounces, el->lockUser, el->lockDateTime, + el->releaseLog, el->featureBits, el->releaseLogUrl, el->importance, el->qid ); sqlUpdate(conn, update->string); freeDyString(&update); -freez(&qid); -freez(&pqid); -freez(&priority); -freez(&qadate); -freez(&newYN); -freez(&track); -freez(&dbs); -freez(&tbls); -freez(&cgis); -freez(&files); -freez(&currLoc); -freez(&makeDocYN); -freez(&onlineHelp); -freez(&ndxYN); -freez(&joinerYN); -freez(&stat); -freez(&sponsor); -freez(&reviewer); -freez(&extSource); -freez(&openIssues); -freez(¬es); -freez(&pushState); -freez(&initdate); -freez(&lastdate); -freez(&lockUser); -freez(&lockDateTime); -freez(&releaseLog); -freez(&releaseLogUrl); -freez(&importance); } void getCgiData(bool *isOK, bool isPtr, void *ptr, int size, char *name) /* get data, truncate to fit in field to prevent safef buf overflows */ { int l = 0; char **pfld = NULL; char *fld = NULL; char *cgi = NULL; cgi = cgiString(name); l = strlen(cgi); if (isPtr) { pfld = (char **) ptr; } @@ -1483,31 +1417,31 @@ } if (size != -1) /* -1 for blob, has no length */ { if (l>(size-1)) { *isOK = FALSE; safef(msg,sizeof(msg),"%s: too large, max. %d chars.",name,size-1); } } if (isPtr) { *pfld = cloneString(cgi); /* set pointer to a copy of the whole thing */ } else { - safef(fld, size, cloneStringZ(cgi,size-1)); /* for non-ptr strings, copy into existing buffer */ + safef(fld, size, "%s", cloneStringZ(cgi,size-1)); /* for non-ptr strings, copy into existing buffer */ } } void doTransfer(); /* forward reference needed */ void doShowSizes(); /* forward reference needed */ void doEdit(); /* forward reference needed */ void doPost() /* handle the post (really just a get for now) from Add or Edit of a pushQ record */ { @@ -1524,110 +1458,110 @@ char *lockbutton = cgiUsualString("lockbutton" ,""); char *cancelbutton = cgiUsualString("cancelbutton" ,""); char *showSizes = cgiUsualString("showSizes" ,""); char *transfer = cgiUsualString("transfer" ,""); struct pushQ *q; bool isNew = FALSE; /* new rec */ bool isRedo = FALSE; /* need to return to edit form with error msg */ bool isOK = TRUE; /* is data valid length (not too large) */ bool lockOK = TRUE; /* assume for now lock state OK */ char newQid [sizeof(q->qid)] = ""; char newPriority[sizeof(q->priority)] = ""; -safef(newQid, sizeof(newQid), cgiString("qid")); +safef(newQid, sizeof(newQid), "%s", cgiString("qid")); if (sameString(newQid,"")) { isNew = TRUE; } else { isNew = FALSE; } if (!isNew) { /* we need to preload q with existing values * because some fields like rank are not carried in form */ q = mustLoadPushQ(newQid); /* true means optional, it was asked if we could tolerate this, * e.g. delete, then hit back-button * user is trying to use back button to recover deleted rec - safef(newQid, sizeof(newQid), ""); + safef(newQid, sizeof(newQid), "%s", ""); isNew = TRUE; */ /* check lock status */ if (sameString(cancelbutton,"Cancel")) /* user cancelled */ { /* unlock record */ safef(q->lockUser, sizeof(q->lockUser), "%s", ""); safef(q->lockDateTime, sizeof(q->lockDateTime), "%s", ""); - pushQUpdateEscaped(conn, q, pushQtbl, updateSize); + pushQUpdate(conn, q, pushQtbl, updateSize); lockOK = FALSE; } else if (sameString(lockbutton,"Lock")) /* try to lock the record for editing */ { if (sameString(q->lockUser,"")) /* q->lockUser blank if nobody has lock */ { - safef(q->lockUser, sizeof(q->lockUser), qaUser); + safef(q->lockUser, sizeof(q->lockUser), "%s", qaUser); strftime(q->lockDateTime, sizeof(q->lockDateTime), "%Y-%m-%d %H:%M", loctime); - pushQUpdateEscaped(conn, q, pushQtbl, updateSize); + pushQUpdate(conn, q, pushQtbl, updateSize); lockOK = FALSE; } else { /* somebody else has lock-> */ lockOK = FALSE; } } else if (!sameString(q->lockUser,qaUser)) /* User supposed to already have lock, verify. */ { /* if lock was lost, what do we do now? */ if (sameString(q->lockUser,"")) { - safef(msg,sizeof(msg),"Lost lock-> Must refresh data->"); + safef(msg,sizeof(msg), "%s", "Lost lock-> Must refresh data->"); } else { safef(msg,sizeof(msg),"Lost lock-> User %s currently has lock on Queue Id %s since %s->", q->lockUser,q->qid,q->lockDateTime); } lockOK = FALSE; } if (!lockOK) { doEdit(); pushQFree(&q); return; } } if (isNew) { AllocVar(q); newqid = getNextAvailQid(); safef(q->pqid, sizeof(q->pqid), "%s", ""); safef(q->pushState,sizeof(q->pushState),"N"); /* default to: push not done yet */ } -safef(newPriority, sizeof(newPriority), cgiString("priority")); +safef(newPriority, sizeof(newPriority), "%s", cgiString("priority")); /* dates */ getCgiData(&isOK, FALSE, q->qadate , sizeof(q->qadate ), "qadate" ); getCgiData(&isOK, FALSE, q->initdate , sizeof(q->initdate ), "initdate" ); /* YN select listboxes */ getCgiData(&isOK, FALSE, q->newYN , sizeof(q->newYN ), "newYN" ); getCgiData(&isOK, FALSE, q->makeDocYN , sizeof(q->makeDocYN ), "makeDocYN" ); getCgiData(&isOK, FALSE, q->ndxYN , sizeof(q->ndxYN ), "ndxYN" ); getCgiData(&isOK, FALSE, q->joinerYN , sizeof(q->joinerYN ), "joinerYN" ); getCgiData(&isOK, FALSE, q->importance, sizeof(q->importance), "importance" ); /* chr(255) strings */ getCgiData(&isOK, TRUE ,&q->track , 256 , "track" ); @@ -1737,126 +1671,126 @@ isRedo = TRUE; } if (isRedo) { replacePushQFields(q, isNew); pushQFree(&q); return; } if (sameString(bouncebutton,"bounce")) { safef(newPriority, sizeof(newPriority), "B"); - safef(q->lastdate, sizeof(q->lastdate), q->qadate); + safef(q->lastdate, sizeof(q->lastdate), "%s", q->qadate); strftime (q->qadate, sizeof(q->qadate), "%Y-%m-%d", loctime); /* set to today's date */ q->bounces++; } if (sameString(bouncebutton,"unbounce")) { safef(newPriority, sizeof(newPriority), "A"); - safef(q->lastdate, sizeof(q->lastdate), q->qadate); + safef(q->lastdate, sizeof(q->lastdate), "%s", q->qadate); strftime (q->qadate, sizeof(q->qadate), "%Y-%m-%d", loctime); /* set to today's date */ } /* check if priority class has changed, or deleted, then close ranks */ if ( (!sameString(newPriority,q->priority)) || (sameString(delbutton,"delete")) ) { /* first close the hole where it was */ - safef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank > %d ", + sqlSafef(query, sizeof(query), "update %s set rank = rank - 1 where priority ='%s' and rank > %d ", pushQtbl, q->priority, q->rank); sqlUpdate(conn, query); } /* if not deleted, then if new or priority class change, then take last rank */ if (!sameString(delbutton,"delete")) { if ((!sameString(newPriority,q->priority)) || isNew) { q->rank = getNextAvailRank(newPriority); - safef(q->priority, sizeof(q->priority), newPriority); + safef(q->priority, sizeof(q->priority), "%s", newPriority); } } if (q->priority[0]=='L') { q->rank = 0; } if (sameString(pushbutton,"push requested")) { /* reset pushState in case was prev-> a log already */ safef(q->pushState,sizeof(q->pushState),"Y"); } if (sameString(delbutton,"delete")) { /* delete old record */ - safef(query, sizeof(query), "delete from %s where qid ='%s'", pushQtbl, q->qid); + sqlSafef(query, sizeof(query), "delete from %s where qid ='%s'", pushQtbl, q->qid); sqlUpdate(conn, query); } else { if (sameString(showSizes,"Show Sizes") || sameString(transfer,"Transfer")) { /* mark record as locked */ - safef(q->lockUser, sizeof(q->lockUser), qaUser); + safef(q->lockUser, sizeof(q->lockUser), "%s", qaUser); strftime(q->lockDateTime, sizeof(q->lockDateTime), "%Y-%m-%d %H:%M", loctime); } else { /* unlock record */ safef(q->lockUser, sizeof(q->lockUser), "%s", ""); safef(q->lockDateTime, sizeof(q->lockDateTime), "%s", ""); } if (isNew) { /* save new record */ safef(msg, sizeof(msg), "%%0%dd", (int)sizeof(q->qid)-1); safef(newQid,sizeof(newQid),msg,newqid); - safef(q->qid, sizeof(q->qid), newQid); + safef(q->qid, sizeof(q->qid), "%s", newQid); safef(msg, sizeof(msg), "%s", ""); - pushQSaveToDbEscaped(conn, q, pushQtbl, updateSize); + pushQSaveToDb(conn, q, pushQtbl, updateSize); } else { /* update existing record */ - pushQUpdateEscaped(conn, q, pushQtbl, updateSize); + pushQUpdate(conn, q, pushQtbl, updateSize); } } if (sameString(clonebutton,"clone")) { /* save new clone */ - safef(q->pqid,sizeof(q->pqid), q->qid); /* daughter will point to parent */ + safef(q->pqid,sizeof(q->pqid), "%s", q->qid); /* daughter will point to parent */ newqid = getNextAvailQid(); safef(msg, sizeof(msg), "%%0%dd", (int)sizeof(q->qid)-1); safef(newQid,sizeof(newQid),msg,newqid); - safef(q->qid, sizeof(q->qid), newQid); + safef(q->qid, sizeof(q->qid), "%s", newQid); safef(msg, sizeof(msg), "%s", ""); if (q->priority[0]=='L') { q->rank = 0; } else { q->rank = getNextAvailRank(q->priority); } safef(q->pushState,sizeof(q->pushState),"N"); /* default to: push not done yet */ - pushQSaveToDbEscaped(conn, q, pushQtbl, updateSize); + pushQSaveToDb(conn, q, pushQtbl, updateSize); } if (sameString(showSizes,"Show Sizes")) { cgiVarSet("qid", q->qid); /* for new rec */ doShowSizes(); } else if (sameString(transfer,"Transfer")) { cgiVarSet("qid", q->qid); /* for new rec */ doTransfer(); } @@ -1891,67 +1825,67 @@ printf("Queue Id %s not found.", cgiString("qid")); return; } if ( sameString(qaUser,"kuhn") || sameString(qaUser,"kuhn2") || sameString(qaUser,"mary") || sameString(qaUser,"ann") || sameString(qaUser,"antonio") ) /* for users that want to automatically try to lock record immediately */ { if (sameString(action,"edit") || sameString(action,"setSize")) { if (sameString(q->lockUser,"")) /* q->lockUser blank if nobody has lock */ { - safef(q->lockUser, sizeof(q->lockUser), qaUser); + safef(q->lockUser, sizeof(q->lockUser), "%s", qaUser); strftime(q->lockDateTime, sizeof(q->lockDateTime), "%Y-%m-%d %H:%M", loctime); - pushQUpdateEscaped(conn, q, pushQtbl, updateSize); + pushQUpdate(conn, q, pushQtbl, updateSize); } } else /* we are coming back from a post? so return to display automatically */ { doDisplay(); return; /* this is needed? */ } } replacePushQFields(q, FALSE); /* new rec = false */ pushQFree(&q); } void doSetSize() /* save sizeMB */ { struct pushQ *q; char tempSizeMB[10]; int updateSize=2456; q = loadPushQ(cgiString("qid")); if (!q) { printf("Queue Id %s not found.", cgiString("qid")); return; } -safef(tempSizeMB,sizeof(tempSizeMB), cgiUsualString("sizeMB","")); +safef(tempSizeMB,sizeof(tempSizeMB), "%s", cgiUsualString("sizeMB","")); if (!sameString(tempSizeMB,"")) { if (sscanf(tempSizeMB,"%u",&q->sizeMB) != 1) { q->sizeMB = 0; } } -pushQUpdateEscaped(conn, q, pushQtbl, updateSize); +pushQUpdate(conn, q, pushQtbl, updateSize); doEdit(); pushQFree(&q); } void doLogin() /* make form for login */ { printf("