summaryrefslogtreecommitdiff
path: root/source3/smbd/mangle.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-09-03 03:14:31 +0000
committerAndrew Tridgell <tridge@samba.org>1998-09-03 03:14:31 +0000
commit0b5cc173099c7fd5ea4865ef4197739ec87e4c35 (patch)
tree78628f6843f0685683573efafc710540f4953e50 /source3/smbd/mangle.c
parent0067ea1b5a634db442ed8f89558dc4d43d9f3fe6 (diff)
downloadsamba-0b5cc173099c7fd5ea4865ef4197739ec87e4c35.tar.gz
samba-0b5cc173099c7fd5ea4865ef4197739ec87e4c35.tar.bz2
samba-0b5cc173099c7fd5ea4865ef4197739ec87e4c35.zip
fixed a bug in the name mangling code. It implicitly assumed that
mangling a name can't increase it's size which isn't true. (imagine a file called "L B" which mangles to "LB~XX") The symptoms were that users couldn't run batch files from short directory names that contained non 8.3 characters (such as spaces). (This used to be commit c319d8ea3f8b42bb3a8e501642971ed0bdb21583)
Diffstat (limited to 'source3/smbd/mangle.c')
-rw-r--r--source3/smbd/mangle.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c
index 0703a4a74e..0a3d3f54eb 100644
--- a/source3/smbd/mangle.c
+++ b/source3/smbd/mangle.c
@@ -799,12 +799,12 @@ static void do_fwd_mangled_map(char *s, char *MangledMap)
}
} /* do_fwd_mangled_map */
-/* ************************************************************************** **
+/*****************************************************************************
* do the actual mangling to 8.3 format
- *
- * ************************************************************************** **
+ * the buffer must be able to hold 13 characters (including the null)
+ *****************************************************************************
*/
-void mangle_name_83( char *s, int s_len )
+void mangle_name_83( char *s)
{
int csum = str_checksum(s);
char *p;
@@ -907,7 +907,7 @@ void mangle_name_83( char *s, int s_len )
csum = csum % (36*36);
- (void)slprintf( s, s_len - 1, "%s%c%c%c",
+ (void)slprintf(s, 12, "%s%c%c%c",
base, magic_char, base36( csum/36 ), base36( csum ) );
if( *extension )
@@ -917,12 +917,13 @@ void mangle_name_83( char *s, int s_len )
}
DEBUG( 5, ( "%s\n", s ) );
+
} /* mangle_name_83 */
-/* ************************************************************************** **
+/*****************************************************************************
* Convert a filename to DOS format. Return True if successful.
*
- * Input: OutName - Source *and* destination buffer.
+ * Input: OutName - Source *and* destination buffer.
*
* NOTE that OutName must point to a memory space that
* is at least 13 bytes in size!
@@ -939,47 +940,46 @@ void mangle_name_83( char *s, int s_len )
* Output: Returns False only if the name wanted mangling but the share does
* not have name mangling turned on.
*
- * ************************************************************************** **
+ * ****************************************************************************
*/
-BOOL name_map_mangle( char *OutName, BOOL need83, int snum )
- {
- DEBUG(5,
- ("name_map_mangle( %s, %s, %d )\n", OutName, need83?"TRUE":"FALSE", snum) );
+BOOL name_map_mangle(char *OutName, BOOL need83, int snum)
+{
+ char *map;
+ DEBUG(5,("name_map_mangle( %s, %s, %d )\n",
+ OutName, need83?"TRUE":"FALSE", snum));
#ifdef MANGLE_LONG_FILENAMES
- if( !need83 && is_illegal_name(OutName) )
- need83 = True;
+ if( !need83 && is_illegal_name(OutName) )
+ need83 = True;
#endif
- /* apply any name mappings */
- {
- char *map = lp_mangled_map( snum );
+ /* apply any name mappings */
+ map = lp_mangled_map(snum);
- if( map && *map )
- do_fwd_mangled_map( OutName, map );
- }
+ if (map && *map) {
+ do_fwd_mangled_map( OutName, map );
+ }
- /* check if it's already in 8.3 format */
- if( need83 && !is_8_3( OutName, True ) )
- {
- char *tmp; /* kludge -- mangle_name_83() overwrites the source string */
- /* but cache_mangled_name() needs both. crh 09-Apr-1998 */
+ /* check if it's already in 8.3 format */
+ if (need83 && !is_8_3(OutName, True)) {
+ char *tmp;
- if( !lp_manglednames( snum ) )
- return( False );
+ if (!lp_manglednames(snum)) {
+ return(False);
+ }
- /* mangle it into 8.3 */
- tmp = strdup( OutName );
- mangle_name_83( OutName, strlen(OutName) );
- if( tmp )
- {
- cache_mangled_name( OutName, tmp );
- free( tmp );
- }
- }
+ /* mangle it into 8.3 */
+ tmp = strdup(OutName);
+ mangle_name_83(OutName);
- DEBUG( 5, ("name_map_mangle() ==> [%s]\n", OutName) );
- return( True );
- } /* name_map_mangle */
+ if(tmp) {
+ cache_mangled_name(OutName, tmp);
+ free(tmp);
+ }
+ }
+
+ DEBUG(5,("name_map_mangle() ==> [%s]\n", OutName));
+ return(True);
+} /* name_map_mangle */
/* ========================================================================== */