This patch addresses a number of problems with printf-like functions.
Most of them are %x formats applied to pointers (which could be a
problem depending on the architecture I would assume). There is a
%p format for pointers on many machines but I don't know if it
applies to all supported OpenAFS platforms so I didn't go that route.
There is a buffer overflow fix to ktime.c
There are a couple places where incorrect format characters were used.
One call had two arguments swapped.
Other fixes include the use of PrintInode() and %s formats for
printing inode numbers. The code was inconsistent in this regard -- sometimes
PrintInode() was used, sometimes it was side-stepped.
There is one place where a local shadowed another variable, so I renamed
the local.
The last segment points out that an fdset need not be anything printable
with an integer format.
--
Joe Buehler
Comments - The fdset comment relates to a WinSock only file on which
the size is a pointer to int. Modified the source to use a %p instead
of %x as it is supported on Windows.
Added an assert(p != NULL) to src/rx/rx_packet.c
/* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize);
- afsi_log("osi_LogCreate log addr %x", afsd_logp);
+ afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
osi_LogEnable(afsd_logp);
logReady = 1;
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1,
RXAFSCB_ExecuteRequest);
- afsi_log("rx_NewService addr %x", serverp);
+ afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats",
&nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
- afsi_log("rx_NewService addr %x", serverp);
+ afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
if (code == 0 && !cm_freelanceEnabled) {
cm_rootCellp = cm_GetCell(rootCellName, CM_FLAG_CREATE);
- afsi_log("cm_GetCell addr %x", cm_rootCellp);
+ afsi_log("cm_GetCell addr %x", (int)cm_rootCellp);
if (cm_rootCellp == NULL) {
*reasonP = "can't find root cell in afsdcell.ini";
return -1;
for(uidp = vcp->usersp; uidp; uidp = uidp->nextp) {
if (uid == uidp->userID) {
uidp->refCount++;
- osi_LogEvent("AFS smb_FindUID (Find by UID)",NULL," VCP[%x] found-uid[%d] name[%s]",vcp,uidp->userID,(uidp->unp) ? uidp->unp->name : "");
+ osi_LogEvent("AFS smb_FindUID (Find by UID)",NULL," VCP[%x] found-uid[%d] name[%s]",(int)vcp,uidp->userID,(uidp->unp) ? uidp->unp->name : "");
break;
}
}
vcp->usersp = uidp;
lock_InitializeMutex(&uidp->mx, "uid_t mutex");
uidp->userID = uid;
- osi_LogEvent("AFS smb_FindUID (Find by UID)",NULL,"VCP[%x] new-uid[%d] name[%s]",vcp,uidp->userID,(uidp->unp ? uidp->unp->name : ""));
+ osi_LogEvent("AFS smb_FindUID (Find by UID)",NULL,"VCP[%x] new-uid[%d] name[%s]",(int)vcp,uidp->userID,(uidp->unp ? uidp->unp->name : ""));
}
lock_ReleaseWrite(&smb_rctLock);
return uidp;
continue;
if (stricmp(uidp->unp->name, usern) == 0) {
uidp->refCount++;
- osi_LogEvent("AFS smb_FindUserByNameThisSession",NULL,"VCP[%x] uid[%d] match-name[%s]",vcp,uidp->userID,usern);
+ osi_LogEvent("AFS smb_FindUserByNameThisSession",NULL,"VCP[%x] uid[%d] match-name[%s]",(int)vcp,uidp->userID,usern);
break;
} else
continue;
code = smb_ReceiveCoreWriteRaw (vcp, inp, outp,
rwcp);
else {
- osi_LogEvent("AFS Dispatch %s",(myCrt_Dispatch(inp->inCom)),"vcp[%x] lana[%d] lsn[%d]",vcp,vcp->lana,vcp->lsn);
+ osi_LogEvent("AFS Dispatch %s",(myCrt_Dispatch(inp->inCom)),"vcp[%x] lana[%d] lsn[%d]",(int)vcp,vcp->lana,vcp->lsn);
osi_Log4(afsd_logp,"Dispatch %s vcp[%x] lana[%d] lsn[%d]",(myCrt_Dispatch(inp->inCom)),vcp,vcp->lana,vcp->lsn);
code = (*(dp->procp)) (vcp, inp, outp);
- osi_LogEvent("AFS Dispatch return",NULL,"Code[%d]",(code==0)?0:code-CM_ERROR_BASE,"");
+ osi_LogEvent("AFS Dispatch return",NULL,"Code[%d]",(code==0)?0:code-CM_ERROR_BASE);
osi_Log1(afsd_logp,"Dispatch return code[%d]",(code==0)?0:code-CM_ERROR_BASE);
}
uidp = smb_FindUID(vcp, newUid, SMB_FLAG_CREATE);
lock_ObtainMutex(&uidp->mx);
uidp->unp = unp;
- osi_LogEvent("AFS smb_ReceiveV3SessionSetupX",NULL,"MakeNewUser:VCP[%x],Lana[%d],lsn[%d],userid[%d],TicketKTCName[%s]",vcp,vcp->lana,vcp->lsn,newUid,usern);
+ osi_LogEvent("AFS smb_ReceiveV3SessionSetupX",NULL,"MakeNewUser:VCP[%x],Lana[%d],lsn[%d],userid[%d],TicketKTCName[%s]",(int)vcp,vcp->lana,vcp->lsn,newUid,usern);
osi_Log4(afsd_logp,"smb_ReceiveV3SessionSetupX MakeNewUser:VCP[%x],Lana[%d],lsn[%d],userid[%d]",vcp,vcp->lana,vcp->lsn,newUid);
lock_ReleaseMutex(&uidp->mx);
smb_ReleaseUID(uidp);
lock_ReleaseWrite(&smb_globalLock);
/* now dispatch it */
- osi_LogEvent("AFS-Dispatch-2[%s]",myCrt_2Dispatch(asp->opcode),"vcp[%x] lana[%d] lsn[%d]",vcp,vcp->lana,vcp->lsn);
+ osi_LogEvent("AFS-Dispatch-2[%s]",myCrt_2Dispatch(asp->opcode),"vcp[%x] lana[%d] lsn[%d]",(int)vcp,vcp->lana,vcp->lsn);
osi_Log4(afsd_logp,"AFS Server - Dispatch-2 %s vcp[%x] lana[%d] lsn[%d]",myCrt_2Dispatch(asp->opcode),vcp,vcp->lana,vcp->lsn);
code = (*smb_tran2DispatchTable[asp->opcode].procp)(vcp, asp, outp);
void MemMgr_ShowWarning (PMEMCHUNK pChunk, LPSTR pszFile, DWORD dwLine, LPTSTR pszDesc)
{
TCHAR szMessage[ 1024 ];
- wsprintf (szMessage, TEXT("%s\n\n Address: 0x%08lX (%s)\n Allocated: %s line %ld\n Freed: %s line %ld\n\nClick OK for memory details."), pszDesc, pChunk->pData, pChunk->pszExpr, pChunk->pszFile, pChunk->dwLine, pszFile, dwLine);
+ wsprintf (szMessage, TEXT("%s\n\n Address: 0x%08lX (%s)\n Allocated: %s line %ld\n Freed: %s line %ld\n\nClick OK for memory details."), pszDesc, (long)pChunk->pData, pChunk->pszExpr, pChunk->pszFile, pChunk->dwLine, pszFile, dwLine);
if (MessageBox (NULL, szMessage, cszTITLE, MB_ICONHAND | MB_OKCANCEL | MB_DEFBUTTON2) == IDOK)
{
// TODO: Show Details
wsprintf (szLocation, TEXT("%s, %ld"), pszFile, pCopy->dwLine);
TCHAR szBytes[256];
- FormatBytes (szBytes, pCopy->cbData);
+ FormatBytes (szBytes, (double)pCopy->cbData);
TCHAR szAddress[256];
- wsprintf (szAddress, TEXT("0x%08lX"), pCopy->pData);
+ wsprintf (szAddress, TEXT("0x%08lX"), (long)pCopy->pData);
LPTSTR pszKey = NULL;
switch (lr.iColSort)
TypeName(index)
int index;
{
- static char error[16];
+ static char error[36];
if ((index < 0) || (index >= NBLOCKTYPES)) {
- sprintf(error, "UNKNOWN_TYPE", index);
+ sprintf(error, "UNKNOWN_TYPE %d", index);
return (error);
}
return (typeName[index]);
/* check block type */
if (blockMap[blockIndex]->header.type != i) {
- Log("verifyFreeLists: Found %s type in %s free chain\n",
+ Log("verifyFreeLists: Found %s type in %s free chain (addr 0x%x)\n",
TypeName(blockMap[blockIndex]->header.type), TypeName(i),
addr);
if (BumpErrors())
}
count =
- sscanf(numstring, "%f%c%s", (unsigned char *)&total, &cunit, rest);
+ sscanf(numstring, "%f%c%s", &total, &cunit, rest);
if ((count > 2) || (count <= 0))
return -1;
if (count == 1)
if ((tlen == 0) && (flen == 0))
break; /* correct termination */
if (flen != tlen) {
- printf("File length mismatch for %dth file (%d)\n", i,
+ printf("File length mismatch for %dth file (%s)\n", i,
tip->files[i]);
ERROR_EXIT(6);
}
usuage()
{
printf("util_cr file ;remove cr (from crlf)\n\
- OR util_cr } ProductVersion in_filename out_filename ; substitute for %1-%5 in file\n\
- %1=Major version, %2=Minor version, %3=Patch(first digit) %4=(last two digits) %5=Version display string \n\
+ OR util_cr } ProductVersion in_filename out_filename ; substitute for %%1-%%5 in file\n\
+ %%1=Major version, %%2=Minor version, %%3=Patch(first digit) %%4=(last two digits) %%5=Version display string \n\
ProductVersion=maj.min.pat.pat2 ;maj=numeric, min=numeric pat,pat2 are not more than 3 digits or 1-2 digits and one alpha \n\
e.g 1.0.4.1, 1.0.4 a 1.0.401, 1.0.4a all represent the same version\n\
OR util_cr + file ;add cr\n \
/* A null name is no good */
if (ep->name[0] == '\000') {
printf("Dir entry %x in chain %d has bogus (null) name.\n",
- ep, i);
+ (int)ep, i);
DRelease(ep, 0);
DRelease(dhp, 0);
return 0;
/* The entry flag better be FFIRST */
if (ep->flag != FFIRST) {
- printf("Dir entry %x in chain %d has bogus flag field.\n", ep,
+ printf("Dir entry %x in chain %d has bogus flag field.\n", (int)ep,
i);
DRelease(ep, 0);
DRelease(dhp, 0);
/* Check the size of the name */
j = strlen(ep->name);
if (j >= MAXENAME) { /* MAXENAME counts the null */
- printf("Dir entry %x in chain %d has too-long name.\n", ep,
+ printf("Dir entry %x in chain %d has too-long name.\n", (int)ep,
i);
DRelease(ep, 0);
DRelease(dhp, 0);
if ((j = DirHash(ep->name)) != i) {
printf
("Dir entry %x should be in hash bucket %d but IS in %d.\n",
- ep, j, i);
+ (int)ep, j, i);
DRelease(ep, 0);
DRelease(dhp, 0);
return 0;
} else {
printf
("Dir entry %x, index 13 has name '%s' should be '.'\n",
- ep, ep->name);
+ (int)ep, ep->name);
DRelease(ep, 0);
DRelease(dhp, 0);
return 0;
} else {
printf
("Dir entry %x, index 14 has name '%s' should be '..'\n",
- ep, ep->name);
+ (int)ep, ep->name);
DRelease(ep, 0);
DRelease(dhp, 0);
return 0;
(void)fflush(stdout);
}
FD_ZERO(&readfds);
- FD_SET(f, &readfds);
+ FD_SET(f,&readfds);
errno = 0;
/* select - either recv is ready, or timeout */
/* see if timeout or error or wrong descriptor */
if (select(f + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout) < 1
|| !FD_ISSET(f, &readfds)) {
if (krb_debug) {
- fprintf(stderr, "select failed: readfds=%x", readfds);
+ fprintf(stderr, "select failed: readfds=%p", readfds);
perror("");
}
return 0;
printf("%sVersion number: %d\n", prefix, key->keyVersionNumber);
printf("%sLast modification date %d\n", prefix,
key->keyStatus.lastModificationDate);
- printf("%sLast modification micro seconds %d\n",
- key->keyStatus.lastModificationMicroSeconds, prefix);
+ printf("%sLast modification micro seconds %d\n", prefix,
+ key->keyStatus.lastModificationMicroSeconds);
printf("%sChecksum %u\n", prefix, key->keyStatus.checkSum);
printf("%sKey: \n", prefix);
printf("%sCurrent time %s\n", prefix, ctime(&time));
printf("%sNo auth %d\n", prefix, debug->noAuth);
time = debug->lastTransaction;
- printf("%sLast transaction %d\n", prefix, ctime(&time));
+ printf("%sLast transaction %s\n", prefix, ctime(&time));
printf("%sLast operation %s\n", prefix, debug->lastOperation);
printf("%sLast principal auth %s\n", prefix, debug->lastPrincipalAuth);
printf("%sLast principal UDP auth %s\n", prefix,
void
rxi_FreePacketNoLock(struct rx_packet *p)
{
- dpf(("Free %x\n", p));
+ dpf(("Free %x\n", (int)p));
if (p->flags & RX_PKTFLAG_FREE)
osi_Panic("rxi_FreePacketNoLock: packet already free\n");
if (!(p->flags & RX_PKTFLAG_FREE))
osi_Panic("rxi_AllocPacket: packet not free\n");
- dpf(("Alloc %x, class %d\n", p, class));
+ dpf(("Alloc %x, class %d\n", (int)p, class));
queue_Remove(p);
p->flags = 0; /* clear RX_PKTFLAG_FREE, initialize the rest */
AFS_RXGLOCK();
#ifdef RXDEBUG
}
- dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
+ dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
#endif
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.packetsSent[p->header.type - 1]++;
AFS_RXGLOCK();
#ifdef RXDEBUG
}
- dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
+
+ assert(p != NULL);
+
+ dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d",
+ deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1],
+ peer->host, peer->port, p->header.serial, p->header.epoch,
+ p->header.cid, p->header.callNumber, p->header.seq, p->header.flags,
+ (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
+
#endif
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.packetsSent[p->header.type - 1]++;
MUTEX_EXIT(&rx_stats_mutex);
MUTEX_ENTER(&peer->peer_lock);
+
hadd32(peer->bytesSent, p->length);
MUTEX_EXIT(&peer->peer_lock);
}
ktime_ParseDate(char *adate, struct ktime_date *akdate)
{
int code;
- afs_int32 month, day, year, hour, min, sec;
+ afs_int32 month, day2, year, hour, min, sec;
char never[7];
- char c;
+ char c[2];
lcstring(never, adate, sizeof(never));
if (strcmp(never, "never") == 0)
code =
- sscanf(adate, "%d / %d / %d %d : %d : %d%1s", &month, &day, &year,
- &hour, &min, &sec, &c);
+ sscanf(adate, "%d / %d / %d %d : %d : %d%1s", &month, &day2, &year,
+ &hour, &min, &sec, &c[0]);
if (code != 6) {
sec = 0;
code =
- sscanf(adate, "%d / %d / %d %d : %d%1s", &month, &day, &year,
- &hour, &min, &c);
+ sscanf(adate, "%d / %d / %d %d : %d%1s", &month, &day2, &year,
+ &hour, &min, &c[0]);
if (code != 5) {
hour = min = 0;
- code = sscanf(adate, "%d / %d / %d%1s", &month, &day, &year, &c);
+ code = sscanf(adate, "%d / %d / %d%1s", &month, &day2, &year, &c[0]);
if (code != 3) {
return -1;
}
}
}
- if ((year < 0) || (month < 1) || (month > 12) || (day < 1) || (day > 31) || /* more or less */
+ if ((year < 0) || (month < 1) || (month > 12) || (day2 < 1) || (day2 > 31) || /* more or less */
(hour < 0) || (hour > 23) || (min < 0) || (min > 59) || (sec < 0)
|| (sec > 59))
return -2;
akdate->year = year;
akdate->month = month;
- akdate->day = day;
+ akdate->day = day2;
akdate->hour = hour;
akdate->min = min;
akdate->sec = sec;
readentry(record[i].addr, &vlentry, &type);
if (InvalidVolname(vlentry.name))
- printf("Volume '%s' at addr has an invalid name\n",
+ printf("Volume '%s' at addr %u has an invalid name\n",
vlentry.name, record[i].addr);
if (!(record[i].type & NH))
#endif
if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
return errorcode;
- VLog(5, ("GetStats %\n", rxinfo(rxcall)));
+ VLog(5, ("GetStats %s\n", rxinfo(rxcall)));
memcpy((char *)vital_header, (char *)&cheader.vital_header,
sizeof(vital_vlheader));
memcpy((char *)stats, (char *)&dynamic_statistics, sizeof(vldstats));
changed_oldTime) << 1) | vnp->
delete);
if (thisProcess != vnp->writer)
- Abort("VPutVnode: Vnode at 0x%x locked by another process!\n", vnp);
+ Abort("VPutVnode: Vnode at 0x%x locked by another process!\n", (int)vnp);
if (vnp->delete) {
return 0;
}
* range or the inode table is full.
*/
VOL_LOCK if (code == BAD_IGET) {
- Log("VPutVnode: bad inumber %llu\n",
- (afs_uintmax_t) vp->vnodeIndex[class].handle->ih_ino);
+ Log("VPutVnode: bad inumber %s\n",
+ PrintInode(NULL, vp->vnodeIndex[class].handle->ih_ino));
*ec = VIO;
} else {
Log("VPutVnode: Couldn't write vnode %u, volume %u (%s)\n", vnp->vnodeNumber, V_id(vnp->volumePtr), V_name(vnp->volumePtr));
FDH_REALLYCLOSE(fdP1);
IH_RELEASE(ih1);
close(ofd);
- printf("... Copied inode %llu to file %s (%d bytes)\n",
- (afs_uintmax_t) ino, nfile, total);
+ printf("... Copied inode %s to file %s (%d bytes)\n",
+ PrintInode(NULL, ino), nfile, total);
}
} else {
#if defined(AFS_NAMEI_ENV)
IH_INIT(handle, device, vol.parentId, tempHeader.volumeInfo);
fdP = IH_OPEN(handle);
if (fdP == NULL) {
- Log("VCreateVolume: Problem iopen inode %llu (err=%d)\n",
- (afs_uintmax_t) tempHeader.volumeInfo, errno);
+ Log("VCreateVolume: Problem iopen inode %s (err=%d)\n",
+ PrintInode(NULL, tempHeader.volumeInfo), errno);
unlink(volumePath);
goto bad;
}
if (FDH_SEEK(fdP, 0, SEEK_SET) < 0) {
- Log("VCreateVolume: Problem lseek inode %llu (err=%d)\n",
- (afs_uintmax_t) tempHeader.volumeInfo, errno);
+ Log("VCreateVolume: Problem lseek inode %s (err=%d)\n",
+ PrintInode(NULL, tempHeader.volumeInfo), errno);
FDH_REALLYCLOSE(fdP);
unlink(volumePath);
goto bad;
}
if (FDH_WRITE(fdP, (char *)&vol, sizeof(vol)) != sizeof(vol)) {
- Log("VCreateVolume: Problem writing to inode %llu (err=%d)\n",
- (afs_uintmax_t) tempHeader.volumeInfo, errno);
+ Log("VCreateVolume: Problem writing to inode %s (err=%d)\n",
+ PrintInode(NULL, tempHeader.volumeInfo), errno);
FDH_REALLYCLOSE(fdP);
unlink(volumePath);
goto bad;
replicas[i].trans = 0;
if (code) {
fprintf(STDERR,
- "Failed to end transaction on ro volume %u at server 0x%x\n",
+ "Failed to end transaction on ro volume %u at server %s\n",
entry.volumeId[ROVOL],
hostutil_GetNameByINet(htonl
(replicas[i].server.