diff options
Diffstat (limited to 'crypto/heimdal/lib/sl/ss.c')
-rw-r--r-- | crypto/heimdal/lib/sl/ss.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/crypto/heimdal/lib/sl/ss.c b/crypto/heimdal/lib/sl/ss.c index f3c0546..7655a9e 100644 --- a/crypto/heimdal/lib/sl/ss.c +++ b/crypto/heimdal/lib/sl/ss.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -35,7 +35,7 @@ #include <com_err.h> #include "ss.h" -RCSID("$Id: ss.c,v 1.4 1999/12/02 16:58:55 joda Exp $"); +RCSID("$Id: ss.c,v 1.6 2000/05/25 00:14:58 assar Exp $"); struct ss_subst { char *name; @@ -55,14 +55,34 @@ ss_create_invocation(const char *subsystem, int *code) { struct ss_subst *ss; + if(num_subsystems >= sizeof(subsystems) / sizeof(subsystems[0])) { *code = 17; return 0; } ss = &subsystems[num_subsystems]; - ss->name = subsystem ? strdup(subsystem) : NULL; - ss->version = version ? strdup(version) : NULL; - ss->info = info ? strdup(info) : NULL; + ss->name = ss->version = ss->info = NULL; + if (subsystem != NULL) { + ss->name = strdup (subsystem); + if (ss->name == NULL) { + *code = ENOMEM; + return 0; + } + } + if (version != NULL) { + ss->version = strdup (version); + if (ss->version == NULL) { + *code = ENOMEM; + return 0; + } + } + if (info != NULL) { + ss->info = strdup (info); + if (ss->info == NULL) { + *code = ENOMEM; + return 0; + } + } ss->table = table; *code = 0; return num_subsystems++; @@ -87,8 +107,12 @@ int ss_execute_command(int index, char **argv) { int argc = 0; + int ret; + while(argv[argc++]); - sl_command(subsystems[index].table, argc, argv); + ret = sl_command(subsystems[index].table, argc, argv); + if (ret == SL_BADCOMMAND) + return SS_ET_COMMAND_NOT_FOUND; return 0; } @@ -98,10 +122,15 @@ ss_execute_line (int index, const char *line) char *buf = strdup(line); int argc; char **argv; + int ret; + if (buf == NULL) + return ENOMEM; sl_make_argv(buf, &argc, &argv); - sl_command(subsystems[index].table, argc, argv); + ret = sl_command(subsystems[index].table, argc, argv); free(buf); + if (ret == SL_BADCOMMAND) + return SS_ET_COMMAND_NOT_FOUND; return 0; } @@ -109,9 +138,9 @@ int ss_listen (int index) { char *prompt = malloc(strlen(subsystems[index].name) + 3); - if(prompt == NULL) { - abort(); - } + if (prompt == NULL) + return ENOMEM; + strcpy(prompt, subsystems[index].name); strcat(prompt, ": "); sl_loop(subsystems[index].table, prompt); |