diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/smberr.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c index c2d8884d73..4fd9165c69 100644 --- a/source3/libsmb/smberr.c +++ b/source3/libsmb/smberr.c @@ -147,35 +147,48 @@ struct /**************************************************************************** return a SMB error string from a SMB buffer ****************************************************************************/ -char *smb_errstr(char *inbuf) +char *smb_err_msg(uint8 class, uint32 num) { - static pstring ret; - int class = CVAL(inbuf,smb_rcls); - int num = SVAL(inbuf,smb_err); - int i,j; + static pstring ret; + int i,j; - for (i=0;err_classes[i].class;i++) - if (err_classes[i].code == class) - { - if (err_classes[i].err_msgs) - { - err_code_struct *err = err_classes[i].err_msgs; - for (j=0;err[j].name;j++) - if (num == err[j].code) + for (i=0;err_classes[i].class;i++) + { + if (err_classes[i].code == class) { - if (DEBUGLEVEL > 0) - slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",err_classes[i].class, - err[j].name,err[j].message); - else - slprintf(ret, sizeof(ret) - 1, "%s - %s",err_classes[i].class,err[j].name); - return ret; + err_code_struct *err = err_classes[i].err_msgs; + if (err != NULL) + { + for (j=0;err[j].name;j++) + { + if (num == err[j].code) + { + if (DEBUGLEVEL > 0) + { + slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",err_classes[i].class, + err[j].name,err[j].message); + } + else + { + slprintf(ret, sizeof(ret) - 1, "%s - %s",err_classes[i].class,err[j].name); + } + return ret; + } + } + } + } - } - slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class,num); - return ret; - } - - slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num); - return(ret); + slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class, num); + return ret; + } + slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num); + return(ret); +} +/**************************************************************************** +return a SMB error string from a SMB buffer +****************************************************************************/ +char *smb_errstr(char *inbuf) +{ + return smb_err_msg(CVAL(inbuf,smb_rcls), SVAL(inbuf,smb_err)); } |