From: Kern Sibbald Date: Mon, 18 Jan 2010 08:26:39 +0000 (+0100) Subject: Keep serial from overruning with bad data X-Git-Tag: Release-5.0.0~71 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=70c156f640d4e615847b3d00f18cd3411fc9b972;p=bacula%2Fbacula Keep serial from overruning with bad data --- diff --git a/bacula/src/lib/serial.c b/bacula/src/lib/serial.c index 6b803f16db..2de4edaf30 100644 --- a/bacula/src/lib/serial.c +++ b/bacula/src/lib/serial.c @@ -2,14 +2,11 @@ Serialisation Support Functions John Walker - - - Version $Id$ */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2010 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -173,12 +170,17 @@ void serial_float64(uint8_t * * const ptr, const float64_t v) *ptr += sizeof(float64_t); } -void serial_string(uint8_t * * const ptr, const char * const str) +void serial_string(uint8_t * * const ptr, const char * const str, int max) { - int len = strlen(str) + 1; - - memcpy(*ptr, str, len); - *ptr += len; + int i; + char *dest = (char *)*ptr; + char *src = (char *)str; + for (i=0; i