SHA256
1
0
forked from pool/systemd
systemd/check-for-empty-strings-in-strto-conversions.patch

96 lines
3.0 KiB
Diff
Raw Normal View History

Accepting request 149703 from home:fcrozat:branches:Base:System - Add systemctl-options.patch: handle SYSTEMCTL_OPTIONS internaly (bnc#798620). - Update crypt-loop-file.patch to correctly detect crypto loop files (bnc#799514). - Add journalctl-remove-leftover-message.patch: remove debug message in systemctl. - Add job-avoid-recursion-when-cancelling.patch: prevent potential recursion when cancelling a service. - Add sysctl-parse-all-keys.patch: ensure sysctl file is fully parsed. - Add journal-fix-cutoff-max-date.patch: fix computation of cutoff max date for journal. - Add reword-rescue-mode-hints.patch: reword rescue prompt. - Add improve-overflow-checks.patch: improve time overflow checks. - Add fix-swap-behaviour-with-symlinks.patch: fix swap behaviour with symlinks. - Add hostnamectl-fix-set-hostname-with-no-argument.patch: ensure hostnamectl requires an argument when called with set-hostname option. - Add agetty-overrides-term.patch: pass correctly terminal type to agetty. - Add check-for-empty-strings-in-strto-conversions.patch: better check for empty strings in strto* conversions. - Add strv-cleanup-error-path-loops.patch: cleanup strv on error path. - Add cryptsetup-handle-plain.patch: correctly handle "plain" option in cryptsetup. - Add fstab-generator-improve-error-message.patch: improve error message in fstab-generator. - Add delta-accept-t-option.patch: accept -t option in OBS-URL: https://build.opensuse.org/request/show/149703 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=331
2013-01-23 14:44:07 +01:00
From f3910003bce32ebdc1dbb71fd9ca2d4b8352b563 Mon Sep 17 00:00:00 2001
From: Michal Schmidt <mschmidt@redhat.com>
Date: Tue, 30 Oct 2012 10:29:40 +0100
Subject: [PATCH] shared, libsystemd-daemon: check for empty strings in
strto*l conversions
strtol() and friends may set EINVAL if no conversion was performed, but
they are not required to do so. In practice they don't. We need to check
for it.
https://bugzilla.redhat.com/show_bug.cgi?id=870577
---
src/libsystemd-daemon/sd-daemon.c | 4 ++--
src/shared/conf-parser.c | 2 +-
src/shared/util.c | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 863ac75..480db3b 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -88,7 +88,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) {
goto finish;
}
- if (!p || *p || l <= 0) {
+ if (!p || p == e || *p || l <= 0) {
r = -EINVAL;
goto finish;
}
@@ -112,7 +112,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) {
goto finish;
}
- if (!p || *p) {
+ if (!p || p == e || *p) {
r = -EINVAL;
goto finish;
}
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 4bf3147..9f5c07c 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -865,7 +865,7 @@ int config_parse_mode(
errno = 0;
l = strtol(rvalue, &x, 8);
- if (!x || *x || errno) {
+ if (!x || x == rvalue || *x || errno) {
log_error("[%s:%u] Failed to parse mode value, ignoring: %s", filename, line, rvalue);
return 0;
}
diff --git a/src/shared/util.c b/src/shared/util.c
index 8ec83e4..23832fe 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -377,7 +377,7 @@ int safe_atou(const char *s, unsigned *ret_u) {
errno = 0;
l = strtoul(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
if ((unsigned long) (unsigned) l != l)
@@ -397,7 +397,7 @@ int safe_atoi(const char *s, int *ret_i) {
errno = 0;
l = strtol(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
if ((long) (int) l != l)
@@ -417,7 +417,7 @@ int safe_atollu(const char *s, long long unsigned *ret_llu) {
errno = 0;
l = strtoull(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
*ret_llu = l;
@@ -434,7 +434,7 @@ int safe_atolli(const char *s, long long int *ret_lli) {
errno = 0;
l = strtoll(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
*ret_lli = l;
--
1.7.10.4