diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-04-18 02:17:46 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-04-18 02:17:46 +0000 |
commit | 75731f8c23ee20f5d345615b1398be1991fff0e4 (patch) | |
tree | 5e0cd0cdaca6b0a93638ad4281a4ca731b283c23 /source3 | |
parent | 9ff032320da86c88b481f68886cdda713ed136fa (diff) | |
download | samba-75731f8c23ee20f5d345615b1398be1991fff0e4.tar.gz samba-75731f8c23ee20f5d345615b1398be1991fff0e4.tar.bz2 samba-75731f8c23ee20f5d345615b1398be1991fff0e4.zip |
fixed some crash bugs in the nt forms parsing
(This used to be commit e505a6ddf3df37ca485cae117c53fa96d736f897)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_file.c | 2 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index f3e2879587..c3b444ffa1 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -371,6 +371,8 @@ char *file_load(char *fname, size_t *size) int fd; SMB_STRUCT_STAT sbuf; char *p; + + if (!fname || !*fname) return NULL; fd = open(fname,O_RDONLY); if (fd == -1) return NULL; diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 7cb2e9aab5..44f228880a 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -42,7 +42,9 @@ static BOOL parse_form_entry(char *line, nt_forms_struct *buf) char *tok[MAXTOK]; int count = 0; - tok[count] = strtok(line,":"); + tok[0] = strtok(line,":"); + + if (!tok[0]) return False; /* strip the comment lines */ if (tok[0][0]=='#') return (False); @@ -53,7 +55,7 @@ static BOOL parse_form_entry(char *line, nt_forms_struct *buf) count++; } - DEBUG(106,("Found [%d] tokens\n", count)); + if (count < MAXTOK-1) return False; StrnCpy(buf->name,tok[NAMETOK],sizeof(buf->name)-1); buf->flag=atoi(tok[FLAGTOK]); @@ -83,11 +85,11 @@ int get_ntforms(nt_forms_struct **list) return(0); } + *list = NULL; + for (i=0; lines[i]; i++) { char *line = lines[i]; - DEBUG(105,("%s\n",line)); - *list = Realloc(*list, sizeof(nt_forms_struct)*(total+1)); if (! *list) { @@ -104,8 +106,6 @@ int get_ntforms(nt_forms_struct **list) file_lines_free(lines); - DEBUG(104,("%d info lines on %d\n",total, grandtotal)); - return(total); } |