- case '1': /* File length in bytes */
- for (i = 0; (i < aln) && (i < ABUFL); i++) /* Copy it */
- abuf[i] = *s++;
- abuf[i] = '\0'; /* Terminate with null */
- if (i < aln) s += (aln - i);
- yy->length = atol(abuf); /* Convert to number */
- debug(F111,"gattr length",abuf,(int) yy->length);
- break;
-
+ case '!': /* File length in K */
+ case '1': { /* File length in bytes */
+ char * l2;
+ CK_OFF_T xlen;
+ for (i = 0; (i < aln) && (i < ABUFL); i++) /* Copy it */
+ abuf[i] = *s++;
+ abuf[i] = '\0'; /* Terminate with null */
+ if (i < aln) s += (aln - i);
+ if (rdigits(abuf)) { /* Make sure string is all digits */
+ xlen = ckatofs(abuf); /* Convert to number */
+ l2 = ckfstoa(xlen); /* Convert number back to string */
+ if (c == '1')
+ debug(F111,"gattr length",abuf,xlen);
+ else
+ debug(F111,"gattr lengthk",abuf,xlen);
+ if (ckstrcmp(abuf,l2,-1,1)) { /* This is how we check... */
+ xlen = (CK_OFF_T)-2; /* -2 = unk, possibly too long */
+ overflow++;
+ debug(F111,"gattr overflow",
+ (c == '1') ? "length" : "lengthk",
+ xlen);
+ }
+ if (c == '1') {
+ yy->length = xlen;
+ debug(F101,"gattr length","",xlen);
+ } else {
+ yy->lengthk = xlen;
+ debug(F101,"gattr lengthk","",xlen);
+ }
+ }
+ /* If the length field is not numeric accept the file */
+ /* anyway but with an unknown length */
+ break;
+ }