chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Verify validity of session name when received from outside
[elogind.git]
/
src
/
login
/
logind-session.c
diff --git
a/src/login/logind-session.c
b/src/login/logind-session.c
index dac50e833478b0cbf218719ecb42f28ed6ec3a97..2d22a68b6eb441438f6c75a51ab58f886d98c9af 100644
(file)
--- a/
src/login/logind-session.c
+++ b/
src/login/logind-session.c
@@
-41,6
+41,7
@@
Session* session_new(Manager *m, const char *id) {
assert(m);
assert(id);
assert(m);
assert(id);
+ assert(session_id_valid(id));
s = new0(Session, 1);
if (!s)
s = new0(Session, 1);
if (!s)
@@
-381,7
+382,8
@@
int session_activate(Session *s) {
}
static int session_link_x11_socket(Session *s) {
}
static int session_link_x11_socket(Session *s) {
- char *t, *f, *c;
+ _cleanup_free_ char *t = NULL, *f = NULL;
+ char *c;
size_t k;
assert(s);
size_t k;
assert(s);
@@
-405,7
+407,6
@@
static int session_link_x11_socket(Session *s) {
if (access(f, F_OK) < 0) {
log_warning("Session %s has display %s with non-existing socket %s.", s->id, s->display, f);
if (access(f, F_OK) < 0) {
log_warning("Session %s has display %s with non-existing socket %s.", s->id, s->display, f);
- free(f);
return -ENOENT;
}
return -ENOENT;
}
@@
-414,10
+415,8
@@
static int session_link_x11_socket(Session *s) {
* path is owned by the user */
t = strappend(s->user->runtime_path, "/X11-display");
* path is owned by the user */
t = strappend(s->user->runtime_path, "/X11-display");
- if (!t) {
- free(f);
+ if (!t)
return log_oom();
return log_oom();
- }
if (link(f, t) < 0) {
if (errno == EEXIST) {
if (link(f, t) < 0) {
if (errno == EEXIST) {
@@
-437,17
+436,12
@@
static int session_link_x11_socket(Session *s) {
}
log_error("Failed to link %s to %s: %m", f, t);
}
log_error("Failed to link %s to %s: %m", f, t);
- free(f);
- free(t);
return -errno;
}
}
done:
log_info("Linked %s to %s.", f, t);
return -errno;
}
}
done:
log_info("Linked %s to %s.", f, t);
- free(f);
- free(t);
-
s->user->display = s;
return 0;
s->user->display = s;
return 0;
@@
-585,7
+579,7
@@
static int session_stop_scope(Session *s) {
}
static int session_unlink_x11_socket(Session *s) {
}
static int session_unlink_x11_socket(Session *s) {
-
char *t
;
+
_cleanup_free_ char *t = NULL
;
int r;
assert(s);
int r;
assert(s);
@@
-601,8
+595,6
@@
static int session_unlink_x11_socket(Session *s) {
return log_oom();
r = unlink(t);
return log_oom();
r = unlink(t);
- free(t);
-
return r < 0 ? -errno : 0;
}
return r < 0 ? -errno : 0;
}