* @param len Length of buffer
* @param conn Network connection
*/
-static void flush_buffer(char *buf, size_t *len, struct Connection *conn)
+static int flush_buffer(char *buf, size_t *len, struct Connection *conn)
{
buf[*len] = '\0';
- mutt_socket_write_n(conn, buf, *len);
+ int rc = mutt_socket_write_n(conn, buf, *len);
*len = 0;
+ return rc;
}
/**
SKIPWS(pc);
pc = imap_next_word(pc);
mutt_error("%s", pc);
- mutt_file_fclose(&fp);
goto fail;
}
if (len > sizeof(buf) - 3)
{
sent += len;
- flush_buffer(buf, &len, adata->conn);
+ if (flush_buffer(buf, &len, adata->conn) < 0)
+ goto fail;
mutt_progress_update(&progress, sent, -1);
}
}
if (len)
- flush_buffer(buf, &len, adata->conn);
+ if (flush_buffer(buf, &len, adata->conn) < 0)
+ goto fail;
- mutt_socket_send(adata->conn, "\r\n");
+ if (mutt_socket_send(adata->conn, "\r\n") < 0)
+ goto fail;
mutt_file_fclose(&fp);
do
rc = imap_cmd_step(adata);
while (rc == IMAP_CMD_CONTINUE);
- if (!imap_code(adata->buf))
+ if (rc != IMAP_CMD_OK)
{
mutt_debug(LL_DEBUG1, "#2 command failed: %s\n", adata->buf);
char *pc = adata->buf + SEQ_LEN;
return 0;
fail:
+ mutt_file_fclose(&fp);
return -1;
}