]> git.armaanb.net Git - sic.git/blobdiff - util.c
fix an out-of-bounds read if the input is ""
[sic.git] / util.c
diff --git a/util.c b/util.c
index 8afa58f40544cfd0cf86be6ebb01c3aca4c2f3a2..25678120422eea5ec0782e9040fdd5ad24b9ff45 100644 (file)
--- a/util.c
+++ b/util.c
@@ -40,13 +40,6 @@ dial(char *host, char *port) {
        return srv;
 }
 
-#define strlcpy _strlcpy
-static void
-strlcpy(char *to, const char *from, int l) {
-       memccpy(to, from, '\0', l);
-       to[l-1] = '\0';
-}
-
 static char *
 eat(char *s, int (*p)(int), int r) {
        while(*s != '\0' && p(*s) == r)
@@ -68,7 +61,7 @@ trim(char *s) {
        char *e;
 
        e = s + strlen(s) - 1;
-       while(isspace(*e) && e > s)
+       while(e > s && isspace(*e))
                e--;
        *(e + 1) = '\0';
 }