diff options
Diffstat (limited to 'g10/comment.c')
-rw-r--r-- | g10/comment.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/g10/comment.c b/g10/comment.c index fef831cc7..71d524c40 100644 --- a/g10/comment.c +++ b/g10/comment.c @@ -44,9 +44,17 @@ write_comment( IOBUF out, const char *s ) int rc=0; pkt.pkttype = PKT_COMMENT; - pkt.pkt.comment = m_alloc( sizeof *pkt.pkt.comment + n - 1 ); - pkt.pkt.comment->len = n; - strcpy(pkt.pkt.comment->data, s); + if( *s != '#' ) { + pkt.pkt.comment = m_alloc( sizeof *pkt.pkt.comment + n ); + pkt.pkt.comment->len = n+1; + *pkt.pkt.comment->data = '#'; + strcpy(pkt.pkt.comment->data+1, s); + } + else { + pkt.pkt.comment = m_alloc( sizeof *pkt.pkt.comment + n - 1 ); + pkt.pkt.comment->len = n; + strcpy(pkt.pkt.comment->data, s); + } if( (rc = build_packet( out, &pkt )) ) log_error("build_packet(comment) failed: %s\n", g10_errstr(rc) ); free_packet( &pkt ); |