Revision a5aa842a
b/libcacard/vcard_emul_nss.c | ||
---|---|---|
1110 | 1110 |
{ |
1111 | 1111 |
int reader_count = 0; |
1112 | 1112 |
VCardEmulOptions *opts; |
1113 |
char type_str[100]; |
|
1114 |
int type_len; |
|
1115 | 1113 |
|
1116 | 1114 |
/* Allow the future use of allocating the options structure on the fly */ |
1117 | 1115 |
memcpy(&options, &default_options, sizeof(options)); |
... | ... | |
1126 | 1124 |
* cert_2,cert_3...) */ |
1127 | 1125 |
if (strncmp(args, "soft=", 5) == 0) { |
1128 | 1126 |
const char *name; |
1127 |
size_t name_length; |
|
1129 | 1128 |
const char *vname; |
1129 |
size_t vname_length; |
|
1130 | 1130 |
const char *type_params; |
1131 |
size_t type_params_length; |
|
1132 |
char type_str[100]; |
|
1131 | 1133 |
VCardEmulType type; |
1132 |
int name_length, vname_length, type_params_length, count, i;
|
|
1134 |
int count, i; |
|
1133 | 1135 |
VirtualReaderOptions *vreaderOpt = NULL; |
1134 | 1136 |
|
1135 | 1137 |
args = strip(args + 5); |
1136 | 1138 |
if (*args != '(') { |
1137 | 1139 |
continue; |
1138 | 1140 |
} |
1141 |
args = strip(args+1); |
|
1142 |
|
|
1139 | 1143 |
name = args; |
1140 |
args = strpbrk(args + 1, ",)");
|
|
1144 |
args = strpbrk(args, ",)"); |
|
1141 | 1145 |
if (*args == 0) { |
1142 | 1146 |
break; |
1143 | 1147 |
} |
... | ... | |
1145 | 1149 |
args++; |
1146 | 1150 |
continue; |
1147 | 1151 |
} |
1152 |
name_length = args - name; |
|
1148 | 1153 |
args = strip(args+1); |
1149 |
name_length = args - name - 2; |
|
1154 |
|
|
1150 | 1155 |
vname = args; |
1151 |
args = strpbrk(args + 1, ",)");
|
|
1156 |
args = strpbrk(args, ",)"); |
|
1152 | 1157 |
if (*args == 0) { |
1153 | 1158 |
break; |
1154 | 1159 |
} |
... | ... | |
1156 | 1161 |
args++; |
1157 | 1162 |
continue; |
1158 | 1163 |
} |
1159 |
vname_length = args - name - 2;
|
|
1164 |
vname_length = args - vname;
|
|
1160 | 1165 |
args = strip(args+1); |
1161 |
type_len = strpbrk(args, ",)") - args; |
|
1162 |
assert(sizeof(type_str) > type_len); |
|
1163 |
strncpy(type_str, args, type_len); |
|
1164 |
type_str[type_len] = 0; |
|
1165 |
type = vcard_emul_type_from_string(type_str); |
|
1166 |
|
|
1167 |
type_params = args; |
|
1166 | 1168 |
args = strpbrk(args, ",)"); |
1167 | 1169 |
if (*args == 0) { |
1168 | 1170 |
break; |
... | ... | |
1171 | 1173 |
args++; |
1172 | 1174 |
continue; |
1173 | 1175 |
} |
1176 |
type_params_length = args - type_params; |
|
1174 | 1177 |
args = strip(args+1); |
1178 |
|
|
1179 |
type_params_length = MIN(type_params_length, sizeof(type_str)-1); |
|
1180 |
strncpy(type_str, type_params, type_params_length); |
|
1181 |
type_str[type_params_length] = 0; |
|
1182 |
type = vcard_emul_type_from_string(type_str); |
|
1183 |
|
|
1175 | 1184 |
type_params = args; |
1176 |
args = strpbrk(args + 1, ",)");
|
|
1185 |
args = strpbrk(args, ",)"); |
|
1177 | 1186 |
if (*args == 0) { |
1178 | 1187 |
break; |
1179 | 1188 |
} |
... | ... | |
1181 | 1190 |
args++; |
1182 | 1191 |
continue; |
1183 | 1192 |
} |
1184 |
type_params_length = args - name;
|
|
1193 |
type_params_length = args - type_params;
|
|
1185 | 1194 |
args = strip(args+1); |
1195 |
|
|
1186 | 1196 |
if (*args == 0) { |
1187 | 1197 |
break; |
1188 | 1198 |
} |
... | ... | |
1202 | 1212 |
vreaderOpt->card_type = type; |
1203 | 1213 |
vreaderOpt->type_params = |
1204 | 1214 |
copy_string(type_params, type_params_length); |
1205 |
count = count_tokens(args, ',', ')'); |
|
1215 |
count = count_tokens(args, ',', ')') + 1;
|
|
1206 | 1216 |
vreaderOpt->cert_count = count; |
1207 | 1217 |
vreaderOpt->cert_name = (char **)qemu_malloc(count*sizeof(char *)); |
1208 | 1218 |
for (i = 0; i < count; i++) { |
1209 |
const char *cert = args + 1;
|
|
1210 |
args = strpbrk(args + 1, ",)");
|
|
1219 |
const char *cert = args; |
|
1220 |
args = strpbrk(args, ",)"); |
|
1211 | 1221 |
vreaderOpt->cert_name[i] = copy_string(cert, args - cert); |
1222 |
args = strip(args+1); |
|
1212 | 1223 |
} |
1213 | 1224 |
if (*args == ')') { |
1214 | 1225 |
args++; |
Also available in: Unified diff