3
votes

I am working on a simple pop3 client in C and I encountered the following issue: In AUTHORIZATION state, the server will never recognise my password:

Connection successful: +OK GMX POP3 StreamProxy ready

user [email protected]
+OK May I have your password, please?

pass ******
-ERR Username or password incorrect

but the same succession of commands works nicely in telnet

+OK GMX POP3 StreamProxy ready
user [email protected]
+OK May I have your password, please?
pass ******
+OK Mailbox locked and ready

I am sure that the password I send is alright. This is how I send the pass command and receive the answer:

sprintf (command, "pass %s\r\n", pass); //pass is the string containing the password
    printf("%s", command);
    if (write(sock, command, sizeof(command)) == -1)
    {
        fprintf(stderr, "write() error: %d\n", errno);
        return errno;
    }
    if (read(sock, msgbuff, sizeof(msgbuff)) == -1)
    {
        fprintf(stderr, "read() error: %d\n", errno);
        return errno;
    }

Any help would be greatly appreciated.

1

1 Answers

3
votes

Why are you using sizeof(command) and not strlen(command) for the length?