projects
/
blerg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
52e09e8
)
Paranoia fix for reading password version
author
Chip Black
<bytex64@bytex64.net>
Fri, 31 May 2013 00:03:23 +0000
(19:03 -0500)
committer
Chip Black
<bytex64@bytex64.net>
Fri, 31 May 2013 00:03:23 +0000
(19:03 -0500)
common/auth.c
patch
|
blob
|
history
diff --git
a/common/auth.c
b/common/auth.c
index
6e5f346
..
3fd0376
100644
(file)
--- a/
common/auth.c
+++ b/
common/auth.c
@@
-66,7
+66,7
@@
int auth_get_password_version(const char *username) {
char filename[512];
int fd;
char str[4];
- int
versio
n;
+ int
le
n;
sprintf(filename, "%s/%s/password_version", DATA_PATH, username);
if (access(filename, F_OK) != 0) {
@@
-74,8
+74,9
@@
int auth_get_password_version(const char *username) {
}
fd = open(filename, O_RDONLY);
- read(fd, str, 4);
+
len =
read(fd, str, 4);
close(fd);
+ str[len] = 0;
/* strtol returns zero if there isn't a number */
return strtol(str, NULL, 10);
}