Swen Schillig
58e2c15344
libcli: Use wrapper for string to integer conversion
...
In order to detect an value overflow error during
the string to integer conversion with strtoul/strtoull,
the errno variable must be set to zero before the execution and
checked after the conversion is performed. This is achieved by
using the wrapper function strtoul_err and strtoull_err.
Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-01 00:32:11 +00:00
Volker Lendecke
c2b9b574b2
lib: Make dom_sid_string_buf static
...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Nov 3 00:23:31 CET 2018 on sn-devel-144
2018-11-03 00:23:31 +01:00
Volker Lendecke
8b9d362219
lib: Add dom_sid_str_buf
...
This is modeled after server_id_str_buf, which as an API to me is easier to
use: I can rely on the compiler to get the buffer size right.
It is designed to violate README.Coding's "Make use of helper variables", but
as this API is simple enough and the output should never be a surprise at all,
I think that's worth it.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Nov 2 20:11:11 CET 2018 on sn-devel-144
2018-11-02 20:11:11 +01:00
Volker Lendecke
831ee63f54
lib: Add error checks in dom_sid_string_buf
...
Also, avoid casts by using PRIxxx macros
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-02 17:03:26 +01:00
Volker Lendecke
74de5a5d25
lib: Avoid an "includes.h"
...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-10-25 17:58:24 +02:00
Stefan Metzmacher
8a1c930e1b
libcli/security: add dom_sid_is_valid_account_domain()
...
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-03-19 20:30:52 +01:00
Ralph Boehme
a58b54a334
libcli/security: fix dom_sid_in_domain()
...
Ensure the SID has exactly one component more then the domain SID, eg
Domain SID: S-1-5-21-1-2-3
SID: S-1-5-21-1-2-3-4
This will return true. If the SID has more components, eg
SID: S-1-5-21-1-2-3-4-5, or
SID: S-1-5-21-1-2-3-4-5-6-7-8
dom_sid_in_domain() must return false.
This was verified against Windows:
lsa_LookupSids: struct lsa_LookupSids
out: struct lsa_LookupSids
domains : *
domains : *
domains: struct lsa_RefDomainList
count : 0x00000002 (2)
domains : *
domains: ARRAY(2)
domains: struct lsa_DomainInfo
name: struct lsa_StringLarge
length : 0x000e (14)
size : 0x0010 (16)
string : *
string : 'BUILTIN'
sid : *
sid : S-1-5-32
domains: struct lsa_DomainInfo
name: struct lsa_StringLarge
length : 0x0012 (18)
size : 0x0014 (20)
string : *
string : 'W4EDOM-L4'
sid : *
sid : S-1-5-21-278041429-3399921908-1452754838
max_size : 0x00000020 (32)
names : *
names: struct lsa_TransNameArray
count : 0x00000004 (4)
names : *
names: ARRAY(4)
names: struct lsa_TranslatedName
sid_type : SID_NAME_USER (1)
name: struct lsa_String
length : 0x001a (26)
size : 0x001a (26)
string : *
string : 'Administrator'
sid_index : 0x00000001 (1)
names: struct lsa_TranslatedName
sid_type : SID_NAME_UNKNOWN (8)
name: struct lsa_String
length : 0x005c (92)
size : 0x005e (94)
string : *
string : 'S-1-5-21-278041429-3399921908-1452754838-500-1'
sid_index : 0xffffffff (4294967295)
names: struct lsa_TranslatedName
sid_type : SID_NAME_ALIAS (4)
name: struct lsa_String
length : 0x001c (28)
size : 0x001c (28)
string : *
string : 'Administrators'
sid_index : 0x00000000 (0)
names: struct lsa_TranslatedName
sid_type : SID_NAME_UNKNOWN (8)
name: struct lsa_String
length : 0x001c (28)
size : 0x001e (30)
string : *
string : 'S-1-5-32-544-9'
sid_index : 0xffffffff (4294967295)
count : *
count : 0x00000002 (2)
result : STATUS_SOME_UNMAPPED
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-04-12 01:41:14 +02:00
Volker Lendecke
a5902383e3
lib: Make dom_sid_parse_endp init "endp" on all "ok" paths
...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-12-06 20:24:22 +01:00
Jeremy Allison
688aae8bac
s4: Fix bad review I did in dom_sid_parse_length() code.
...
Volker, apologies for the mistake.
Spotted by Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Apr 29 08:20:23 CEST 2015 on sn-devel-104
2015-04-29 08:20:23 +02:00
Volker Lendecke
b2c34d45c0
lib: Simplify dom_sid_parse_length
...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-28 18:11:13 +02:00
Volker Lendecke
f4e358bc8b
libcli: Add a NULL check in dom_sid_string
...
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jun 10 21:46:15 CEST 2014 on sn-devel-104
2014-06-10 21:46:15 +02:00
Jeff Layton
edd3302ad4
libcli: fix conversion logic in dom_sid_string_buf
...
Signed-off-by: Jeff Layton <jlayton@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-07-31 15:16:11 -07:00
Jeff Layton
34d3639305
libcli: fix conversion logic in dom_sid_parse_endp
...
Signed-off-by: Jeff Layton <jlayton@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-07-31 15:16:08 -07:00
Volker Lendecke
b9a727c5f1
Tiny simplification to dom_sid_string_buf
...
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Tue May 31 23:16:31 CEST 2011 on sn-devel-104
2011-05-31 23:16:31 +02:00
Volker Lendecke
d4c693df98
Add dom_sid_parse_endp
...
This returns a pointer to the first non-parsed character, along the lines of
strtoul for example.
Signed-off-by: Jeremy Allison <jra@samba.org>
2011-04-13 14:13:24 -07:00
Volker Lendecke
70517477f8
Add dom_sid_string_buf
...
This prints into a fixed buffer with the same overflow semantics as snprintf
has: Return required string length, regardless of whether it fit or not.
2011-03-03 22:08:49 +01:00
Andrew Bartlett
a879a4610d
libcli/auth Merge source4/libcli/security and util_sid.c into the common code
...
This should ensure we only have one copy of these core functions
in the tree.
Andrew Bartlett
Signed-off-by: Andrew Tridgell <tridge@samba.org>
2010-10-14 02:35:05 +00:00
Günther Deschner
4006160179
libcli: add dom_sid_compare_domain()
...
Guenther
2010-09-20 14:03:13 -07:00
Jeremy Allison
55b315094e
Fix string_to_sid() to allow non '\0' termination of the string - allows
...
string_to_sid() to be used in formatted strings like FOO/S-1-5-XXXX-YYYY/BAR.
Jeremy.
2010-09-14 14:48:50 -07:00
Andrew Bartlett
46f585e364
libcli/security Use sid_append_rid() in dom_sid_append_rid()
...
This ensures that the maximum number of sub-authorities is respected,
otherwise we may run off the end of the array.
Andrew Bartlett
2010-09-14 14:48:49 -07:00
Andrew Bartlett
51ecf79654
libcli/security Merge source3/ string_to_sid() to common code
...
The source3 code repsects the limit of a maximum of 15 subauths,
while the source4 code does not, creating a security issue as
we parse string-form SIDs from clients.
Andrew Bartlett
2010-09-14 14:48:49 -07:00
Matt Kraai
aa6a507e76
Change uint_t to unsigned int in libcli
...
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-02-02 07:18:17 +01:00
Volker Lendecke
005bbd0826
Revert "libcli/security: Remove a call to strncasecmp"
...
This reverts commit 7c687665ea
.
2010-01-25 16:45:32 +01:00
Volker Lendecke
d86d5be636
Revert "libcli/security: Convert some strtol calls to strtoul"
...
This reverts commit 7fe66e06c4
.
2010-01-25 16:45:32 +01:00
Volker Lendecke
fa47dbb57a
Revert "libcli/security: Fix a valgrind error in dom_sid_parse"
...
This reverts commit f1c889a4e6
.
2010-01-25 16:45:31 +01:00
Volker Lendecke
a53a8ec452
Revert "libcli/security: Prohibit SID formats like S-1-5-32-+545"
...
This reverts commit 1fbeae4165
.
Apparently this breaks the build of Samba4
2010-01-25 12:40:51 +01:00
Volker Lendecke
1fbeae4165
libcli/security: Prohibit SID formats like S-1-5-32-+545
2010-01-23 16:28:11 +01:00
Volker Lendecke
f1c889a4e6
libcli/security: Fix a valgrind error in dom_sid_parse
2010-01-23 16:28:11 +01:00
Volker Lendecke
7fe66e06c4
libcli/security: Convert some strtol calls to strtoul
...
This tightens the dom_sid_parse syntax check a bit: "--" would have been
allowed in sid string
2010-01-23 16:28:11 +01:00
Volker Lendecke
7c687665ea
libcli/security: Remove a call to strncasecmp
2010-01-23 16:28:11 +01:00
Volker Lendecke
e304a623f1
Add missing include to shut up missing prototype warnings
2009-02-14 22:00:44 +01:00
Kai Blin
d936be23cd
s3: Fix the non-merged build.
2009-02-01 20:49:07 +01:00
Kai Blin
07aa05f678
shared: Move dom_sid_* utility functions to top level
2009-02-01 19:42:30 +01:00