r7229: use socket_pending() to get rid of the max packet size limits in the
authorAndrew Tridgell <tridge@samba.org>
Fri, 3 Jun 2005 13:31:27 +0000 (13:31 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:29 +0000 (13:17 -0500)
nbt and dgram layers
(This used to be commit 2a9efbdae638a655999e07a7c3da97fd20dc056c)

source4/libcli/dgram/dgramsocket.c
source4/libcli/nbt/nbtsocket.c

index a3909df7686c81235c70963a1e0894541adec17d..88eed5c10b0eb3fa068090216609a59bdaddc4bb 100644 (file)
@@ -27,8 +27,6 @@
 #include "libcli/dgram/libdgram.h"
 #include "lib/socket/socket.h"
 
-#define DGRAM_MAX_PACKET_SIZE 2048
-
 
 /*
   handle recv events on a nbt dgram socket
@@ -40,11 +38,17 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock)
        const char *src_addr;
        int src_port;
        DATA_BLOB blob;
-       size_t nread;
+       size_t nread, dsize;
        struct nbt_dgram_packet *packet;
        const char *mailslot_name;
 
-       blob = data_blob_talloc(tmp_ctx, NULL, DGRAM_MAX_PACKET_SIZE);
+       status = socket_pending(dgmsock->sock, &dsize);
+       if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(tmp_ctx);
+               return;
+       }
+
+       blob = data_blob_talloc(tmp_ctx, NULL, dsize);
        if (blob.data == NULL) {
                talloc_free(tmp_ctx);
                return;
index 481327cc85fb15e0266f1967a052a874725a4aff..f600afb79fdc35678824c001aebe0766dfb5bee6 100644 (file)
@@ -26,7 +26,6 @@
 #include "libcli/nbt/libnbt.h"
 #include "lib/socket/socket.h"
 
-#define NBT_MAX_PACKET_SIZE 2048
 #define NBT_MAX_REPLIES 1000
 
 /*
@@ -157,11 +156,17 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
        const char *src_addr;
        int src_port;
        DATA_BLOB blob;
-       size_t nread;
+       size_t nread, dsize;
        struct nbt_name_packet *packet;
        struct nbt_name_request *req;
 
-       blob = data_blob_talloc(tmp_ctx, NULL, NBT_MAX_PACKET_SIZE);
+       status = socket_pending(nbtsock->sock, &dsize);
+       if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(tmp_ctx);
+               return;
+       }
+
+       blob = data_blob_talloc(tmp_ctx, NULL, dsize);
        if (blob.data == NULL) {
                talloc_free(tmp_ctx);
                return;