From: ben Date: Thu, 12 Dec 2002 23:55:51 +0000 (+0000) Subject: When loading a string setting, expect in the same form we would have X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/086efcde067f75f97768e54c251befc9e4ad10ce When loading a string setting, expect in the same form we would have saved (raw text rather than Pascal string). git-svn-id: svn://svn.tartarus.org/sgt/putty@2314 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/mac/macstore.c b/mac/macstore.c index fa6493a0..1c317ebc 100644 --- a/mac/macstore.c +++ b/mac/macstore.c @@ -1,4 +1,4 @@ -/* $Id: macstore.c,v 1.1 2002/11/19 02:13:46 ben Exp $ */ +/* $Id: macstore.c,v 1.2 2002/12/12 23:55:51 ben Exp $ */ /* * macstore.c: Macintosh-specific impementation of the interface @@ -222,6 +222,7 @@ char *read_setting_s(void *handle, char *key, char *buffer, int buflen) { int fd; Handle h; OSErr error; + size_t len; if (handle == NULL) goto out; fd = *(int *)handle; @@ -230,8 +231,11 @@ char *read_setting_s(void *handle, char *key, char *buffer, int buflen) { h = get1namedresource(FOUR_CHAR_CODE('TEXT'), key); if (h == NULL) goto out; - if (GetHandleSize(h) > buflen) goto out; - p2cstrcpy(buffer, (StringPtr)*h); + len = GetHandleSize(h); + if (len + 1 > buflen) goto out; + memcpy(buffer, *h, len); + buffer[len] = '\0'; + ReleaseResource(h); if (ResError() != noErr) goto out; return buffer;