Skip to content

Commit

Permalink
minor fix and workaround for newline problem
Browse files Browse the repository at this point in the history
  • Loading branch information
younix committed Oct 24, 2016
1 parent d21a82d commit 06e4cf9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fishii.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ send_msg(const char *msg, const char *key)
{
int fd;
char cipher[BUFSIZ] = "+OK ";
char *nl;

if ((nl = strrchr(msg, '\n')) != NULL) /* rm newline */
*nl = '\0';

if (encrypt_string(key, msg, cipher + 4, strlen(msg)) == 0)
errx(EXIT_FAILURE, "encrypt_string");

strlcat(cipher, "\n", sizeof cipher);

if ((fd = open("in", O_WRONLY)) == -1)
err(EXIT_FAILURE, "open");

Expand Down Expand Up @@ -113,7 +118,7 @@ main(int argc, char *argv[])
# define READ_FD 6
# define WRITE_FD 7

while ((ch = getopt(argc, argv, "d:h")) != -1) {
while ((ch = getopt(argc, argv, "d:n:h")) != -1) {
switch (ch) {
case 'd':
if ((dir = strdup(optarg)) == NULL)
Expand Down

0 comments on commit 06e4cf9

Please sign in to comment.