{
int ret;
+ errno = 0;
ret = fread((char *) buf, 1, len, ((krb5_scc_data *) id->data)->file);
- if (ret == 0)
+ if ((ret == 0) && errno)
return krb5_scc_interpret(errno);
else if (ret != len)
return KRB5_CC_END;
if (keyblock->contents == NULL)
return KRB5_CC_NOMEM;
+ errno = 0;
ret = fread((char *)keyblock->contents, 1,
(keyblock->length)*sizeof(krb5_octet),
((krb5_scc_data *) id->data)->file);
- if (ret == 0) {
+ if ((ret == 0) && errno) {
xfree(keyblock->contents);
return krb5_scc_interpret(errno);
}
if (data->data == NULL)
return KRB5_CC_NOMEM;
+ errno = 0;
ret = fread((char *)data->data, 1,
data->length, ((krb5_scc_data *) id->data)->file);
- if (ret == -1) {
+ if ((ret == 0) && errno) {
xfree(data->data);
return krb5_scc_interpret(errno);
}
if (addr->contents == NULL)
return KRB5_CC_NOMEM;
+ errno = 0;
ret = fread((char *)addr->contents, 1, (addr->length)*sizeof(krb5_octet),
((krb5_scc_data *) id->data)->file);
- if (ret == -1) {
+ if ((ret == 0) && errno) {
xfree(addr->contents);
return krb5_scc_interpret(errno);
}
a->contents = (krb5_octet *) malloc(a->length);
if (a->contents == NULL)
return KRB5_CC_NOMEM;
+ errno = 0;
ret = fread ((char *)a->contents, 1,
(a->length)*sizeof(krb5_octet),
((krb5_scc_data *) id->data)->file);
- if (ret == 0) {
+ if ((ret == 0) && errno) {
xfree(a->contents);
return krb5_scc_interpret(errno);
}
{
int ret;
+ errno = 0;
ret = fwrite((char *) buf, 1, len, ((krb5_scc_data *)id->data)->file);
- if (ret == 0) {
+ if ((ret == 0) && errno) {
return krb5_scc_interpret (errno);
- }
+ } else if (ret != len)
+ return KRB5_CC_END;
return KRB5_OK;
}
CHECK(ret);
ret = krb5_scc_store_int(id, &keyblock->length);
CHECK(ret);
+ errno = 0;
ret = fwrite((char *)keyblock->contents, 1,
(keyblock->length)*sizeof(krb5_octet),
((krb5_scc_data *) id->data)->file);
- if (ret == 0)
+ if ((ret == 0) && errno)
return krb5_scc_interpret(errno);
if (ret != (keyblock->length)*sizeof(krb5_octet))
return KRB5_CC_END;
CHECK(ret);
ret = krb5_scc_store_int(id, &addr->length);
CHECK(ret);
+ errno = 0;
ret = fwrite((char *)addr->contents, 1,
(addr->length)*sizeof(krb5_octet),
((krb5_scc_data *) id->data)->file);
- if (ret == 0)
+ if ((ret == 0) && errno)
return krb5_scc_interpret(errno);
if (ret != (addr->length)*sizeof(krb5_octet))
return KRB5_CC_END;
ret = krb5_scc_store_int32(id, &data->length);
CHECK(ret);
+ errno = 0;
ret = fwrite(data->data, 1, data->length,
((krb5_scc_data *) id->data)->file);
- if (ret == 0)
+ if ((ret == 0) && errno)
return krb5_scc_interpret(errno);
-
+ else if (ret != data->length)
+ return KRB5_CC_END;
return KRB5_OK;
}
CHECK(ret);
ret = krb5_scc_store_int32(id, &a->length);
CHECK(ret);
- return krb5_scc_write(id, a->contents, a->length);
+ return krb5_scc_write(id, (krb5_pointer) a->contents, a->length);
}