projects
/
oweals
/
tinc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a08462b
)
Abort disabling old PEM keys on I/O errors.
author
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 22 Oct 2010 20:43:50 +0000
(22:43 +0200)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 22 Oct 2010 20:43:50 +0000
(22:43 +0200)
src/conf.c
patch
|
blob
|
history
diff --git
a/src/conf.c
b/src/conf.c
index f5f6c3a4cab25279ac6803a52984117a1202203b..c5467d20ad3028583f1be2afa486340df6b38de1 100644
(file)
--- a/
src/conf.c
+++ b/
src/conf.c
@@
-459,24
+459,33
@@
bool disable_old_keys(FILE *f) {
rewind(f);
pos = ftell(f);
rewind(f);
pos = ftell(f);
+ if(pos < 0)
+ return false;
+
while(fgets(buf, sizeof buf, f)) {
if(!strncmp(buf, "-----BEGIN RSA", 14)) {
buf[11] = 'O';
buf[12] = 'L';
buf[13] = 'D';
while(fgets(buf, sizeof buf, f)) {
if(!strncmp(buf, "-----BEGIN RSA", 14)) {
buf[11] = 'O';
buf[12] = 'L';
buf[13] = 'D';
- fseek(f, pos, SEEK_SET);
- fputs(buf, f);
+ if(fseek(f, pos, SEEK_SET))
+ break;
+ if(fputs(buf, f) <= 0)
+ break;
disabled = true;
}
else if(!strncmp(buf, "-----END RSA", 12)) {
buf[ 9] = 'O';
buf[10] = 'L';
buf[11] = 'D';
disabled = true;
}
else if(!strncmp(buf, "-----END RSA", 12)) {
buf[ 9] = 'O';
buf[10] = 'L';
buf[11] = 'D';
- fseek(f, pos, SEEK_SET);
- fputs(buf, f);
+ if(fseek(f, pos, SEEK_SET))
+ break;
+ if(fputs(buf, f) <= 0)
+ break;
disabled = true;
}
pos = ftell(f);
disabled = true;
}
pos = ftell(f);
+ if(pos < 0)
+ break;
}
return disabled;
}
return disabled;