1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

122 Commits

Author SHA1 Message Date
Jeremy Allison
3634e20c76 s3: lib: nmbname: Ensure we limit the NetBIOS name correctly. CID: 1433607
Firstly, make the exit condition from the loop explicit (we must
never write into byte n, where n >= sizeof(name->name).

Secondly ensure exiting from the loop that n==MAX_NETBIOSNAME_LEN,
as this is the sign of a correct NetBIOS name encoding (RFC1002)
in order to properly read the NetBIOS name type (which is always
encoded in byte 16 == name->name[15]).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>

Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Tue Nov 13 20:54:56 CET 2018 on sn-devel-144
2018-11-13 20:54:56 +01:00
Andreas Schneider
ba3e21cea0 s3:libsmb: Fix size types in nmblib
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-20 23:16:15 +01:00
Volker Lendecke
d4f7d9e08c libnmb: Fix CID 1428474 Incorrect expression (COPY_PASTE_ERROR)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jan 25 01:53:53 CET 2018 on sn-devel-144
2018-01-25 01:53:53 +01:00
Volker Lendecke
7ea5d38a69 libnmb: Move "read_packet" to nmbd
It's only used there

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): Wed Jan 24 05:48:19 CET 2018 on sn-devel-144
2018-01-24 05:48:19 +01:00
Volker Lendecke
45aec7d3a2 libnmb: Add "parse_packet_talloc"
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-01-24 00:58:17 +01:00
Richard Sharpe
5c1f8adc33 Convert all uint32/16/8 to _t in source3/libsmb.
Signed-off-by: Richard Sharpe <rsharpe@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-13 19:11:23 +02:00
Andreas Schneider
93d2847bf4 s3-libsmb: Remove check if array is NULL.
rdata is an array with data. rdlength defines how big rdata is. So if
rdlength is not set we have a big problem.

Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
2012-12-21 13:56:01 +01:00
Jeremy Allison
526e875cec Check error returns from strupper_m() (in all reasonable places). 2012-08-09 12:06:54 -07:00
Andrew Bartlett
f348d148b4 s3-param Remove special case for global_scope()
There is no reason this can't be a normal constant string in the
loadparm system.  (Past reasons were that we didn't have lp_set_cmdline())

Andrew Bartlett
2011-06-09 12:40:09 +02:00
Jeremy Allison
02af307585 More simple const fixes. 2011-05-05 23:56:07 +02:00
Jeremy Allison
a3e913ae8b Add in bufflen limit when storing NetBIOS names. Remove safe_strcpy. 2011-05-04 12:12:15 -07:00
Günther Deschner
2473c2fb1b s3-libsmb: put namequery headers to nmblib.h
We might find a better name for it and merge other namequery related things as
well here...

Guenther
2011-03-30 01:13:09 +02:00
Stefan Metzmacher
7eedf69bc9 s3: Remove unused receive_packet 2011-02-28 16:40:19 +01:00
Volker Lendecke
2672101cc4 s3: Remove some unused code 2011-01-07 13:28:07 +01:00
Volker Lendecke
d801d4da2d s3: Add packet_trn_id() 2011-01-07 13:28:04 +01:00
Volker Lendecke
444dcc59c2 s3: Add some const to name_mangle() 2010-12-22 16:39:14 +01:00
Günther Deschner
b38d0542e1 samba: share select wrappers.
Guenther
2010-10-01 22:30:22 +02:00
Jeremy Allison
03841f9e44 Fix bug #7698 - Assert causes smbd to panic on invalid NetBIOS session request.
Found by the CodeNomicon test suites at the SNIA plugfest.

http://www.codenomicon.com/

If an invalid NetBIOS session request is received the code in name_len() in
libsmb/nmblib.c can hit an assert.

Re-write name_len() and name_extract() to use "buf/len" pairs and
always limit reads.

Jeremy.
2010-09-26 03:01:03 -07:00
Andrew Tridgell
8120bc2ba9 s3-lib: use TYPESAFE_QSORT() in remaining s3 library code
the sort_query_replies() in nmblib.c is a TODO. It uses a hack that
treats a char* as a structure. I've left that one alone for now.
2010-02-14 18:44:20 +11:00
Stefan Metzmacher
30a1bc3650 s3:nmbd: also listen explicit on the subnet broadcast addresses
And send replies always via the unicast address of the subnet.

This behavior is off by default (as before)
and can be enabled with "nmbd:bind explicit broadcast = yes".

metze
2010-02-08 18:35:10 +01:00
Volker Lendecke
dbc79381a8 Convert name_mangle() to use talloc 2009-02-24 20:40:46 +01:00
Volker Lendecke
7c3497ef5e Remove two write-only variables
If someone wants those stats, please don't use globals :-)
2008-12-19 13:18:57 +01:00
Volker Lendecke
8da1e033a8 Pass specific packets to build_nmb and build_dgram
To me it was not clear what parts of struct packet_struct are actually used in
build_packet(). This makes it a bit more clear that only the specific parts are
used.
(This used to be commit eb8b6f2404)
2008-03-08 12:31:21 +01:00
Volker Lendecke
a37873490f packet_struct is used in several places as raw memory
-> Fix more uninitialized variable warnings
(This used to be commit 0af02db6f2)
2007-12-19 17:15:45 +01:00
Volker Lendecke
195d6be38d remove some statics
(This used to be commit 97c9a4042d)
2007-12-05 14:39:07 +01:00
Jeremy Allison
f88b7a076b This is a large patch (sorry). Migrate from struct in_addr
to struct sockaddr_storage in most places that matter (ie.
not the nmbd and NetBIOS lookups). This passes make test
on an IPv4 box, but I'll have to do more work/testing on
IPv6 enabled boxes. This should now give us a framework
for testing and finishing the IPv6 migration. It's at
the state where someone with a working IPv6 setup should
(theorecically) be able to type :
smbclient //ipv6-address/share
and have it work.
Jeremy.
(This used to be commit 98e154c312)
2007-10-24 14:16:54 -07:00
Jeremy Allison
30191d1a57 RIP BOOL. Convert BOOL -> bool. I found a few interesting
bugs in various places whilst doing this (places that assumed
BOOL == int). I also need to fix the Samba4 pidl generation
(next checkin).
Jeremy.
(This used to be commit f35a266b3c)
2007-10-18 17:40:25 -07:00
Jeremy Allison
3dbb3d4c26 r25510: Now we're returning the port instead of using a global,
remember to use ntohs. Hopefully will fix the build farm.
Jeremy.
(This used to be commit 5174acccb5)
2007-10-10 12:31:11 -05:00
Jeremy Allison
0d87820380 r25492: Start adding IPv6 compatible code to lib/util_sock.c and deal with
the ripple effects this causes. utmp has to change etc. Remove some
global varables and store address/port in the unexpected db.
Jeremy.
(This used to be commit 18c6a2211d)
2007-10-10 12:31:09 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc)
2007-10-10 12:28:22 -05:00
Jeremy Allison
d824b98f80 r23779: Change from v2 or later to v3 or later.
Jeremy.
(This used to be commit 407e6e695b)
2007-10-10 12:28:20 -05:00
Günther Deschner
351e749246 r15240: Correctly disallow unauthorized access when logging on with the
kerberized pam_winbind and workstation restrictions are in effect.

The krb5 AS-REQ needs to add the host netbios-name in the address-list.

We don't get the clear NT_STATUS_INVALID_WORKSTATION code back yet from
the edata of the KRB_ERROR but the login at least fails when the local
machine is not in the workstation list on the DC.

Guenther
(This used to be commit 8b2ba11508)
2007-10-10 11:16:29 -05:00
Jeremy Allison
83b987befd r12107: Move to a tdb-based wins database. At the moment we still
use it as though it were an in-memory db and dump out to
a flat file every 2 mins, but that can now change.
Jeremy.
(This used to be commit a342681792)
2007-10-10 11:05:45 -05:00
Herb Lewis
978ca84860 r6225: get rid of warnings from my compiler about nested externs
(This used to be commit efea76ac71)
2007-10-10 10:56:30 -05:00
Jeremy Allison
acf9d61421 r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with
malloc checking.
HEAD patch to follow.
Jeremy.
(This used to be commit 620f2e608f)
2007-10-10 10:53:32 -05:00
Jeremy Allison
571cc4811b r2224: Make nmbd more robust against bad netbios packets.
Jeremy.
(This used to be commit dd9b17abd6)
2007-10-10 10:52:36 -05:00
Herb Lewis
84cea46162 r776: I should have just cut and pasted from my build area and I would
have gotten this right :-)
(This used to be commit 548070274e)
2007-10-10 10:51:37 -05:00
Herb Lewis
bb8a4a7991 r775: merge trunk 774 to samba 3_0 - fix bad compare in for loop
(This used to be commit 3cb8f1d535)
2007-10-10 10:51:37 -05:00
Jeremy Allison
a0034d3586 Ensure we don't truncate strcmps to nstring anymore...
Jeremy.
(This used to be commit d7cf64b1e4)
2004-03-13 02:47:21 +00:00
Jeremy Allison
6b9dbbcd24 Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (MORIYAMA Masayuki).
Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios
and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name
when represented in dos charset (ie. cp932). So go back to using fstrings for these but
translate into nstrings (ie. 16 byte length values) for transport on the wire.
Jeremy.
(This used to be commit b4ea493599)
2004-03-13 02:16:21 +00:00
Jeremy Allison
fd2d4f87d4 First part of patch from moriyama@miraclelinux.com (MORIYAMA Masayuki) to
fix up netbios names with mb strings. Includes reformat of libsmb/nmblib.c
so it's readable.
Jeremy.
(This used to be commit 966e49a48c)
2004-03-13 00:28:53 +00:00
Herb Lewis
220d663b74 if we are truncating to the . we need to start at the beginning in case
there are multiple "."'s in the name.

This code is protected with an #ifdef TRUNCATE_NETBIOS_NAME and this
is #define'd to 1 directly above. Should we also get rid of the #ifdef?
(This used to be commit 0375dace24)
2004-03-12 21:35:15 +00:00
Jeremy Allison
9fdc1363be Fix the character set handling properly in nmbd. Also fix bug where
iconv wasn't re-initialised on reading of "charset" parameters. This
caused workgroup name to be set incorrectly if it contained an
extended character.
Jeremy.
(This used to be commit 84ae44678a)
2003-08-27 01:25:01 +00:00
Jeremy Allison
5dfeda0002 Use correct size (17 not 16) when doing a push_ascii(). Ensure that
wins hook is called with unix charset.
Jeremy.
(This used to be commit ecb8057387)
2003-08-22 21:41:50 +00:00
Jeremy Allison
647a048ad0 Ensure nmb_namestr() converts back from CH_DOS to CH_UNIX.
Jeremy.
(This used to be commit eb79272743)
2003-08-22 00:26:37 +00:00
Andrew Bartlett
1478bcd847 Try again to fix up 'session request' name exchange. This time we actualy
get the names...

Andrew Bartlett
(This used to be commit 7c9e204f7e)
2003-07-27 03:29:40 +00:00
Andrew Bartlett
455bb6de90 Some small fixes to our charset conversion code:
- Treat the NMB names in the 'session request' packet as 'ASCII'.  This means
   that we do not get invalid multibyte from the wire, even if we truncate
   in the conversion.  (Otherwise we panic when we try to strupper_m it).

 - Remove acnv_uxu2(), as it was duplicated by push_ucs2_allocate()
 - Remove acnv_dosu2(), as it is not used.

 - In push_ucs2(), with the STR_UPPER flag, do the case conversion *after*
   the UCS2 conversion, when it we know that the length can't change.  Also
   faster, as we don't need to do another 2 UCS2 conversions.

Andrew Bartlett
(This used to be commit 912035af11)
2003-07-27 02:28:25 +00:00
Jeremy Allison
ce72beb2b5 Removed strupper/strlower macros that automatically map to strupper_m/strlower_m.
I really want people to think about when they're using multibyte strings.
Jeremy.
(This used to be commit ff222716a0)
2003-07-03 19:11:31 +00:00
Andrew Tridgell
49d71c7e7b fixed a pstrcpy() that is not on a pstring
(This used to be commit f644b3d6d2)
2003-06-06 05:31:30 +00:00
Andrew Bartlett
634c54310c Merge from HEAD - make Samba compile with -Wwrite-strings without additional
warnings.  (Adds a lot of const).

Andrew Bartlett
(This used to be commit 3a7458f947)
2003-01-03 08:28:12 +00:00