summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>2004-01-28 23:13:22 +0000
committerChristopher R. Hertel <crh@samba.org>2004-01-28 23:13:22 +0000
commit8ce5bd47a346e8a8cc2cbd52e8fd71ee06799884 (patch)
tree2ef715f27eed49cc54b8465f42694dda63394003 /source3/smbd
parent381adaf5cfc6a8f5dcf65c25351d5996e89090f3 (diff)
downloadsamba-8ce5bd47a346e8a8cc2cbd52e8fd71ee06799884.tar.gz
samba-8ce5bd47a346e8a8cc2cbd52e8fd71ee06799884.tar.bz2
samba-8ce5bd47a346e8a8cc2cbd52e8fd71ee06799884.zip
This is Simo's patch for the NetShareEnum() bug which caused us to return
share names longer than 12 bytes. The function now filters out names longer than 12 bytes (which is compatible with Windows behavior). A better fix might be to store short names along with any names longer than 12 bytes, using a simple (very) name mangling. I'm committing in HEAD. If there are no problems this can easily be merged into 3.0.x. Chris -)----- (This used to be commit 6a8a64dc87863b39490d7f22a7d107e6916584f2)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/lanman.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index c53889a7a4..c4df84e76c 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1465,12 +1465,24 @@ static BOOL api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, char *para
}
/****************************************************************************
- view list of shares available
- ****************************************************************************/
-static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
- int mdrcnt,int mprcnt,
- char **rdata,char **rparam,
- int *rdata_len,int *rparam_len)
+ View the list of available shares.
+
+ This function is the server side of the NetShareEnum() RAP call.
+ It fills the return buffer with share names and share comments.
+ Note that the return buffer normally (in all known cases) allows only
+ twelve byte strings for share names (plus one for a nul terminator).
+ Share names longer than 12 bytes must be skipped.
+ ****************************************************************************/
+static BOOL api_RNetShareEnum( connection_struct *conn,
+ uint16 vuid,
+ char *param,
+ char *data,
+ int mdrcnt,
+ int mprcnt,
+ char **rdata,
+ char **rparam,
+ int *rdata_len,
+ int *rparam_len )
{
char *str1 = param+2;
char *str2 = skip_string(str1,1);
@@ -1490,7 +1502,9 @@ static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,c
data_len = fixed_len = string_len = 0;
for (i=0;i<count;i++)
- if (lp_browseable(i) && lp_snum_ok(i))
+ if( lp_browseable( i )
+ && lp_snum_ok( i )
+ && (strlen( lp_servicename( i ) ) < 13) ) /* Maximum name length. */
{
total++;
data_len += fill_share_info(conn,i,uLevel,0,&f_len,0,&s_len,0);
@@ -1511,10 +1525,16 @@ static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,c
p = *rdata;
f_len = fixed_len;
s_len = string_len;
- for (i = 0; i < count;i++)
- if (lp_browseable(i) && lp_snum_ok(i))
- if (fill_share_info(conn,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
+ for( i = 0; i < count; i++ )
+ {
+ if( lp_browseable( i )
+ && lp_snum_ok( i )
+ && (strlen( lp_servicename( i ) ) < 13) )
+ {
+ if( fill_share_info( conn,i,uLevel,&p,&f_len,&p2,&s_len,*rdata ) < 0 )
break;
+ }
+ }
*rparam_len = 8;
*rparam = REALLOC(*rparam,*rparam_len);
@@ -1527,7 +1547,7 @@ static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,c
counted,total,uLevel,
buf_len,*rdata_len,mdrcnt));
return(True);
-}
+} /* api_RNetShareEnum */
/****************************************************************************
Add a share