int ret = IQN_MISSING, fd = -1;
char ebuf[64];
FILE *fp = NULL;
- char *line = NULL, *newline = NULL, *iqn = NULL, *token = NULL,
- *saveptr = NULL;
+ char *line = NULL, *newline = NULL, *iqn = NULL, *token = NULL;
virCommandPtr cmd = virCommandNewArgList(ISCSIADM,
"--mode", "iface", NULL);
iqn++;
if (STREQ(iqn, initiatoriqn)) {
- token = strtok_r(line, " ", &saveptr);
- *ifacename = strdup(token);
+ token = strchr(line, ' ');
+ if (!token) {
+ ret = IQN_ERROR;
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing space when parsing output "
+ "of '%s'"), ISCSIADM);
+ goto out;
+ }
+ *ifacename = strndup(line, token - line);
if (*ifacename == NULL) {
ret = IQN_ERROR;
virReportOOMError();