[OTR-dev] anything else for the libotr 2.0.0 API?
Ian Goldberg
ian at cypherpunks.ca
Fri Jan 28 15:33:26 EST 2005
On Fri, Jan 28, 2005 at 11:36:58AM -0800, Adam Fritzler wrote:
>
> In the ALWAYS case, what happens if there's more than one attempt to
> send a message before negotiation completes? It looks like it's
> silently lost, which there should at least be a warning about.
That seems reasonable. How about this:
--- message.c 28 Jan 2005 19:12:41 -0000 1.9
+++ message.c 28 Jan 2005 20:35:29 -0000
@@ -115,7 +115,45 @@
if (policy == OTRL_POLICY_ALWAYS && context->state != CONN_CONNECTED) {
/* We're trying to send an unencrypted message with policy
* ALWAYS. Don't do that, but try to start up OTR instead. */
- gcry_free(context->lastmessage);
+ if (context->lastmessage) {
+ gcry_free(context->lastmessage);
+ if (ops->notify) {
+ const char *format = "You attempted to send another "
+ "unencrypted message to %s";
+ char *primary = malloc(strlen(format) + strlen(recipient) - 1);
+ if (primary) {
+ sprintf(primary, format, recipient);
+ ops->notify(opdata, OTRL_NOTIFY_ERROR, accountname,
+ protocol, recipient, "OTR Policy Violation",
+ primary,
+ "Unencrypted messages to this recipient are not "
+ "allowed. Attempting to start a private "
+ "conversation.\n\nYour message will be "
+ "retransmitted when the private conversation "
+ "starts, but the previously saved message has "
+ "been discarded.");
+ free(primary);
+ }
+ }
+ } else {
+ if (ops->notify) {
+ const char *format = "You attempted to send an "
+ "unencrypted message to %s";
+ char *primary = malloc(strlen(format) + strlen(recipient) - 1);
+ if (primary) {
+ sprintf(primary, format, recipient);
+ ops->notify(opdata, OTRL_NOTIFY_WARNING, accountname,
+ protocol, recipient, "OTR Policy Violation",
+ primary,
+ "Unencrypted messages to this recipient are not "
+ "allowed. Attempting to start a private "
+ "conversation.\n\nYour message will be "
+ "retransmitted when the private conversation "
+ "starts.");
+ free(primary);
+ }
+ }
+ }
context->lastmessage = gcry_malloc_secure(strlen(message) + 1);
if (context->lastmessage) {
strcpy(context->lastmessage, message);
More information about the OTR-dev
mailing list