author | Michael Krelin <hacker@klever.net> | 2007-11-21 12:09:06 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-11-21 12:09:06 (UTC) |
commit | d31def2b6dc0fb5c4a17918d608d9f5107372a74 (patch) (unidiff) | |
tree | a52663a3db03f75d647e6dfea5fe173cdd37d528 | |
parent | f0877a6af785a36ef769114816c71a838295d902 (diff) | |
download | libopkele-d31def2b6dc0fb5c4a17918d608d9f5107372a74.zip libopkele-d31def2b6dc0fb5c4a17918d608d9f5107372a74.tar.gz libopkele-d31def2b6dc0fb5c4a17918d608d9f5107372a74.tar.bz2 |
keep compiler happy and check more error conditions
Thanks Marcus Rueckert for pointing this out
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/util.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/util.cc b/lib/util.cc index 94f6f53..94e09ed 100644 --- a/lib/util.cc +++ b/lib/util.cc | |||
@@ -25,15 +25,16 @@ namespace opkele { | |||
25 | BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL); | 25 | BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL); |
26 | bmem = BIO_new(BIO_s_mem()); | 26 | bmem = BIO_new(BIO_s_mem()); |
27 | BIO_set_flags(b64,BIO_CLOSE); | 27 | BIO_set_flags(b64,BIO_CLOSE); |
28 | if(!bmem) | 28 | if(!bmem) |
29 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() memory buffer"); | 29 | throw exception_openssl(OPKELE_CP_ "failed to BIO_new() memory buffer"); |
30 | BIO_push(b64,bmem); | 30 | BIO_push(b64,bmem); |
31 | if(BIO_write(b64,data,length)!=length) | 31 | if(((size_t)BIO_write(b64,data,length))!=length) |
32 | throw exception_openssl(OPKELE_CP_ "failed to BIO_write()"); | 32 | throw exception_openssl(OPKELE_CP_ "failed to BIO_write()"); |
33 | BIO_flush(b64); | 33 | if(BIO_flush(b64)!=1) |
34 | throw exception_openssl(OPKELE_CP_ "failed to BIO_flush()"); | ||
34 | char *rvd; | 35 | char *rvd; |
35 | long rvl = BIO_get_mem_data(bmem,&rvd); | 36 | long rvl = BIO_get_mem_data(bmem,&rvd); |
36 | string rv(rvd,rvl); | 37 | string rv(rvd,rvl); |
37 | BIO_free_all(b64); | 38 | BIO_free_all(b64); |
38 | return rv; | 39 | return rv; |
39 | }catch(...) { | 40 | }catch(...) { |
@@ -141,13 +142,13 @@ namespace opkele { | |||
141 | return rv; | 142 | return rv; |
142 | } | 143 | } |
143 | 144 | ||
144 | string long_to_string(long l) { | 145 | string long_to_string(long l) { |
145 | char rv[32]; | 146 | char rv[32]; |
146 | int r=snprintf(rv,sizeof(rv),"%ld",l); | 147 | int r=snprintf(rv,sizeof(rv),"%ld",l); |
147 | if(r<0 || r>=sizeof(rv)) | 148 | if(r<0 || r>=(int)sizeof(rv)) |
148 | throw failed_conversion(OPKELE_CP_ "failed to snprintf()"); | 149 | throw failed_conversion(OPKELE_CP_ "failed to snprintf()"); |
149 | return rv; | 150 | return rv; |
150 | } | 151 | } |
151 | 152 | ||
152 | long string_to_long(const string& s) { | 153 | long string_to_long(const string& s) { |
153 | char *endptr = 0; | 154 | char *endptr = 0; |