From: David Levine Date: Mon, 25 Apr 2016 02:09:39 +0000 (-0400) Subject: Check for empty code. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/e120bb936ef014673007ae4ff7f5780aff9d160b?ds=inline;hp=-c Check for empty code. --- e120bb936ef014673007ae4ff7f5780aff9d160b diff --git a/uip/mhlogin.c b/uip/mhlogin.c index 88912b5c..6ce414f2 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -101,9 +101,10 @@ do_login(const char *svc, const char *user, const char *browser, int snoop) fflush(stdout); code = geta(); - while ((cred = mh_oauth_authorize(code, ctx)) == NULL - && mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) { - printf("Code rejected; try again? "); + while (strlen(code) == 0 || + ((cred = mh_oauth_authorize(code, ctx)) == NULL + && mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT)) { + printf(strlen(code) == 0 ? "Empty code; try again? " : "Code rejected; try again? "); fflush(stdout); code = geta(); }