projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove a return path from sshcom_write() which was both unreachable
[u/mdw/putty]
/
unix
/
uxstore.c
diff --git
a/unix/uxstore.c
b/unix/uxstore.c
index
8d49e48
..
c5e40d4
100644
(file)
--- a/
unix/uxstore.c
+++ b/
unix/uxstore.c
@@
-299,8
+299,10
@@
void *open_settings_r(const char *sessionname)
char *value = strchr(line, '=');
struct skeyval *kv;
char *value = strchr(line, '=');
struct skeyval *kv;
- if (!value)
+ if (!value) {
+ sfree(line);
continue;
continue;
+ }
*value++ = '\0';
value[strcspn(value, "\r\n")] = '\0'; /* trim trailing NL */
*value++ = '\0';
value[strcspn(value, "\r\n")] = '\0'; /* trim trailing NL */
@@
-357,7
+359,7
@@
int read_setting_i(void *handle, const char *key, int defvalue)
return atoi(val);
}
return atoi(val);
}
-
int read_setting_fontspec(void *handle, const char *name, FontSpec *result
)
+
FontSpec *read_setting_fontspec(void *handle, const char *name
)
{
/*
* In GTK1-only PuTTY, we used to store font names simply as a
{
/*
* In GTK1-only PuTTY, we used to store font names simply as a
@@
-375,40
+377,38
@@
int read_setting_fontspec(void *handle, const char *name, FontSpec *result)
char *tmp;
if ((tmp = read_setting_s(handle, suffname)) != NULL) {
char *tmp;
if ((tmp = read_setting_s(handle, suffname)) != NULL) {
- strncpy(result->name, tmp, sizeof(result->name)-1);
- result->name[sizeof(result->name)-1] = '\0';
+ FontSpec *fs = fontspec_new(tmp);
sfree(suffname);
sfree(tmp);
sfree(suffname);
sfree(tmp);
- return
TRUE;
/* got new-style name */
+ return
fs;
/* got new-style name */
}
sfree(suffname);
/* Fall back to old-style name. */
tmp = read_setting_s(handle, name);
if (tmp && *tmp) {
}
sfree(suffname);
/* Fall back to old-style name. */
tmp = read_setting_s(handle, name);
if (tmp && *tmp) {
-
strcpy(result->name, "server:"
);
-
strncpy(result->name + 7, tmp, sizeof(result->name) - 8
);
-
result->name[sizeof(result->name)-1] = '\0'
;
+
char *tmp2 = dupcat("server:", tmp, NULL
);
+
FontSpec *fs = fontspec_new(tmp2
);
+
sfree(tmp2)
;
sfree(tmp);
sfree(tmp);
- return
TRUE
;
+ return
fs
;
} else {
sfree(tmp);
} else {
sfree(tmp);
- return
FALSE
;
+ return
NULL
;
}
}
}
}
-
int read_setting_filename(void *handle, const char *name, Filename *result
)
+
Filename *read_setting_filename(void *handle, const char *name
)
{
char *tmp = read_setting_s(handle, name);
if (tmp) {
{
char *tmp = read_setting_s(handle, name);
if (tmp) {
- strncpy(result->path, tmp, sizeof(result->path)-1);
- result->path[sizeof(result->path)-1] = '\0';
+ Filename *ret = filename_from_str(tmp);
sfree(tmp);
sfree(tmp);
- return
TRUE
;
+ return
ret
;
} else
} else
- return
FALSE
;
+ return
NULL
;
}
}
-void write_setting_fontspec(void *handle, const char *name, FontSpec
result
)
+void write_setting_fontspec(void *handle, const char *name, FontSpec
*fs
)
{
/*
* read_setting_fontspec had to handle two cases, but when
{
/*
* read_setting_fontspec had to handle two cases, but when
@@
-416,12
+416,12
@@
void write_setting_fontspec(void *handle, const char *name, FontSpec result)
* new-style name.
*/
char *suffname = dupcat(name, "Name", NULL);
* new-style name.
*/
char *suffname = dupcat(name, "Name", NULL);
- write_setting_s(handle, suffname,
result.
name);
+ write_setting_s(handle, suffname,
fs->
name);
sfree(suffname);
}
sfree(suffname);
}
-void write_setting_filename(void *handle, const char *name, Filename result)
+void write_setting_filename(void *handle, const char *name, Filename
*
result)
{
{
- write_setting_s(handle, name, result
.
path);
+ write_setting_s(handle, name, result
->
path);
}
void close_settings_r(void *handle)
}
void close_settings_r(void *handle)
@@
-591,9
+591,6
@@
void store_host_key(const char *hostname, int port,
int headerlen;
char *filename, *tmpfilename;
int headerlen;
char *filename, *tmpfilename;
- newtext = dupprintf("%s@%d:%s %s\n", keytype, port, hostname, key);
- headerlen = 1 + strcspn(newtext, " "); /* count the space too */
-
/*
* Open both the old file and a new file.
*/
/*
* Open both the old file and a new file.
*/
@@
-615,6
+612,9
@@
void store_host_key(const char *hostname, int port,
filename = make_filename(INDEX_HOSTKEYS, NULL);
rfp = fopen(filename, "r");
filename = make_filename(INDEX_HOSTKEYS, NULL);
rfp = fopen(filename, "r");
+ newtext = dupprintf("%s@%d:%s %s\n", keytype, port, hostname, key);
+ headerlen = 1 + strcspn(newtext, " "); /* count the space too */
+
/*
* Copy all lines from the old file to the new one that _don't_
* involve the same host key identifier as the one we're adding.
/*
* Copy all lines from the old file to the new one that _don't_
* involve the same host key identifier as the one we're adding.
@@
-623,6
+623,7
@@
void store_host_key(const char *hostname, int port,
while ( (line = fgetline(rfp)) ) {
if (strncmp(line, newtext, headerlen))
fputs(line, wfp);
while ( (line = fgetline(rfp)) ) {
if (strncmp(line, newtext, headerlen))
fputs(line, wfp);
+ sfree(line);
}
fclose(rfp);
}
}
fclose(rfp);
}