Browse Subversion Repository
Diff of /trunk/ttssh2/ttxssh/buffer.c
Parent Directory
| Revision Log
| Patch
134 |
return (msg->buf); |
return (msg->buf); |
135 |
} |
} |
136 |
|
|
137 |
|
char *buffer_tail_ptr(buffer_t *msg) |
138 |
|
{ |
139 |
|
return (char *)(msg->buf + msg->offset); |
140 |
|
} |
141 |
|
|
142 |
|
int buffer_overflow_verify(buffer_t *msg, int len) |
143 |
|
{ |
144 |
|
if (msg->offset + len > msg->maxlen) { |
145 |
|
return -1; // error |
146 |
|
} |
147 |
|
return 0; // no problem |
148 |
|
} |
149 |
|
|
150 |
|
// for SSH1 |
151 |
|
void buffer_put_bignum(buffer_t *buffer, BIGNUM *value) |
152 |
|
{ |
153 |
|
unsigned int bits, bin_size; |
154 |
|
unsigned char *buf; |
155 |
|
int oi; |
156 |
|
char msg[2]; |
157 |
|
|
158 |
|
bits = BN_num_bits(value); |
159 |
|
bin_size = (bits + 7) / 8; |
160 |
|
buf = malloc(bin_size); |
161 |
|
if (buf == NULL) { |
162 |
|
*buf = 0; |
163 |
|
goto error; |
164 |
|
} |
165 |
|
|
166 |
|
buf[0] = '\0'; |
167 |
|
/* Get the value of in binary */ |
168 |
|
oi = BN_bn2bin(value, buf); |
169 |
|
if (oi != bin_size) { |
170 |
|
goto error; |
171 |
|
} |
172 |
|
|
173 |
|
/* Store the number of bits in the buffer in two bytes, msb first. */ |
174 |
|
set_ushort16_MSBfirst(msg, bits); |
175 |
|
buffer_append(buffer, msg, 2); |
176 |
|
|
177 |
|
/* Store the binary data. */ |
178 |
|
buffer_append(buffer, (char *)buf, oi); |
179 |
|
|
180 |
|
error: |
181 |
|
free(buf); |
182 |
|
} |
183 |
|
|
184 |
|
// for SSH2 |
185 |
void buffer_put_bignum2(buffer_t *msg, BIGNUM *value) |
void buffer_put_bignum2(buffer_t *msg, BIGNUM *value) |
186 |
{ |
{ |
187 |
unsigned int bytes; |
unsigned int bytes; |
237 |
|
|
238 |
/* |
/* |
239 |
* $Log: not supported by cvs2svn $ |
* $Log: not supported by cvs2svn $ |
240 |
|
* Revision 1.2 2004/12/19 15:37:37 yutakakn |
241 |
|
* CVS LogIDの追加 |
242 |
|
* |
243 |
*/ |
*/ |
|
Legend:
Removed from v.2761 |
|
changed lines |
|
Added in v.2816 |
|
|
| |