Commit 6d491e54 authored by rswindell's avatar rswindell
Browse files

Include current function name in smb.last_error strings.

Set smb.last_error strings in new voting/polling functions on failure.
parent 64bf44b6
......@@ -59,12 +59,14 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
hash_t** hashes=NULL; /* This is a NULL-terminated list of hashes */
smbmsg_t remsg;
if(msg->subj == NULL)
if(msg->subj == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" subject field missing");
return SMB_ERR_HDR_FIELD;
}
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
return(SMB_ERR_NOT_OPEN);
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return SMB_ERR_NOT_OPEN;
}
if(filelength(fileno(smb->shd_fp))<1) { /* Create it if it doesn't exist */
......@@ -74,7 +76,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
}
if(!smb->locked && smb_locksmbhdr(smb)!=SMB_SUCCESS)
return(SMB_ERR_LOCK);
return SMB_ERR_LOCK;
msg->hdr.total_dfields = 0;
......@@ -91,7 +93,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_findhash(smb, hashes, &found, dupechk_hashes, /* mark? */FALSE)==SMB_SUCCESS) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"duplicate %s: %s found in message #%lu"
,__FUNCTION__" duplicate %s: %s found in message #%lu"
,smb_hashsourcetype(found.source)
,smb_hashsource(msg,found.source)
,found.number);
......@@ -143,7 +145,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(length) {
if(length >= 0x80000000 || length < 0) {
sprintf(smb->last_error,"message length: 0x%"PRIXMAX,(intmax_t)length);
sprintf(smb->last_error,__FUNCTION__" message length: 0x%"PRIXMAX,(intmax_t)length);
retval=SMB_ERR_DAT_LEN;
break;
}
......@@ -179,7 +181,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(xlat!=XLAT_NONE) { /* e.g. XLAT_LZH */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing body xlat string"
,__FUNCTION__" %d '%s' writing body xlat string"
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -189,7 +191,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing body xlat terminator"
,__FUNCTION__" %d '%s' writing body xlat terminator"
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -198,7 +200,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_fwrite(smb,body,bodylen,smb->sdt_fp)!=bodylen) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing body (%ld bytes)"
,__FUNCTION__" %d '%s' writing body (%ld bytes)"
,get_errno(),STRERROR(get_errno())
,bodylen);
retval=SMB_ERR_WRITE;
......@@ -213,7 +215,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
xlat=XLAT_NONE; /* xlat string terminator */
if(smb_fwrite(smb,&xlat,sizeof(xlat),smb->sdt_fp)!=sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing tail xlat terminator"
,__FUNCTION__" %d '%s' writing tail xlat terminator"
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -221,7 +223,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
if(smb_fwrite(smb,tail,taillen-sizeof(xlat),smb->sdt_fp)!=taillen-sizeof(xlat)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing tail (%ld bytes)"
,__FUNCTION__" %d '%s' writing tail (%ld bytes)"
,get_errno(),STRERROR(get_errno())
,taillen-sizeof(xlat));
retval=SMB_ERR_WRITE;
......@@ -235,7 +237,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
}
if(l%SDT_BLOCK_LEN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing data padding"
,__FUNCTION__" %d '%s' writing data padding"
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_WRITE;
break;
......@@ -326,18 +328,24 @@ int SMBCALL smb_addvote(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), "msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
return SMB_ERR_NOT_OPEN;
}
if(filelength(fileno(smb->shd_fp)) < 1)
if(filelength(fileno(smb->shd_fp)) < 1) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" header file empty");
return SMB_ERR_NOT_FOUND;
}
if(!(msg->hdr.attr&MSG_VOTE) || msg->hdr.attr&MSG_POLL)
if(!(msg->hdr.attr&MSG_VOTE) || msg->hdr.attr&MSG_POLL) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" incorrect attr: %04hX", msg->hdr.attr);
return SMB_ERR_HDR_ATTR;
}
if(msg->hdr.thread_back == 0)
if(msg->hdr.thread_back == 0) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" thread_back field missing");
return SMB_ERR_HDR_FIELD;
}
msg->hdr.type = SMB_MSG_TYPE_BALLOT;
......@@ -358,12 +366,19 @@ int SMBCALL smb_addpoll(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), "msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
return SMB_ERR_NOT_OPEN;
}
if(msg->subj == NULL || smb_get_hfield(msg, SMB_POLL_ANSWER, NULL) == NULL)
if(msg->subj == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error), __FUNCTION__" subject field missing");
return SMB_ERR_HDR_FIELD;
}
if(smb_get_hfield(msg, SMB_POLL_ANSWER, NULL) == NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error), __FUNCTION__" poll answers missing");
return SMB_ERR_HDR_FIELD;
}
if(filelength(fileno(smb->shd_fp)) < 1) { /* Create it if it doesn't exist */
/* smb->status.max_crcs, max_msgs, max_age, and attr should be pre-initialized */
......@@ -392,15 +407,19 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
int retval;
if(!SMB_IS_OPEN(smb)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), "msgbase not open");
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" msgbase not open");
return SMB_ERR_NOT_OPEN;
}
if(filelength(fileno(smb->shd_fp)) < 1)
if(filelength(fileno(smb->shd_fp)) < 1) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" header file empty");
return SMB_ERR_NOT_FOUND;
}
if(msg->hdr.thread_back == 0)
if(msg->hdr.thread_back == 0) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" thread_back field missing");
return SMB_ERR_HDR_FIELD;
}
memset(&remsg, 0, sizeof(remsg));
remsg.hdr.number = msg->hdr.thread_back;
......@@ -414,12 +433,14 @@ int SMBCALL smb_addpollclosure(smb_t* smb, smbmsg_t* msg, int storage)
}
if(remsg.hdr.auxattr&POLL_CLOSED) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" closed poll");
smb_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg);
return SMB_CLOSED;
}
if(!smb_msg_is_from(&remsg, msg->from, msg->from_net.type, msg->from_net.addr)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error), __FUNCTION__" wrong pollster");
smb_freemsgmem(&remsg);
smb_unlockmsghdr(smb, &remsg);
return SMB_UNAUTHORIZED;
......
/* smballoc.c */
/* Synchronet message base (SMB) alloc/free routines */
/* $Id$ */
......@@ -53,7 +51,7 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
ulong j,l,blocks,offset=0L;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_datblocks(length);
......@@ -72,17 +70,19 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
}
}
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"invalid data offset: %lu",offset);
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" invalid data offset: %lu",offset);
return(SMB_ERR_DAT_OFFSET);
}
clearerr(smb->sda_fp);
if(fseek(smb->sda_fp,(offset/SDT_BLOCK_LEN)*sizeof(refs),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to: %ld"
,(offset/SDT_BLOCK_LEN)*sizeof(refs));
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(!fwrite(&refs,sizeof(refs),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation bytes at offset %ld"
,__FUNCTION__" %d '%s' writing allocation bytes at offset %ld"
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(refs));
return(SMB_ERR_WRITE);
......@@ -100,19 +100,20 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
ulong l,blocks,offset;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->sda_fp);
clearerr(smb->sda_fp);
blocks=smb_datblocks(length);
if(fseek(smb->sda_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
return(SMB_ERR_SEEK);
}
offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN;
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"invalid data offset: %lu",offset);
,__FUNCTION__" invalid data offset: %lu",offset);
return(SMB_ERR_DAT_OFFSET);
}
for(l=0;l<blocks;l++)
......@@ -121,7 +122,7 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
fflush(smb->sda_fp);
if(l<blocks) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation bytes"
,__FUNCTION__" %d '%s' writing allocation bytes"
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -156,7 +157,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
sda_offset=((offset/SDT_BLOCK_LEN)+l)*sizeof(i);
if(fseek(smb->sda_fp,sda_offset,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' seeking to %lu (0x%lX) of allocation file"
,__FUNCTION__" %d '%s' seeking to %lu (0x%lX) of allocation file"
,get_errno(),STRERROR(get_errno())
,sda_offset,sda_offset);
retval=SMB_ERR_SEEK;
......@@ -164,7 +165,7 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' reading allocation bytes at offset %ld"
,__FUNCTION__" %d '%s' reading allocation bytes at offset %ld"
,get_errno(),STRERROR(get_errno())
,sda_offset);
retval=SMB_ERR_READ;
......@@ -176,14 +177,14 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs
i-=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' seeking backwards 2 bytes in allocation file"
,__FUNCTION__" %d '%s' seeking backwards 2 bytes in allocation file"
,get_errno(),STRERROR(get_errno()));
retval=SMB_ERR_SEEK;
break;
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation bytes at offset %ld"
,__FUNCTION__" %d '%s' writing allocation bytes at offset %ld"
,get_errno(),STRERROR(get_errno())
,sda_offset);
retval=SMB_ERR_WRITE;
......@@ -206,29 +207,32 @@ int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, uint16_t refs)
ulong l,blocks;
if(smb->sda_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
clearerr(smb->sda_fp);
blocks=smb_datblocks(length);
for(l=0;l<blocks;l++) {
if(fseek(smb->sda_fp,((offset/SDT_BLOCK_LEN)+l)*sizeof(i),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld"
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_SEEK);
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' reading allocation record at offset %ld"
,__FUNCTION__" %d '%s' reading allocation record at offset %ld"
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_READ);
}
i+=refs;
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding %ld", -(int)sizeof(i));
return(SMB_ERR_SEEK);
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation record at offset %ld"
,__FUNCTION__" %d '%s' writing allocation record at offset %ld"
,get_errno(),STRERROR(get_errno())
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_WRITE);
......@@ -278,17 +282,19 @@ int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length)
ulong l,blocks;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
clearerr(smb->sha_fp);
blocks=smb_hdrblocks(length);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET))
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld", offset/SHD_BLOCK_LEN);
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation record"
,__FUNCTION__" %d '%s' writing allocation record"
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -345,7 +351,7 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
ulong i,l,blocks,offset=0;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_hdrblocks(length);
......@@ -364,13 +370,14 @@ long SMBCALL smb_allochdr(smb_t* smb, ulong length)
}
}
clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET))
if(fseek(smb->sha_fp,offset/SHD_BLOCK_LEN,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" seeking to %ld", offset/SHD_BLOCK_LEN);
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(fputc(1,smb->sha_fp)!=1) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation record"
,__FUNCTION__" %d '%s' writing allocation record"
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -388,19 +395,21 @@ long SMBCALL smb_fallochdr(smb_t* smb, ulong length)
ulong l,blocks,offset;
if(smb->sha_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
blocks=smb_hdrblocks(length);
fflush(smb->sha_fp);
clearerr(smb->sha_fp);
if(fseek(smb->sha_fp,0L,SEEK_END))
if(fseek(smb->sha_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
return(SMB_ERR_SEEK);
}
offset=ftell(smb->sha_fp)*SHD_BLOCK_LEN;
for(l=0;l<blocks;l++)
if(!fwrite(&c,1,1,smb->sha_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' writing allocation record"
,__FUNCTION__" %d '%s' writing allocation record"
,get_errno(),STRERROR(get_errno()));
return(SMB_ERR_WRITE);
}
......@@ -418,12 +427,14 @@ long SMBCALL smb_hallochdr(smb_t* smb)
ulong offset;
if(smb->shd_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"msgbase not open");
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->shd_fp);
if(fseek(smb->shd_fp,0L,SEEK_END))
if(fseek(smb->shd_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
return(SMB_ERR_SEEK);
}
offset=ftell(smb->shd_fp);
if(offset<smb->status.header_offset) /* Header file truncated?!? */
return(smb->status.header_offset);
......@@ -448,22 +459,24 @@ long SMBCALL smb_hallocdat(smb_t* smb)
if(smb->sdt_fp==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"msgbase not open");
,__FUNCTION__" msgbase not open");
return(SMB_ERR_NOT_OPEN);
}
fflush(smb->sdt_fp);
offset=filelength(fileno(smb->sdt_fp));
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"invalid file length: %lu",(ulong)offset);
,__FUNCTION__" invalid file length: %lu",(ulong)offset);
return(SMB_ERR_FILE_LEN);
}
if(fseek(smb->sdt_fp,0L,SEEK_END))
if(fseek(smb->sdt_fp,0L,SEEK_END)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),__FUNCTION__" rewinding");
return(SMB_ERR_SEEK);
}
offset=ftell(smb->sdt_fp);
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"invalid file offset: %ld",offset);
,__FUNCTION__" invalid file offset: %ld",offset);
return(SMB_ERR_DAT_OFFSET);
}
......
/* smbfile.c */
/* Synchronet message base (SMB) FILE stream I/O routines */
/* $Id$ */
......@@ -147,7 +145,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
ext="hash";
else {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"opening %s: Illegal FILE* pointer argument: %p"
,__FUNCTION__" opening %s: Illegal FILE* pointer argument: %p"
,smb->file, fp);
return(SMB_ERR_OPEN);
}
......@@ -162,7 +160,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
break;
if(get_errno()!=EACCES && get_errno()!=EAGAIN) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' opening %s"
,__FUNCTION__" %d '%s' opening %s"
,get_errno(),STRERROR(get_errno()),path);
return(SMB_ERR_OPEN);
}
......@@ -171,7 +169,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
else
if(time(NULL)-start>=(time_t)smb->retry_time) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"timeout opening %s (retry_time=%ld)"
,__FUNCTION__" timeout opening %s (retry_time=%ld)"
,path,smb->retry_time);
return(SMB_ERR_TIMEOUT);
}
......@@ -179,7 +177,7 @@ int SMBCALL smb_open_fp(smb_t* smb, FILE** fp, int share)
}
if((*fp=fdopen(file,"r+b"))==NULL) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%d '%s' fdopening %s (%d)"
,__FUNCTION__" %d '%s' fdopening %s (%d)"
,get_errno(),STRERROR(get_errno()),path,file);
close(file);
return(SMB_ERR_OPEN);
......
......@@ -312,7 +312,7 @@ int SMBCALL smb_hashmsg(smb_t* smb, smbmsg_t* msg, const uchar* text, BOOL updat
if(smb_findhash(smb, hashes, &found, SMB_HASH_SOURCE_DUPE, update)==SMB_SUCCESS && !update) {
retval=SMB_DUPE_MSG;
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"duplicate %s: %s found in message #%lu"
,__FUNCTION__" duplicate %s: %s found in message #%lu"
,smb_hashsourcetype(found.source)
,smb_hashsource(msg,found.source)
,found.number);
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
if((buf=(char*)malloc(sizeof(char)))==NULL) {
sprintf(smb->last_error
,"malloc failure of %" XP_PRIsize_t "u bytes for buffer"
,__FUNCTION__" malloc failure of %" XP_PRIsize_t "u bytes for buffer"
,sizeof(char));
return(NULL);
}
......@@ -67,7 +67,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
length=strlen(str)+2; /* +2 for crlf */
if((p=(char*)realloc(buf,l+length+1))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for comment buffer"
,__FUNCTION__" realloc failure of %ld bytes for comment buffer"
,l+length+1);
free(buf);
return(NULL);
......@@ -78,7 +78,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
if(l) { /* Add a blank line after comments */
if((p=(char*)realloc(buf,l+3))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for comment buffer"
,__FUNCTION__" realloc failure of %ld bytes for comment buffer"
,l+3);
free(buf);
return(NULL);
......@@ -94,7 +94,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
length = safe_snprintf(tmp, sizeof(tmp), "%2u: %s\r\n", ++answers, (char*)msg->hfield_dat[i]);
if((p=(char*)realloc(buf,l+length+1))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for comment buffer"
,__FUNCTION__" realloc failure of %ld bytes for comment buffer"
,l+length+1);
free(buf);
return(NULL);
......@@ -139,7 +139,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
continue;
if((lzhbuf=(char*)malloc(length))==NULL) {
sprintf(smb->last_error
,"malloc failure of %ld bytes for LZH buffer"
,__FUNCTION__" malloc failure of %ld bytes for LZH buffer"
,length);
free(buf);
return(NULL);
......@@ -148,7 +148,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
lzhlen=*(int32_t*)lzhbuf;
if((p=(char*)realloc(buf,l+lzhlen+3L))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for text buffer"
,__FUNCTION__" realloc failure of %ld bytes for text buffer"
,l+lzhlen+3L);
free(lzhbuf);
free(buf);
......@@ -162,7 +162,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
else {
if((p=(char*)realloc(buf,l+length+3L))==NULL) {
sprintf(smb->last_error
,"realloc failure of %ld bytes for text buffer"
,__FUNCTION__" realloc failure of %ld bytes for text buffer"
,l+length+3L);
free(buf);
return(NULL);
......
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