From 80bd1e8cf0b426dabf92f7cd8192c8c960e2f160 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 5 Aug 2014 18:56:39 -0700 Subject: [PATCH] ignore newlines. --- slock.c | 14 +++++++++++--- slocked | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/slock.c b/slock.c index c43bb00..df4669a 100644 --- a/slock.c +++ b/slock.c @@ -318,9 +318,17 @@ main(int argc, char **argv) { Display *dpy; int screen; - if((argc >= 2) && !strcmp("-p", argv[1])) - g_pw = argv[2]; - else if((argc >= 2) && !strcmp("-v", argv[1])) + if((argc >= 2) && !strcmp("-p", argv[1])) { + g_pw = strdup(argv[2]); + int i = 0; + while (g_pw[i]) { + if (g_pw[i] == '\r' || g_pw[i] == '\n') { + g_pw[i] = '\0'; + break; + } + i++; + } + } else if((argc >= 2) && !strcmp("-v", argv[1])) die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION); else if(argc != 1) usage(); diff --git a/slocked b/slocked index 16be08d..26f1049 100755 --- a/slocked +++ b/slocked @@ -16,6 +16,6 @@ fi exec 2> /dev/null pw=$1 if test -z "$pw"; then - pw=$(cat ~/.slock_passwd | xargs printf '%s') + pw=$(cat ~/.slock_passwd) fi exec slock -p "$pw"