summaryrefslogtreecommitdiff
path: root/bufaux.c
diff options
context:
space:
mode:
Diffstat (limited to 'bufaux.c')
-rw-r--r--bufaux.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/bufaux.c b/bufaux.c
index cd9a35ded..e17f001e1 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bufaux.c,v 1.46 2008/06/10 23:21:34 dtucker Exp $ */ 1/* $OpenBSD: bufaux.c,v 1.47 2010/01/12 01:36:08 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -198,14 +198,17 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
198} 198}
199 199
200void * 200void *
201buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr) 201buffer_get_string_ptr_ret(Buffer *buffer, u_int *length_ptr)
202{ 202{
203 void *ptr; 203 void *ptr;
204 u_int len; 204 u_int len;
205 205
206 len = buffer_get_int(buffer); 206 if (buffer_get_int_ret(&len, buffer) != 0)
207 if (len > 256 * 1024) 207 return NULL;
208 fatal("buffer_get_string_ptr: bad string length %u", len); 208 if (len > 256 * 1024) {
209 error("buffer_get_string_ptr: bad string length %u", len);
210 return NULL;
211 }
209 ptr = buffer_ptr(buffer); 212 ptr = buffer_ptr(buffer);
210 buffer_consume(buffer, len); 213 buffer_consume(buffer, len);
211 if (length_ptr) 214 if (length_ptr)
@@ -213,6 +216,16 @@ buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
213 return (ptr); 216 return (ptr);
214} 217}
215 218
219void *
220buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
221{
222 void *ret;
223
224 if ((ret = buffer_get_string_ptr_ret(buffer, length_ptr)) == NULL)
225 fatal("buffer_get_string_ptr: buffer error");
226 return (ret);
227}
228
216/* 229/*
217 * Stores and arbitrary binary string in the buffer. 230 * Stores and arbitrary binary string in the buffer.
218 */ 231 */