summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bufaux.c23
-rw-r--r--buffer.h3
3 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index ddfa8af44..6992a01b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,10 @@
31 [session.c] 31 [session.c]
32 Do not allow logins if /etc/nologin exists but is not readable by the user 32 Do not allow logins if /etc/nologin exists but is not readable by the user
33 logging in. Noted by Jan.Pechanec at Sun, ok djm@ deraadt@ 33 logging in. Noted by Jan.Pechanec at Sun, ok djm@ deraadt@
34 - djm@cvs.openbsd.org 2010/01/12 01:36:08
35 [buffer.h bufaux.c]
36 add a buffer_get_string_ptr_ret() that does the same as
37 buffer_get_string_ptr() but does not fatal() on error; ok dtucker@
34 38
3520100110 3920100110
36 - (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c] 40 - (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c]
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 */
diff --git a/buffer.h b/buffer.h
index d0f354ee7..ecad28973 100644
--- a/buffer.h
+++ b/buffer.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: buffer.h,v 1.17 2008/05/08 06:59:01 markus Exp $ */ 1/* $OpenBSD: buffer.h,v 1.18 2010/01/12 01:36:08 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -81,6 +81,7 @@ int buffer_get_short_ret(u_short *, Buffer *);
81int buffer_get_int_ret(u_int *, Buffer *); 81int buffer_get_int_ret(u_int *, Buffer *);
82int buffer_get_int64_ret(u_int64_t *, Buffer *); 82int buffer_get_int64_ret(u_int64_t *, Buffer *);
83void *buffer_get_string_ret(Buffer *, u_int *); 83void *buffer_get_string_ret(Buffer *, u_int *);
84void *buffer_get_string_ptr_ret(Buffer *, u_int *);
84int buffer_get_char_ret(char *, Buffer *); 85int buffer_get_char_ret(char *, Buffer *);
85 86
86#endif /* BUFFER_H */ 87#endif /* BUFFER_H */