X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=onak.c;h=903c8f0f7c16b56e1168e1e1a1f302be1f24265f;hb=c2524e42992138f66a836d6c7ffe725a307c50d2;hp=870e1bd57d3fc329483b857114d58b3a835a281e;hpb=dd37c5ea8e61e9bec43d01ff1551202bea7402dc;p=onak.git diff --git a/onak.c b/onak.c index 870e1bd..903c8f0 100644 --- a/onak.c +++ b/onak.c @@ -6,6 +6,8 @@ * Jonathan McDowell * * Copyright 2002 Project Purple + * + * $Id: onak.c,v 1.15 2003/09/28 20:33:34 noodles Exp $ */ #include @@ -26,13 +28,15 @@ int stdin_getchar(void *ctx, size_t count, unsigned char *c) { - int ic; + int ic = 0; - do { + while ((count > 0) && (ic != EOF)) { ic = getchar(); *c = ic; c++; - } while ((ic != EOF) && (--count > 0)); + count--; + } + return (ic == EOF); } @@ -191,7 +195,10 @@ int main(int argc, char *argv[]) } else if (!strcmp("delete", argv[optind])) { delete_key(getfullkeyid(keyid), false); } else if (!strcmp("get", argv[optind])) { - if (fetch_key(keyid, &keys, false)) { + if (!ishex) { + puts("Can't get a key on uid text." + " You must supply a keyid."); + } else if (fetch_key(keyid, &keys, false)) { logthing(LOGTHING_INFO, "Got key."); flatten_publickey(keys, &packets,