svnno****@sourc*****
svnno****@sourc*****
2014年 3月 11日 (火) 21:46:29 JST
Revision: 5526 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5526 Author: yutakapon Date: 2014-03-11 21:46:29 +0900 (Tue, 11 Mar 2014) Log Message: ----------- buffer_append_space() で誤って offset を進めていた問題を修正した。 buffer_consume_end() を新規追加した。 Modified Paths: -------------- branches/ssh_ed25519/ttssh2/ttxssh/buffer.c branches/ssh_ed25519/ttssh2/ttxssh/buffer.h -------------- next part -------------- Modified: branches/ssh_ed25519/ttssh2/ttxssh/buffer.c =================================================================== --- branches/ssh_ed25519/ttssh2/ttxssh/buffer.c 2014-03-11 12:45:34 UTC (rev 5525) +++ branches/ssh_ed25519/ttssh2/ttxssh/buffer.c 2014-03-11 12:46:29 UTC (rev 5526) @@ -59,7 +59,6 @@ } // \x83o\x83b\x83t\x83@\x82̗̈\xE6\x8Ag\x92\xA3\x82\xF0\x8Ds\x82\xA4\x81B -// \x83o\x83b\x83t\x83@\x82̃I\x83t\x83Z\x83b\x83g\x82͊g\x92\xA3\x95\xAA\x82\xBE\x82\xAF\x8C\xE3\x82\xEB\x82ɂ\xB8\x82\xEA\x82\xE9\x81B // return: \x8Ag\x92\xA3\x91O\x82̃o\x83b\x83t\x83@\x83|\x83C\x83\x93\x83^\x81[ void *buffer_append_space(buffer_t * buf, int size) { @@ -84,8 +83,8 @@ } p = buf->buf + buf->offset; - buf->offset += size; - buf->len = buf->offset; + //buf->offset += size; + buf->len = buf->offset + size; return (p); @@ -510,6 +509,20 @@ } } +// \x83o\x83b\x83t\x83@\x82̖\x96\x94\xF6\x82\xF0\x8Fk\x91ނ\xB7\x82\xE9\x81B +void buffer_consume_end(buffer_t *buf, int shift_byte) +{ + int n; + + n = buf->offset - shift_byte; + if (n >= 0) { + buf->offset -= shift_byte; + } else { + // TODO: fatal error + } +} + + // \x83p\x83P\x83b\x83g\x82̈\xB3\x8Fk int buffer_compress(z_stream *zstream, char *payload, int len, buffer_t *compbuf) { Modified: branches/ssh_ed25519/ttssh2/ttxssh/buffer.h =================================================================== --- branches/ssh_ed25519/ttssh2/ttxssh/buffer.h 2014-03-11 12:45:34 UTC (rev 5525) +++ branches/ssh_ed25519/ttssh2/ttxssh/buffer.h 2014-03-11 12:46:29 UTC (rev 5526) @@ -36,6 +36,7 @@ char *buffer_tail_ptr(buffer_t *msg); int buffer_overflow_verify(buffer_t *msg, int len); void buffer_consume(buffer_t *buf, int shift_byte); +void buffer_consume_end(buffer_t *buf, int shift_byte); int buffer_compress(z_stream *zstream, char *payload, int len, buffer_t *compbuf); int buffer_decompress(z_stream *zstream, char *payload, int len, buffer_t *compbuf); int buffer_get_ret(buffer_t *msg, void *buf, int len);