add control character sanitization
This commit is contained in:
parent
16f8d35c13
commit
9ad62f990e
1 changed files with 16 additions and 6 deletions
20
kissy.c
20
kissy.c
|
|
@ -25,6 +25,7 @@
|
|||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
// mreowww meow nya :3
|
||||
|
||||
|
|
@ -64,11 +65,20 @@ int main (int argc, char **argv) {
|
|||
char* user = pw2->pw_name;
|
||||
|
||||
// if we have a second argument, set a custom kiss message
|
||||
char* kiss;
|
||||
if (argc >= 3)
|
||||
kiss = argv[2];
|
||||
else
|
||||
kiss = "*mwah*";
|
||||
char kiss[32] = "*mwah*";
|
||||
if (argc >= 3) {
|
||||
int len = strlen(argv[2]);
|
||||
int written_chars = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (written_chars >= 31) {
|
||||
kiss[31] = '\0';
|
||||
break;
|
||||
};
|
||||
if (iscntrl(argv[2][i])) continue;
|
||||
kiss[i] = argv[2][i];
|
||||
written_chars++;
|
||||
}
|
||||
}
|
||||
|
||||
bool kissed = false;
|
||||
// iterate over all files in directory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue