summaryrefslogtreecommitdiff
path: root/source3/libsmb/nterr.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-06-24 18:58:08 +0000
committerLuke Leighton <lkcl@samba.org>1999-06-24 18:58:08 +0000
commitcae3620b2e8abbe35f0369a82d5461cb596475a3 (patch)
tree1f0e36b2a99fd2bb9cce280a0b35f4d3c17f9802 /source3/libsmb/nterr.c
parent07afc549e2cde45e1c5b536cc03903fe8765902f (diff)
downloadsamba-cae3620b2e8abbe35f0369a82d5461cb596475a3.tar.gz
samba-cae3620b2e8abbe35f0369a82d5461cb596475a3.tar.bz2
samba-cae3620b2e8abbe35f0369a82d5461cb596475a3.zip
safe string error reporting functions (found a potential buffer overflow
of a pstrcpy into an fstring). (This used to be commit ac0060443de800fec9042b69b299ff2e9128a31c)
Diffstat (limited to 'source3/libsmb/nterr.c')
-rw-r--r--source3/libsmb/nterr.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
index b094050a33..9cf1fb8214 100644
--- a/source3/libsmb/nterr.c
+++ b/source3/libsmb/nterr.c
@@ -521,12 +521,11 @@ nt_err_code_struct nt_errs[] =
/*****************************************************************************
returns an NT error message. not amazingly helpful, but better than a number.
*****************************************************************************/
-char *get_nt_error_msg(uint32 nt_code)
+void get_safe_nt_error_msg(uint32 nt_code, char *msg, size_t len)
{
- static pstring msg;
int idx = 0;
- snprintf(msg, sizeof(msg), "%08x", nt_code);
+ snprintf(msg, len, "NT code %08x", nt_code);
nt_code &= 0xFFFF;
@@ -534,11 +533,19 @@ char *get_nt_error_msg(uint32 nt_code)
{
if (nt_errs[idx].nt_errcode == nt_code)
{
- pstrcpy(msg, nt_errs[idx].nt_errstr);
- return msg;
+ safe_strcpy(msg, nt_errs[idx].nt_errstr, len);
+ return;
}
idx++;
}
- return msg;
}
+/*****************************************************************************
+ returns an NT error message. not amazingly helpful, but better than a number.
+ *****************************************************************************/
+char *get_nt_error_msg(uint32 nt_code)
+{
+ static pstring msg;
+ get_safe_nt_error_msg(nt_code, msg, sizeof(msg));
+ return msg;
+}