diff options
| author | Pavel Zakharov <pavel.zakharov@delphix.com> | 2017-04-13 14:40:12 -0700 |
|---|---|---|
| committer | Matthew Ahrens <mahrens@delphix.com> | 2017-04-13 20:43:13 -0700 |
| commit | adc68ba91854584a470224cdb128a8e1ba16b41b (patch) | |
| tree | c538d3e89485a4f4c4123019d3841f7607544e0e | |
| parent | 6b036259815954b7ad86d651af18efba672cb7a9 (diff) | |
| download | illumos-joyent-adc68ba91854584a470224cdb128a8e1ba16b41b.tar.gz | |
8062 memory leak in smb_unicode_init()
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
| -rw-r--r-- | usr/src/common/smbsrv/smb_string.c | 16 | ||||
| -rw-r--r-- | usr/src/uts/common/fs/smbsrv/smb_server.c | 2 | ||||
| -rw-r--r-- | usr/src/uts/common/smbsrv/string.h | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/usr/src/common/smbsrv/smb_string.c b/usr/src/common/smbsrv/smb_string.c index 8400c51ea1..3d2abc474b 100644 --- a/usr/src/common/smbsrv/smb_string.c +++ b/usr/src/common/smbsrv/smb_string.c @@ -23,6 +23,7 @@ * Use is subject to license terms. * * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #if defined(_KERNEL) || defined(_FAKE_KERNEL) @@ -50,6 +51,8 @@ static const smb_codepage_t *current_codepage = usascii_codepage; static boolean_t is_unicode = B_FALSE; +static smb_codepage_t *unicode_codepage = NULL; + static smb_codepage_t *smb_unicode_init(void); /* @@ -115,13 +118,14 @@ strcanon(char *buf, const char *class) void smb_codepage_init(void) { - const smb_codepage_t *cp; + smb_codepage_t *cp; if (is_unicode) return; if ((cp = smb_unicode_init()) != NULL) { current_codepage = cp; + unicode_codepage = cp; is_unicode = B_TRUE; } else { current_codepage = usascii_codepage; @@ -129,6 +133,16 @@ smb_codepage_init(void) } } +void +smb_codepage_fini(void) +{ + if (unicode_codepage != NULL) { + MEM_FREE("unicode", unicode_codepage); + unicode_codepage = NULL; + current_codepage = NULL; + } +} + /* * Determine whether or not a character is an uppercase character. * This function operates on the current codepage table. Returns diff --git a/usr/src/uts/common/fs/smbsrv/smb_server.c b/usr/src/uts/common/fs/smbsrv/smb_server.c index 176a35aae7..64699cc799 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_server.c +++ b/usr/src/uts/common/fs/smbsrv/smb_server.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ /* @@ -362,6 +363,7 @@ smb_server_g_fini(void) smb_node_fini(); smb_mbc_fini(); + smb_codepage_fini(); smb_kshare_g_fini(); smb_fem_fini(); diff --git a/usr/src/uts/common/smbsrv/string.h b/usr/src/uts/common/smbsrv/string.h index 14b9cac8b8..92c4fc91b4 100644 --- a/usr/src/uts/common/smbsrv/string.h +++ b/usr/src/uts/common/smbsrv/string.h @@ -21,6 +21,7 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2017 by Delphix. All rights reserved. */ #ifndef _SMBSRV_STRING_H @@ -113,6 +114,7 @@ typedef struct smb_codepage { } smb_codepage_t; void smb_codepage_init(void); +void smb_codepage_fini(void); int smb_isupper(int); int smb_islower(int); |
