From: Guus Sliepen Date: Fri, 22 Oct 2010 20:43:50 +0000 (+0200) Subject: Abort disabling old PEM keys on I/O errors. X-Git-Tag: release-1.0.14~40 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=20ae7dd8c12390f7360eb28cc17e1b8a8a706b06;p=oweals%2Ftinc.git Abort disabling old PEM keys on I/O errors. --- diff --git a/src/conf.c b/src/conf.c index f5f6c3a..c5467d2 100644 --- a/src/conf.c +++ b/src/conf.c @@ -459,24 +459,33 @@ bool disable_old_keys(FILE *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'; - 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'; - 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); + if(pos < 0) + break; } return disabled;