-/* $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"
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;
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.
*/