]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2010/01/12 01:36:08
authordtucker <dtucker>
Tue, 12 Jan 2010 08:45:59 +0000 (08:45 +0000)
committerdtucker <dtucker>
Tue, 12 Jan 2010 08:45:59 +0000 (08:45 +0000)
     [buffer.h bufaux.c]
     add a buffer_get_string_ptr_ret() that does the same as
     buffer_get_string_ptr() but does not fatal() on error; ok dtucker@

ChangeLog
bufaux.c
buffer.h

index ddfa8af4438b0c0dcdc372c3a700ac02d0c870f1..6992a01b864408a0b77582e09ba1c36f4b3903c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [session.c]
      Do not allow logins if /etc/nologin exists but is not readable by the user
      logging in.  Noted by Jan.Pechanec at Sun, ok djm@ deraadt@
+   - djm@cvs.openbsd.org 2010/01/12 01:36:08
+     [buffer.h bufaux.c]
+     add a buffer_get_string_ptr_ret() that does the same as
+     buffer_get_string_ptr() but does not fatal() on error; ok dtucker@
 
 20100110
  - (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c]
index cd9a35dedc5ebe0a040b070675da6c698447922d..e17f001e1c86a11a1d21b50483b16b074d0170a1 100644 (file)
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bufaux.c,v 1.46 2008/06/10 23:21:34 dtucker Exp $ */
+/* $OpenBSD: bufaux.c,v 1.47 2010/01/12 01:36:08 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -198,14 +198,17 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
 }
 
 void *
-buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
+buffer_get_string_ptr_ret(Buffer *buffer, u_int *length_ptr)
 {
        void *ptr;
        u_int len;
 
-       len = buffer_get_int(buffer);
-       if (len > 256 * 1024)
-               fatal("buffer_get_string_ptr: bad string length %u", len);
+       if (buffer_get_int_ret(&len, buffer) != 0)
+               return NULL;
+       if (len > 256 * 1024) {
+               error("buffer_get_string_ptr: bad string length %u", len);
+               return NULL;
+       }
        ptr = buffer_ptr(buffer);
        buffer_consume(buffer, len);
        if (length_ptr)
@@ -213,6 +216,16 @@ buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
        return (ptr);
 }
 
+void *
+buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
+{
+       void *ret;
+
+       if ((ret = buffer_get_string_ptr_ret(buffer, length_ptr)) == NULL)
+               fatal("buffer_get_string_ptr: buffer error");
+       return (ret);
+}
+
 /*
  * Stores and arbitrary binary string in the buffer.
  */
index d0f354ee7bf7e685a51f6edf44b60aef603e5837..ecad28973f837755e8af8c2932e89e6672e573f6 100644 (file)
--- a/buffer.h
+++ b/buffer.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.h,v 1.17 2008/05/08 06:59:01 markus Exp $ */
+/* $OpenBSD: buffer.h,v 1.18 2010/01/12 01:36:08 djm Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -81,6 +81,7 @@ int   buffer_get_short_ret(u_short *, Buffer *);
 int    buffer_get_int_ret(u_int *, Buffer *);
 int    buffer_get_int64_ret(u_int64_t *, Buffer *);
 void   *buffer_get_string_ret(Buffer *, u_int *);
+void   *buffer_get_string_ptr_ret(Buffer *, u_int *);
 int    buffer_get_char_ret(char *, Buffer *);
 
 #endif                         /* BUFFER_H */
This page took 0.04509 seconds and 5 git commands to generate.