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 | e505a6ddf3df37ca485cae117c53fa96d736f897 (patch) | |
tree | 378dc7d491f61c818b580a0cabb92ced658bbdce /source | |
parent | a0afe0d5f8378463b1e47cd779aee3af98c1940a (diff) | |
download | samba-e505a6ddf3df37ca485cae117c53fa96d736f897.tar.gz |
fixed some crash bugs in the nt forms parsing
Diffstat (limited to 'source')
-rw-r--r-- | source/lib/util_file.c | 2 | ||||
-rw-r--r-- | source/printing/nt_printing.c | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/source/lib/util_file.c b/source/lib/util_file.c index f3e28795874..c3b444ffa16 100644 --- a/source/lib/util_file.c +++ b/source/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/source/printing/nt_printing.c b/source/printing/nt_printing.c index 7cb2e9aab5a..44f228880a8 100644 --- a/source/printing/nt_printing.c +++ b/source/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); } |