version 1.71, 2017/05/31 09:15:42 |
version 1.72, 2018/06/06 18:29:18 |
|
|
const char *host, const char *ip, u_int options) |
const char *host, const char *ip, u_int options) |
{ |
{ |
FILE *f; |
FILE *f; |
char line[8192], oline[8192], ktype[128]; |
char *line = NULL, ktype[128]; |
u_long linenum = 0; |
u_long linenum = 0; |
char *cp, *cp2; |
char *cp, *cp2; |
u_int kbits; |
u_int kbits; |
int hashed; |
int hashed; |
int s, r = 0; |
int s, r = 0; |
struct hostkey_foreach_line lineinfo; |
struct hostkey_foreach_line lineinfo; |
size_t l; |
size_t linesize = 0, l; |
|
|
memset(&lineinfo, 0, sizeof(lineinfo)); |
memset(&lineinfo, 0, sizeof(lineinfo)); |
if (host == NULL && (options & HKF_WANT_MATCH) != 0) |
if (host == NULL && (options & HKF_WANT_MATCH) != 0) |
|
|
return SSH_ERR_SYSTEM_ERROR; |
return SSH_ERR_SYSTEM_ERROR; |
|
|
debug3("%s: reading file \"%s\"", __func__, path); |
debug3("%s: reading file \"%s\"", __func__, path); |
while (read_keyfile_line(f, path, line, sizeof(line), &linenum) == 0) { |
while (getline(&line, &linesize, f) != -1) { |
|
linenum++; |
line[strcspn(line, "\n")] = '\0'; |
line[strcspn(line, "\n")] = '\0'; |
strlcpy(oline, line, sizeof(oline)); |
|
|
|
sshkey_free(lineinfo.key); |
sshkey_free(lineinfo.key); |
memset(&lineinfo, 0, sizeof(lineinfo)); |
memset(&lineinfo, 0, sizeof(lineinfo)); |
lineinfo.path = path; |
lineinfo.path = path; |
lineinfo.linenum = linenum; |
lineinfo.linenum = linenum; |
lineinfo.line = oline; |
free(lineinfo.line); |
|
lineinfo.line = xstrdup(line); |
lineinfo.marker = MRK_NONE; |
lineinfo.marker = MRK_NONE; |
lineinfo.status = HKF_STATUS_OK; |
lineinfo.status = HKF_STATUS_OK; |
lineinfo.keytype = KEY_UNSPEC; |
lineinfo.keytype = KEY_UNSPEC; |
|
|
break; |
break; |
} |
} |
sshkey_free(lineinfo.key); |
sshkey_free(lineinfo.key); |
|
free(lineinfo.line); |
|
free(line); |
fclose(f); |
fclose(f); |
return r; |
return r; |
} |
} |