comparison dbutil.c @ 995:6fb4c010c448

Default client key path ~/.ssh/id_dropbear
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jan 2015 00:05:26 +0800
parents db9fa5971d24
children 257f7d5fca97
comparison
equal deleted inserted replaced
994:5c5ade336926 995:6fb4c010c448
934 *val = l; 934 *val = l;
935 return DROPBEAR_SUCCESS; 935 return DROPBEAR_SUCCESS;
936 } 936 }
937 } 937 }
938 938
939 /* Returns malloced path. Only expands ~ in first character */
940 char * expand_tilde(const char *inpath) {
941 struct passwd *pw = NULL;
942 if (inpath[0] == '~') {
943 pw = getpwuid(getuid());
944 if (pw && pw->pw_dir) {
945 int len = strlen(inpath) + strlen(pw->pw_dir) + 1;
946 char *buf = m_malloc(len);
947 snprintf(buf, len, "%s/%s", pw->pw_dir, &inpath[1]);
948 return buf;
949 }
950 }
951
952 /* Fallback */
953 return m_strdup(inpath);
954 }
955
939 int constant_time_memcmp(const void* a, const void *b, size_t n) 956 int constant_time_memcmp(const void* a, const void *b, size_t n)
940 { 957 {
941 const char *xa = a, *xb = b; 958 const char *xa = a, *xb = b;
942 uint8_t c = 0; 959 uint8_t c = 0;
943 size_t i; 960 size_t i;