]> andersk Git - openssh.git/blobdiff - bufaux.c
- (dtucker) [configure.ac misc.c readconf.c servconf.c ssh-keyscan.c]
[openssh.git] / bufaux.c
index a384cc6853cbff008b3e4c3d85ad0ebf2384d707..cd9a35dedc5ebe0a040b070675da6c698447922d 100644 (file)
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bufaux.c,v 1.43 2006/07/22 20:48:22 stevesk Exp $ */
+/* $OpenBSD: bufaux.c,v 1.46 2008/06/10 23:21:34 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
 
 #include "includes.h"
 
+#include <sys/types.h>
+
 #include <openssl/bn.h>
 
 #include <string.h>
+#include <stdarg.h>
 
-#include "bufaux.h"
 #include "xmalloc.h"
+#include "buffer.h"
 #include "log.h"
 #include "misc.h"
 
@@ -177,7 +180,7 @@ buffer_get_string_ret(Buffer *buffer, u_int *length_ptr)
                return (NULL);
        }
        /* Append a null character to make processing easier. */
-       value[len] = 0;
+       value[len] = '\0';
        /* Optionally return the length of the string. */
        if (length_ptr)
                *length_ptr = len;
@@ -194,6 +197,22 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
        return (ret);
 }
 
+void *
+buffer_get_string_ptr(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);
+       ptr = buffer_ptr(buffer);
+       buffer_consume(buffer, len);
+       if (length_ptr)
+               *length_ptr = len;
+       return (ptr);
+}
+
 /*
  * Stores and arbitrary binary string in the buffer.
  */
This page took 0.072046 seconds and 4 git commands to generate.