diff --git a/user/ftp/ftp/glob.c b/user/ftp/ftp/glob.c
index 72761ca..218fc6f 100644
--- a/user/ftp/ftp/glob.c
+++ b/user/ftp/ftp/glob.c
@@ -50,10 +50,18 @@ char glob_rcsid[] =
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "ftp_var.h"  /* for protos only */
 #include "glob.h"
 
+#if defined(_SC_ARG_MAX)
+# if defined(ARG_MAX)
+# undef ARG_MAX
+# endif
+# define ARG_MAX (sysconf(_SC_ARG_MAX))
+#endif
+
 #define	QUOTE 0200
 #define	TRIM 0177
 #define	eq(a,b)		(strcmp(a, b)==0)
@@ -115,7 +123,7 @@ char **
 ftpglob(const char *v)
 {
 	char agpath[BUFSIZ];
-	entry agargv[GAVSIZ];
+	entry *agargv;
 	centry vv[2];
 	vv[0].text = v;
 	vv[1].text = NULL;
@@ -133,6 +141,9 @@ ftpglob(const char *v)
 	/* added ()'s to sizeof, (ambigious math for the compiler) */
 	lastgpathp = agpath + (sizeof(agpath)- 2);
 
+	agargv = (entry *)malloc(sizeof (entry) * GAVSIZ);
+	if (agargv == NULL) fatal("Out of memory");
+
 	ginit(agargv); 
 	globcnt = 0;
 	collect(v);
@@ -674,6 +685,7 @@ efree(entry *av)
 {
     int i;
     for (i=0; av[i].text; i++) free(av[i].text);
+    free((void*)av);
 }
 
 static
diff --git a/user/thttpd/extras/htpasswd.c b/user/thttpd/extras/htpasswd.c
index e01ea1d..9bcae4b 100644
--- a/user/thttpd/extras/htpasswd.c
+++ b/user/thttpd/extras/htpasswd.c
@@ -49,7 +49,7 @@ static void getword(char *word, char *line, char stop) {
     while((line[y++] = line[x++]));
 }
 
-static int getline(char *s, int n, FILE *f) {
+static int local_getline(char *s, int n, FILE *f) {
     register int i=0;
 
     while(1) {
@@ -189,7 +189,7 @@ int main(int argc, char *argv[]) {
     strcpy(user,argv[2]);
 
     found = 0;
-    while(!(getline(line,MAX_STRING_LEN,f))) {
+    while(!(local_getline(line,MAX_STRING_LEN,f))) {
         if(found || (line[0] == '#') || (!line[0])) {
             putline(tfp,line);
             continue;
diff --git a/vendors/AtmarkTechno/Armadillo-4x0.Common/swmgr/main.c b/vendors/AtmarkTechno/Armadillo-4x0.Common/swmgr/main.c
index 069a8fb..eee1984 100644
--- a/vendors/AtmarkTechno/Armadillo-4x0.Common/swmgr/main.c
+++ b/vendors/AtmarkTechno/Armadillo-4x0.Common/swmgr/main.c
@@ -15,6 +15,13 @@
 #define DPRINT(args...)
 #endif
 
+#if defined(_SC_ARG_MAX)
+# if defined(ARG_MAX)
+# undef ARG_MAX
+# endif
+# define ARG_MAX (sysconf(_SC_ARG_MAX))
+#endif
+
 #define INPUT_DIR_PATH	"/dev/input"
 #define EVENT_NAME	"gpio-keys"
 
@@ -93,7 +100,7 @@ main(int argc, char **argv)
 {
 	struct input_event event;
 	char device[PATH_MAX];
-	char cmd[ARG_MAX], *cmd_ptr;
+	char *cmd, *cmd_ptr;
 	int fd;
 	int sw_index;
 	int ret;
@@ -132,6 +139,12 @@ main(int argc, char **argv)
 		return -1;
 	}
 
+	cmd = malloc(ARG_MAX);
+	if (cmd == NULL) {
+		perror("malloc");
+		return -1;
+	}
+
 	cmd_ptr = cmd;
 	for (i = 3; i < argc; i++)
 		cmd_ptr += sprintf(cmd_ptr, "%s ", argv[i]);
@@ -155,6 +168,7 @@ main(int argc, char **argv)
 		}
 	}
 
+	free(cmd);
 	close(fd);
 
 	return 0;
diff --git a/vendors/AtmarkTechno/Common/tools/lib-inst.sh b/vendors/AtmarkTechno/Common/tools/lib-inst.sh
index 77aa361..e0222f0 100755
--- a/vendors/AtmarkTechno/Common/tools/lib-inst.sh
+++ b/vendors/AtmarkTechno/Common/tools/lib-inst.sh
@@ -19,8 +19,22 @@ for dir in `$CROSS_GCC -print-search-dirs | \
 	    grep -e "libraries: =" | \
 	    sed -e "s/libraries: =//" -e "s/:/ /g"`
 do
+    if [ ! -d $dir ]; then
+        continue
+    fi
     CROSS_LIB_DIR=`(cd $dir 2>/dev/null;pwd) | \
 		   grep -v "$GCC_VERSION" 2>/dev/null`
+    if [ "$CROSS_LIB_DIR" ]; then
+        dir_is_found=n
+        for lib_dir in $CROSS_LIB_DIRS; do
+            if [ "$CROSS_LIB_DIR" = "$lib_dir" ]; then
+                dir_is_found=y
+            fi
+        done
+        if [ "$dir_is_found" = "n" ]; then
+            CROSS_LIB_DIRS="$CROSS_LIB_DIRS $CROSS_LIB_DIR"
+        fi
+    fi
 done
 
 ###############################################################################
@@ -99,10 +113,12 @@ check_library(){
 	sed -e "s/NEEDED//" |
 	while read i 
 	do 
-	    if [ ! -f "$ROMFSDIR"/lib/$i ] ; then
-		if [ ! -L "$ROMFSDIR"/lib/$i ]; then
-		    cp_library "$CROSS_LIB_DIR"/$i
-		fi
+	    if [ ! $(find $ROMFSDIR/lib -name $i 2> /dev/null) ]; then
+		for lib_dir in $CROSS_LIB_DIRS; do
+		    for lib in $(find $lib_dir/ -name $i); do
+			cp_library $lib
+		    done
+		done
 	    fi
 	done
 }
