SHA256
1
0
forked from pool/systemd
systemd/check-for-empty-strings-in-strto-conversions.patch
Stephan Kulow 0b12bae943 Accepting request 160211 from Base:System
Please checkin also to openSUSE 12.3

- udev: re-add persistent network rules (bnc#809843).
  add: 1026-re-add-persistent-net.patch
- rebase all patches, ensure that they apply properly.

OBS-URL: https://build.opensuse.org/request/show/160211
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=134
2013-03-22 11:08:23 +00:00

93 lines
3.1 KiB
Diff

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(-)
Index: systemd-195/src/libsystemd-daemon/sd-daemon.c
===================================================================
--- systemd-195.orig/src/libsystemd-daemon/sd-daemon.c
+++ systemd-195/src/libsystemd-daemon/sd-daemon.c
@@ -88,7 +88,7 @@ _sd_export_ int sd_listen_fds(int unset_
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_
goto finish;
}
- if (!p || *p) {
+ if (!p || p == e || *p) {
r = -EINVAL;
goto finish;
}
Index: systemd-195/src/shared/conf-parser.c
===================================================================
--- systemd-195.orig/src/shared/conf-parser.c
+++ systemd-195/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;
}
Index: systemd-195/src/shared/util.c
===================================================================
--- systemd-195.orig/src/shared/util.c
+++ systemd-195/src/shared/util.c
@@ -388,7 +388,7 @@ int safe_atou(const char *s, unsigned *r
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)
@@ -408,7 +408,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)
@@ -428,7 +428,7 @@ int safe_atollu(const char *s, long long
errno = 0;
l = strtoull(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
*ret_llu = l;
@@ -445,7 +445,7 @@ int safe_atolli(const char *s, long long
errno = 0;
l = strtoll(s, &x, 0);
- if (!x || *x || errno)
+ if (!x || x == s || *x || errno)
return errno ? -errno : -EINVAL;
*ret_lli = l;