Index: uspace/app/bdsh/input.c
===================================================================
--- uspace/app/bdsh/input.c	(revision 25cfc3d7c6f3180e615788fae8d2903b184e1821)
+++ uspace/app/bdsh/input.c	(revision 455241b37bedd3719ed3b5b025fdf26f44fd565b)
@@ -86,6 +86,11 @@
  * the handler
  */
-static errno_t process_input_nohup(cliuser_t *usr, list_t *alias_hups)
-{
+static errno_t process_input_nohup(cliuser_t *usr, list_t *alias_hups, size_t count_executed_hups)
+{
+	if (count_executed_hups >= HUBS_MAX) {
+		cli_error(CL_EFAIL, "%s: maximal alias hubs reached\n", PACKAGE_NAME);
+		return ELIMIT;
+	}
+
 	token_t *tokens_buf = calloc(WORD_MAX, sizeof(token_t));
 	if (tokens_buf == NULL)
@@ -197,4 +202,10 @@
 		if (!find_alias_hup(data, alias_hups)) {
 			alias_hup_t *hup = (alias_hup_t *)calloc(1, sizeof(alias_hup_t));
+			if (hup == NULL) {
+				cli_error(CL_EFAIL, "%s: cannot allocate alias structure\n", PACKAGE_NAME);
+				rc = ENOMEM;
+				goto finit;
+			}
+
 			hup->alias = data;
 			list_append(&hup->alias_hup_link, alias_hups);
@@ -202,5 +213,11 @@
 			char *oldLine = usr->line;
 			const size_t input_length = str_size(usr->line) - str_size(cmd[0]) + str_size(data->value) + 1;
-			usr->line = (char *)malloc(input_length * sizeof(char));
+			usr->line = (char *)malloc(input_length);
+			if (usr->line == NULL) {
+				cli_error(CL_EFAIL, "%s: cannot allocate input structure\n", PACKAGE_NAME);
+				rc = ENOMEM;
+				goto finit;
+			}
+
 			usr->line[0] = '\0';
 
@@ -222,5 +239,5 @@
 
 			/* reprocess input after string replace */
-			rc = process_input_nohup(usr, alias_hups);
+			rc = process_input_nohup(usr, alias_hups, count_executed_hups + 1);
 			usr->line = oldLine;
 			goto finit;
@@ -287,5 +304,5 @@
 	list_initialize(&alias_hups);
 
-	errno_t rc = process_input_nohup(usr, &alias_hups);
+	errno_t rc = process_input_nohup(usr, &alias_hups, 0);
 
 	list_foreach_safe(alias_hups, cur_link, next_link) {
