summaryrefslogtreecommitdiff
path: root/source3/param
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-02-24 21:06:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:46 -0500
commit413eb87493d5f4c2ed8e1f674b223e270fcb3667 (patch)
tree2f8ea20c955039244beddd67447d6d28c4204531 /source3/param
parent584c412e0a87bb73d41e260f93b9915286888ba2 (diff)
downloadsamba-413eb87493d5f4c2ed8e1f674b223e270fcb3667.tar.gz
samba-413eb87493d5f4c2ed8e1f674b223e270fcb3667.tar.bz2
samba-413eb87493d5f4c2ed8e1f674b223e270fcb3667.zip
r5543: Fix for bug #962 - using MB sharenames containing a ']' character.
Processing a share name is now MB safe so long as the correct unix charset is in scope. Jeremy. (This used to be commit 5bd027e9ed095c01fc176178ff51b5839fe0c140)
Diffstat (limited to 'source3/param')
-rw-r--r--source3/param/params.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/source3/param/params.c b/source3/param/params.c
index 192223605a..9d21d25a24 100644
--- a/source3/param/params.c
+++ b/source3/param/params.c
@@ -107,6 +107,7 @@ typedef struct {
char *buf;
char *p;
size_t size;
+ char *end_section_p;
} myFILE;
static int mygetc(myFILE *f)
@@ -125,6 +126,22 @@ static void myfile_close(myFILE *f)
SAFE_FREE(f);
}
+/* Find the end of the section. We must use mb functions for this. */
+static int FindSectionEnd(myFILE *f)
+{
+ f->end_section_p = strchr_m(f->p, ']');
+ return f->end_section_p ? 1 : 0;
+}
+
+static int AtSectionEnd(myFILE *f)
+{
+ if (f->p == f->end_section_p + 1) {
+ f->end_section_p = NULL;
+ return 1;
+ }
+ return 0;
+}
+
/* -------------------------------------------------------------------------- **
* Functions...
*/
@@ -230,6 +247,13 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
/* character written to bufr[] is a space, then <end> */
/* will be one less than <i>. */
+
+ /* Find the end of the section. We must use mb functions for this. */
+ if (!FindSectionEnd(InFile)) {
+ DEBUG(0, ("%s No terminating ']' character in section.\n", func) );
+ return False;
+ }
+
c = EatWhitespace( InFile ); /* We've already got the '['. Scan */
/* past initial white space. */
@@ -247,20 +271,8 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
bSize += BUFR_INC;
}
- /* Handle a single character. */
+ /* Handle a single character other than section end. */
switch( c ) {
- case ']': /* Found the closing bracket. */
- bufr[end] = '\0';
- if( 0 == end ) {
- /* Don't allow an empty name. */
- DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
- return False;
- }
- if( !sfunc(bufr) ) /* Got a valid name. Deal with it. */
- return False;
- EatComment( InFile ); /* Finish off the line. */
- return True;
-
case '\n': /* Got newline before closing ']'. */
i = Continuation( bufr, i ); /* Check for line continuation. */
if( i < 0 ) {
@@ -284,6 +296,21 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(const char *) )
c = mygetc( InFile );
}
}
+
+ if (AtSectionEnd(InFile)) {
+ /* Got to the closing bracket. */
+ bufr[end] = '\0';
+ if( 0 == end ) {
+ /* Don't allow an empty name. */
+ DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
+ return False;
+ }
+ if( !sfunc(bufr) ) /* Got a valid name. Deal with it. */
+ return False;
+ EatComment( InFile ); /* Finish off the line. */
+ return True;
+ }
+
}
/* We arrive here if we've met the EOF before the closing bracket. */
@@ -513,6 +540,7 @@ static myFILE *OpenConfFile( const char *FileName )
}
ret->p = ret->buf;
+ ret->end_section_p = NULL;
return( ret );
}