diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-03-11 16:38:24 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-03-11 16:38:24 +0000 |
commit | db69d37d8d8fdc323e28c68824f4f10156727557 (patch) | |
tree | 34a952267e3d422dd870f9f7d2ec86a17a771157 /usr.sbin/bgpd | |
parent | 0f8af14b0d6a6105dc7242f9c0f9e38028ae3d14 (diff) |
Ensure that aspath_snprint() returns a zero terminated string also if the
aspath is "". Found, OK and tsc tsc tsc henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde_attr.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index 3b8e6f609f4..fd3279aee64 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.18 2004/03/05 22:21:32 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.19 2004/03/11 16:38:23 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -797,7 +797,7 @@ aspath_snprint(char *buf, size_t size, void *data, u_int16_t len) #define UPDATE() \ do { \ if (r == -1) \ - return (1); \ + return (-1); \ total_size += r; \ if ((unsigned int)r < size) { \ size -= r; \ @@ -842,6 +842,10 @@ aspath_snprint(char *buf, size_t size, void *data, u_int16_t len) UPDATE(); } } + /* ensure that we have a valid C-string */ + if (size > 0) + *buf = '\0'; + return total_size; #undef UPDATE } |