aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2008-11-07 03:46:21 +0000
committerMichael Brown <mcb30@etherboot.org>2008-11-07 03:48:29 +0000
commited196a3ed26cc9aaa034a6451ee1c789c93dfb68 (patch)
tree3d47ccf813855551a2ee7444ba228ce294c76de1 /src
parent29e6f9835ea0277c262b1ab2c4acee1d69cb7099 (diff)
downloadipxe-ed196a3ed26cc9aaa034a6451ee1c789c93dfb68.zip
ipxe-ed196a3ed26cc9aaa034a6451ee1c789c93dfb68.tar.gz
ipxe-ed196a3ed26cc9aaa034a6451ee1c789c93dfb68.tar.bz2
[settings] Ensure fetch_string_setting() returns a NUL-terminated string
This fixes a regression introduced in commit 612f4e7: [settings] Avoid returning uninitialised data on error in fetch_xxx_setting() in which the memset() was moved from fetch_string_setting() to fetch_setting(), in order that it would be useful for non-string setting types. However, this neglects to take into account the fact that fetch_string_setting() shrinks its buffer by one byte (to allow for the NUL) before calling fetch_setting(). Restore the memset() in fetch_string_setting(), so that the terminating NUL is guaranteed to actually be a NUL.
Diffstat (limited to 'src')
-rw-r--r--src/core/settings.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 9ad2ced..2d9c096 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -384,6 +384,7 @@ int fetch_setting_len ( struct settings *settings, struct setting *setting ) {
*/
int fetch_string_setting ( struct settings *settings, struct setting *setting,
char *data, size_t len ) {
+ memset ( data, 0, len );
return fetch_setting ( settings, setting, data,
( ( len > 0 ) ? ( len - 1 ) : 0 ) );
}