diff options
author | Damien Miller <djm@mindrot.org> | 2010-08-31 14:36:39 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2010-08-31 14:36:39 +0200 |
commit | da108ece6843f1268aa36d7c8ed0030dc53acd15 (patch) | |
tree | 66638a1716374a8d1ac8ece95dceea56ce231a5c /packet.c | |
parent | - djm@cvs.openbsd.org 2010/08/16 04:06:06 (diff) | |
download | openssh-da108ece6843f1268aa36d7c8ed0030dc53acd15.tar.xz openssh-da108ece6843f1268aa36d7c8ed0030dc53acd15.zip |
- 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.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.168 2010/07/13 23:13:16 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.169 2010/08/31 09:58:37 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1546,6 +1546,13 @@ packet_get_string_ptr(u_int *length_ptr) return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr); } +/* Ensures the returned string has no embedded \0 characters in it. */ +char * +packet_get_cstring(u_int *length_ptr) +{ + return buffer_get_cstring(&active_state->incoming_packet, length_ptr); +} + /* * Sends a diagnostic message from the server to the client. This message * can be sent at any time (but not while constructing another message). The |