Fix a bug. read(2) returns a signed value. read(2) errors were not detected in

the previous code.

card-piv.c:833:10: warning: comparison of unsigned expression < 0 is always
      false [-Wsign-compare]
        if (len < 0) {
            ~~~ ^ ~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5135 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
ludovic.rousseau 2011-02-05 17:34:29 +00:00
parent 6ccb540185
commit b3aee43e96
1 changed files with 4 additions and 2 deletions

View File

@ -812,6 +812,7 @@ static int piv_read_obj_from_file(sc_card_t * card, char * filename,
int r;
int f = -1;
size_t len;
ssize_t res;
u8 tagbuf[16];
size_t rbuflen;
const u8 * body;
@ -829,12 +830,13 @@ static int piv_read_obj_from_file(sc_card_t * card, char * filename,
r = SC_ERROR_FILE_NOT_FOUND;
goto err;
}
len = read(f, tagbuf, sizeof(tagbuf)); /* get tag and length */
if (len < 0) {
res = read(f, tagbuf, sizeof(tagbuf)); /* get tag and length */
if (res < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Problem with \"%s\"\n",filename);
r = SC_ERROR_DATA_OBJECT_NOT_FOUND;
goto err;
}
len = res;
body = tagbuf;
if (sc_asn1_read_tag(&body, 0xfffff, &cla_out,
&tag_out, &bodylen) != SC_SUCCESS) {