Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ZerXes
Tor
Commits
36fb8e83
Commit
36fb8e83
authored
Oct 10, 2003
by
Roger Dingledine
Browse files
change WARNING to WARN
svn:r570
parent
ecfb3682
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/common/crypto.c
View file @
36fb8e83
...
...
@@ -211,17 +211,17 @@ crypto_create_init_cipher(int cipher_type, char *key, char *iv, int encrypt_mode
crypto_cipher_env_t
*
crypto
=
NULL
;
if
(
!
(
crypto
=
crypto_new_cipher_env
(
cipher_type
)))
{
log_fn
(
LOG_WARN
ING
,
"Unable to allocate crypto object"
);
log_fn
(
LOG_WARN
,
"Unable to allocate crypto object"
);
return
NULL
;
}
if
(
crypto_cipher_set_key
(
crypto
,
key
))
{
log_fn
(
LOG_WARN
ING
,
"Unable to set key: %s"
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Unable to set key: %s"
,
crypto_perror
());
goto
error
;
}
if
(
crypto_cipher_set_iv
(
crypto
,
iv
))
{
log_fn
(
LOG_WARN
ING
,
"Unable to set iv: %s"
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Unable to set iv: %s"
,
crypto_perror
());
goto
error
;
}
...
...
@@ -231,7 +231,7 @@ crypto_create_init_cipher(int cipher_type, char *key, char *iv, int encrypt_mode
r
=
crypto_cipher_decrypt_init_cipher
(
crypto
);
if
(
r
)
{
log_fn
(
LOG_WARN
ING
,
"Unable to initialize cipher: %s"
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Unable to initialize cipher: %s"
,
crypto_perror
());
goto
error
;
}
return
crypto
;
...
...
@@ -367,7 +367,7 @@ int crypto_pk_read_private_key_from_filename(crypto_pk_env_t *env, const char *k
/* read the private key */
if
(
crypto_pk_read_private_key_from_file
(
env
,
f_pr
)
<
0
)
{
log_fn
(
LOG_WARN
ING
,
"Error reading private key : %s"
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Error reading private key : %s"
,
crypto_perror
());
fclose
(
f_pr
);
return
-
1
;
}
...
...
@@ -376,10 +376,10 @@ int crypto_pk_read_private_key_from_filename(crypto_pk_env_t *env, const char *k
/* check the private key */
switch
(
crypto_pk_check_key
(
env
))
{
case
0
:
log_fn
(
LOG_WARN
ING
,
"Private key read but is invalid : %s."
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Private key read but is invalid : %s."
,
crypto_perror
());
return
-
1
;
case
-
1
:
log_fn
(
LOG_WARN
ING
,
"Private key read but validity checking failed : %s"
,
crypto_perror
());
log_fn
(
LOG_WARN
,
"Private key read but validity checking failed : %s"
,
crypto_perror
());
return
-
1
;
/* case 1: fall through */
}
...
...
@@ -982,14 +982,14 @@ int crypto_seed_rng()
n
=
fread
(
buf
,
1
,
20
,
f
);
fclose
(
f
);
if
(
n
!=
20
)
{
log_fn
(
LOG_WARN
ING
,
"Error reading from entropy source"
);
log_fn
(
LOG_WARN
,
"Error reading from entropy source"
);
return
-
1
;
}
RAND_seed
(
buf
,
20
);
return
0
;
}
log_fn
(
LOG_WARN
ING
,
"Cannot seed RNG -- no entropy source found."
);
log_fn
(
LOG_WARN
,
"Cannot seed RNG -- no entropy source found."
);
return
-
1
;
}
...
...
src/common/log.c
View file @
36fb8e83
...
...
@@ -18,7 +18,7 @@ static INLINE const char *sev_to_string(int severity) {
switch
(
severity
)
{
case
LOG_DEBUG
:
return
"debug"
;
case
LOG_INFO
:
return
"info"
;
case
LOG_WARN
ING
:
return
"warn"
;
case
LOG_WARN
:
return
"warn"
;
case
LOG_ERR
:
return
"err"
;
default:
assert
(
0
);
return
"UNKNOWN"
;
}
...
...
src/common/log.h
View file @
36fb8e83
...
...
@@ -9,15 +9,12 @@
#ifdef HAVE_SYSLOG_H
#include
<syslog.h>
#define LOG_WARN LOG_WARNING
#else
#define LOG_DEBUG 0
#define LOG_INFO 1
#define LOG_NOTICE 2
#define LOG_WARNING 3
#define LOG_WARN 3
#define LOG_ERR 4
#define LOG_CRIT 5
#define LOG_ALERT 6
#define LOG_EMERG 7
#endif
/* magic to make GCC check for proper format strings. */
...
...
src/common/tortls.c
View file @
36fb8e83
...
...
@@ -215,7 +215,7 @@ tor_tls_context_new(crypto_pk_env_t *rsa,
if
(
rsa
)
{
cert
=
tor_tls_create_certificate
(
rsa
,
nickname
);
if
(
!
cert
)
{
log
(
LOG_WARN
ING
,
"Error creating certificate"
);
log
(
LOG_WARN
,
"Error creating certificate"
);
return
-
1
;
}
}
...
...
@@ -415,7 +415,7 @@ tor_tls_shutdown(tor_tls *tls)
*/
if
(
tls
->
state
==
TOR_TLS_ST_GOTCLOSE
||
tls
->
state
==
TOR_TLS_ST_SENTCLOSE
)
{
log
(
LOG_WARN
ING
,
log
(
LOG_WARN
,
"TLS returned
\"
half-closed
\"
value while already half-closed"
);
return
TOR_TLS_ERROR
;
}
...
...
src/common/util.c
View file @
36fb8e83
...
...
@@ -64,7 +64,7 @@ tv_udiff(struct timeval *start, struct timeval *end)
long
secdiff
=
end
->
tv_sec
-
start
->
tv_sec
;
if
(
secdiff
+
1
>
LONG_MAX
/
1000000
)
{
log_fn
(
LOG_WARN
ING
,
"comparing times too far apart."
);
log_fn
(
LOG_WARN
,
"comparing times too far apart."
);
return
LONG_MAX
;
}
...
...
@@ -335,17 +335,17 @@ int check_private_dir(const char *dirname, int create)
struct
stat
st
;
if
(
stat
(
dirname
,
&
st
))
{
if
(
errno
!=
ENOENT
)
{
log
(
LOG_WARN
ING
,
"Directory %s cannot be read: %s"
,
dirname
,
log
(
LOG_WARN
,
"Directory %s cannot be read: %s"
,
dirname
,
strerror
(
errno
));
return
-
1
;
}
if
(
!
create
)
{
log
(
LOG_WARN
ING
,
"Directory %s does not exist."
,
dirname
);
log
(
LOG_WARN
,
"Directory %s does not exist."
,
dirname
);
return
-
1
;
}
log
(
LOG_INFO
,
"Creating directory %s"
,
dirname
);
if
(
mkdir
(
dirname
,
0700
))
{
log
(
LOG_WARN
ING
,
"Error creating directory %s: %s"
,
dirname
,
log
(
LOG_WARN
,
"Error creating directory %s: %s"
,
dirname
,
strerror
(
errno
));
return
-
1
;
}
else
{
...
...
@@ -353,17 +353,17 @@ int check_private_dir(const char *dirname, int create)
}
}
if
(
!
(
st
.
st_mode
&
S_IFDIR
))
{
log
(
LOG_WARN
ING
,
"%s is not a directory"
,
dirname
);
log
(
LOG_WARN
,
"%s is not a directory"
,
dirname
);
return
-
1
;
}
if
(
st
.
st_uid
!=
getuid
())
{
log
(
LOG_WARN
ING
,
"%s is not owned by this UID (%d)"
,
dirname
,
getuid
());
log
(
LOG_WARN
,
"%s is not owned by this UID (%d)"
,
dirname
,
getuid
());
return
-
1
;
}
if
(
st
.
st_mode
&
0077
)
{
log
(
LOG_WARN
ING
,
"Fixing permissions on directory %s"
,
dirname
);
log
(
LOG_WARN
,
"Fixing permissions on directory %s"
,
dirname
);
if
(
chmod
(
dirname
,
0700
))
{
log
(
LOG_WARN
ING
,
"Could not chmod directory %s: %s"
,
dirname
,
log
(
LOG_WARN
,
"Could not chmod directory %s: %s"
,
dirname
,
strerror
(
errno
));
return
-
1
;
}
else
{
...
...
@@ -380,28 +380,28 @@ write_str_to_file(const char *fname, const char *str)
int
fd
;
FILE
*
file
;
if
(
strlen
(
fname
)
>
1000
)
{
log
(
LOG_WARN
ING
,
"Filename %s is too long."
,
fname
);
log
(
LOG_WARN
,
"Filename %s is too long."
,
fname
);
return
-
1
;
}
strcpy
(
tempname
,
fname
);
strcat
(
tempname
,
".tmp"
);
if
((
fd
=
open
(
tempname
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0600
))
<
0
)
{
log
(
LOG_WARN
ING
,
"Couldn't open %s for writing: %s"
,
tempname
,
log
(
LOG_WARN
,
"Couldn't open %s for writing: %s"
,
tempname
,
strerror
(
errno
));
return
-
1
;
}
if
(
!
(
file
=
fdopen
(
fd
,
"w"
)))
{
log
(
LOG_WARN
ING
,
"Couldn't fdopen %s for writing: %s"
,
tempname
,
log
(
LOG_WARN
,
"Couldn't fdopen %s for writing: %s"
,
tempname
,
strerror
(
errno
));
close
(
fd
);
return
-
1
;
}
if
(
fputs
(
str
,
file
)
==
EOF
)
{
log
(
LOG_WARN
ING
,
"Error writing to %s: %s"
,
tempname
,
strerror
(
errno
));
log
(
LOG_WARN
,
"Error writing to %s: %s"
,
tempname
,
strerror
(
errno
));
fclose
(
file
);
return
-
1
;
}
fclose
(
file
);
if
(
rename
(
tempname
,
fname
))
{
log
(
LOG_WARN
ING
,
"Error replacing %s: %s"
,
fname
,
strerror
(
errno
));
log
(
LOG_WARN
,
"Error replacing %s: %s"
,
fname
,
strerror
(
errno
));
return
-
1
;
}
return
0
;
...
...
@@ -415,7 +415,7 @@ char *read_file_to_str(const char *filename) {
assert
(
filename
);
if
(
strcspn
(
filename
,
CONFIG_LEGAL_FILENAME_CHARACTERS
)
!=
0
)
{
log_fn
(
LOG_WARN
ING
,
"Filename %s contains illegal characters."
,
filename
);
log_fn
(
LOG_WARN
,
"Filename %s contains illegal characters."
,
filename
);
return
NULL
;
}
...
...
@@ -426,14 +426,14 @@ char *read_file_to_str(const char *filename) {
fd
=
open
(
filename
,
O_RDONLY
,
0
);
if
(
fd
<
0
)
{
log_fn
(
LOG_WARN
ING
,
"Could not open %s."
,
filename
);
log_fn
(
LOG_WARN
,
"Could not open %s."
,
filename
);
return
NULL
;
}
string
=
tor_malloc
(
statbuf
.
st_size
+
1
);
if
(
read_all
(
fd
,
string
,
statbuf
.
st_size
)
!=
statbuf
.
st_size
)
{
log_fn
(
LOG_WARN
ING
,
"Couldn't read all %ld bytes of file '%s'."
,
log_fn
(
LOG_WARN
,
"Couldn't read all %ld bytes of file '%s'."
,
(
long
)
statbuf
.
st_size
,
filename
);
free
(
string
);
close
(
fd
);
...
...
@@ -485,7 +485,7 @@ try_next_line:
value
++
;
if
(
!*
end
||
!*
value
)
{
/* only a key on this line. no value. */
log_fn
(
LOG_WARN
ING
,
"Line has keyword '%s' but no value. Skipping."
,
s
);
log_fn
(
LOG_WARN
,
"Line has keyword '%s' but no value. Skipping."
,
s
);
goto
try_next_line
;
}
*
end
=
0
;
/* null it out */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment