Peter Wu
changed
bug 11268
What |
Removed |
Added |
Status |
UNCONFIRMED
|
CONFIRMED
|
CC |
|
peter@lekensteyn.nl
|
Ever confirmed |
|
1
|
Comment # 2
on bug 11268
from Peter Wu
Confirmed with the latest code, v1.99.8rc0-214-g59d56bf and GCC 5.1.0.
For some reason size = 0x7fffffffffffffff while I would expect
0xffffffffffffffff for (signed long)-1.
long size;
/* ... */
if ((size = ftell(fp)) < 0) {
ssl_debug_printf("ssl_load_key: can't ftell file\n");
g_free(private_key);
return NULL;
}
if (fseek(fp, 0, SEEK_SET) < 0) {
ssl_debug_printf("ssl_load_key: can't re-fseek file\n");
g_free(private_key);
return NULL;
}
key.data = "" char *)g_malloc(size);
Minimal reproducer below, strange enough it also shows the 0x7fffffffffffffff
behavior with /usr, but not with /tmp/. Perhaps filesystems can somehow be
opened on Linux as well? (On BSD you can just read directory contents iirc.)
#include <stdio.h>
#define P(r, expr) do { r = (expr); printf("%s = %ld\n", #expr, r); \
if (r < 0) { puts("FAIL"); return 1; } } while (0)
int main(int argc, char **argv) {
long r, size;
if (argc < 2) return 1;
FILE *fp = fopen(argv[1], "r");
P(r, fseek(fp, 0, SEEK_END));
P(size, ftell(fp));
P(r, fseek(fp, 0, SEEK_SET));
printf("size = %#lx\n", size);
fclose(fp);
}
You are receiving this mail because:
- You are watching all bug changes.