summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-08-31 22:36:39 +1000
committerDamien Miller <djm@mindrot.org>2010-08-31 22:36:39 +1000
commitda108ece6843f1268aa36d7c8ed0030dc53acd15 (patch)
tree66638a1716374a8d1ac8ece95dceea56ce231a5c /packet.c
parentd96546f5b0f7c57395a338dbb9ac3ac5a48b77fa (diff)
- djm@cvs.openbsd.org 2010/08/31 09:58:37
[auth-options.c auth1.c auth2.c bufaux.c buffer.h kex.c key.c packet.c] [packet.h ssh-dss.c ssh-rsa.c] Add buffer_get_cstring() and related functions that verify that the string extracted from the buffer contains no embedded \0 characters* This prevents random (possibly malicious) crap from being appended to strings where it would not be noticed if the string is used with a string(3) function. Use the new API in a few sensitive places. * actually, we allow a single one at the end of the string for now because we don't know how many deployed implementations get this wrong, but don't count on this to remain indefinitely.
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/packet.c b/packet.c
index 48f7fe613..49aa97335 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.168 2010/07/13 23:13:16 djm Exp $ */ 1/* $OpenBSD: packet.c,v 1.169 2010/08/31 09:58:37 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
@@ -1546,6 +1546,13 @@ packet_get_string_ptr(u_int *length_ptr)
1546 return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr); 1546 return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr);
1547} 1547}
1548 1548
1549/* Ensures the returned string has no embedded \0 characters in it. */
1550char *
1551packet_get_cstring(u_int *length_ptr)
1552{
1553 return buffer_get_cstring(&active_state->incoming_packet, length_ptr);
1554}
1555
1549/* 1556/*
1550 * Sends a diagnostic message from the server to the client. This message 1557 * Sends a diagnostic message from the server to the client. This message
1551 * can be sent at any time (but not while constructing another message). The 1558 * can be sent at any time (but not while constructing another message). The