Unverified Commit 615edc1f authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

sasl_getmesssage: make sure we have a long enough string to pass

For pop3/imap/smtp, added test 891 to somewhat verify the pop3
case.

For this, I enhanced the pingpong test server to be able to send back
responses with LF-only instead of always using CRLF.

Closes #2150
parent 44014094
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -344,15 +344,16 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
 */
static void imap_get_message(char *buffer, char **outptr)
{
  size_t len = 0;
  size_t len = strlen(buffer);
  char *message = NULL;

  if(len > 2) {
    /* Find the start of the message */
    for(message = buffer + 2; *message == ' ' || *message == '\t'; message++)
      ;

    /* Find the end of the message */
  for(len = strlen(message); len--;)
    for(len -= 2; len--;)
      if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
         message[len] != '\t')
        break;
@@ -361,6 +362,10 @@ static void imap_get_message(char *buffer, char **outptr)
    if(++len) {
      message[len] = '\0';
    }
  }
  else
    /* junk input => zero length output */
    message = &buffer[len];

  *outptr = message;
}
+17 −12
Original line number Diff line number Diff line
@@ -243,15 +243,16 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
 */
static void pop3_get_message(char *buffer, char **outptr)
{
  size_t len = 0;
  size_t len = strlen(buffer);
  char *message = NULL;

  if(len > 2) {
    /* Find the start of the message */
    for(message = buffer + 2; *message == ' ' || *message == '\t'; message++)
      ;

    /* Find the end of the message */
  for(len = strlen(message); len--;)
    for(len -= 2; len--;)
      if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
         message[len] != '\t')
        break;
@@ -260,6 +261,10 @@ static void pop3_get_message(char *buffer, char **outptr)
    if(++len) {
      message[len] = '\0';
    }
  }
  else
    /* junk input => zero length output */
    message = &buffer[len];

  *outptr = message;
}
+17 −12
Original line number Diff line number Diff line
@@ -232,15 +232,16 @@ static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len,
 */
static void smtp_get_message(char *buffer, char **outptr)
{
  size_t len = 0;
  size_t len = strlen(buffer);
  char *message = NULL;

  if(len > 4) {
    /* Find the start of the message */
    for(message = buffer + 4; *message == ' ' || *message == '\t'; message++)
      ;

    /* Find the end of the message */
  for(len = strlen(message); len--;)
    for(len -= 4; len--;)
      if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
         message[len] != '\t')
        break;
@@ -249,6 +250,10 @@ static void smtp_get_message(char *buffer, char **outptr)
    if(++len) {
      message[len] = '\0';
    }
  }
  else
    /* junk input => zero length output */
    message = &buffer[len];

  *outptr = message;
}
+2 −0
Original line number Diff line number Diff line
@@ -124,6 +124,8 @@ REPLY [command] [return value] [response string]
   evaluated as a perl string, so it can contain embedded \r\n, for example.
   There's a special [command] named "welcome" (without quotes) which is the
   string sent immediately on connect as a welcome.
REPLYLF (like above but sends the response terminated with LF-only and not
   CRLF)
COUNT [command] [num]
 - Do the REPLY change for [command] only [num] times and then go back to the
   built-in approach
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ test850 test851 test852 test853 test854 test855 test856 test857 test858 \
test859 test860 test861 test862 test863 test864 test865 test866 test867 \
test868 test869 test870 test871 test872 test873 test874 test875 test876 \
test877 test878 test879 test880 test881 test882 test883 test884 test885 \
test886 test887 test888 test889 test890 \
test886 test887 test888 test889 test890 test891 \
\
test900 test901 test902 test903 test904 test905 test906 test907 test908 \
test909 test910 test911 test912 test913 test914 test915 test916 test917 \
Loading