From 017e0c8d95fe8212b006e1c14aef8d96fed30674 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2011 13:10:01 -0700 Subject: Fix simple uses of safe_strcpy -> strlcpy. Easy ones where we just remove -1. --- libcli/auth/smbencrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcli/auth/smbencrypt.c') diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c index 366f6df3ad..c59bc515ba 100644 --- a/libcli/auth/smbencrypt.c +++ b/libcli/auth/smbencrypt.c @@ -134,7 +134,7 @@ bool E_deshash(const char *passwd, uint8_t p16[16]) tmpbuf = strupper_talloc(mem_ctx, passwd); if (tmpbuf == NULL) { /* Too many callers don't check this result, we need to fill in the buffer with something */ - safe_strcpy((char *)dospwd, passwd, sizeof(dospwd)-1); + strlcpy((char *)dospwd, passwd, sizeof(dospwd)); E_P16(dospwd, p16); return false; } -- cgit From df023b8657cab232df88d3656aa5d87676bb7254 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2011 16:42:17 -0700 Subject: Tidy up some missing checks for NULL in strlcpy. --- libcli/auth/smbencrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcli/auth/smbencrypt.c') diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c index c59bc515ba..0cd836302b 100644 --- a/libcli/auth/smbencrypt.c +++ b/libcli/auth/smbencrypt.c @@ -134,7 +134,7 @@ bool E_deshash(const char *passwd, uint8_t p16[16]) tmpbuf = strupper_talloc(mem_ctx, passwd); if (tmpbuf == NULL) { /* Too many callers don't check this result, we need to fill in the buffer with something */ - strlcpy((char *)dospwd, passwd, sizeof(dospwd)); + strlcpy((char *)dospwd, passwd ? passwd : "", sizeof(dospwd)); E_P16(dospwd, p16); return false; } -- cgit From cd1d75c7a4f84e16c6da2d56ddcd42e285453d21 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 11 May 2011 11:57:10 +0200 Subject: libcli/auth/smbencrypt: in E_deshash, use talloc_stackframe instead of "#if _SAMBA_BUILD_ == 3" and talloc_tos() talloc_stackframe() is used in other shared components already, and if the stack is a talloc_pool, then in most cases, it should also not be more expensive than directly using talloc_tos(). Pair-Programmed-With: Stefan Metzmacher Autobuild-User: Volker Lendecke Autobuild-Date: Thu May 12 12:52:02 CEST 2011 on sn-devel-104 --- libcli/auth/smbencrypt.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'libcli/auth/smbencrypt.c') diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c index 0cd836302b..66fdbd25a8 100644 --- a/libcli/auth/smbencrypt.c +++ b/libcli/auth/smbencrypt.c @@ -118,7 +118,7 @@ bool E_deshash(const char *passwd, uint8_t p16[16]) { bool ret; uint8_t dospwd[14]; - TALLOC_CTX *mem_ctx; + TALLOC_CTX *frame = talloc_stackframe(); size_t converted_size; @@ -126,23 +126,19 @@ bool E_deshash(const char *passwd, uint8_t p16[16]) ZERO_STRUCT(dospwd); -#if _SAMBA_BUILD_ == 3 - mem_ctx = talloc_tos(); -#else - mem_ctx = NULL; -#endif - tmpbuf = strupper_talloc(mem_ctx, passwd); + tmpbuf = strupper_talloc(frame, passwd); if (tmpbuf == NULL) { /* Too many callers don't check this result, we need to fill in the buffer with something */ strlcpy((char *)dospwd, passwd ? passwd : "", sizeof(dospwd)); E_P16(dospwd, p16); + talloc_free(frame); return false; } ZERO_STRUCT(dospwd); ret = convert_string_error(CH_UNIX, CH_DOS, tmpbuf, strlen(tmpbuf), dospwd, sizeof(dospwd), &converted_size); - talloc_free(tmpbuf); + talloc_free(frame); /* Only the first 14 chars are considered, password need not * be null terminated. We do this in the error and success -- cgit