Skip to content

Commit

Permalink
flush buffer if more than 32 char
Browse files Browse the repository at this point in the history
  • Loading branch information
kewlfft committed Jan 24, 2021
1 parent fa01941 commit 0078939
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dse.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,21 @@ int crypt(char *keyfile, int encrypt, char *src, char *dst)
return status;
}


/*=====================================================================*/


int passgets(char *s, int n)
{
int c;
char *t;

t = s;
while(--n >= 0)
{
c = getchar();
if(c < 32 || c > 126) break;
if(c == '\n') break;
*s++ = c;
}
*s = 0;
if(n<0) while (getchar() != '\n') { }; // n char or more, flush the rest of the buffer containing the linefeed
return s != t;
}

Expand All @@ -216,7 +214,7 @@ int password(char *pass)
return 1;
}
}
printf("\nError\n");
printf("Error\n");
return 0;
}

Expand Down

0 comments on commit 0078939

Please sign in to comment.