diff options
author | Olaf Flebbe <flebbe@nix.science-computing.de> | 2009-08-17 17:31:01 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-09-01 09:26:11 +0200 |
commit | 5404f974f012590b13249e015fa40f33a896d774 (patch) | |
tree | 78857cc27f647debaae5e57a7c8da6717498409d /source3/lib/util.c | |
parent | 6fdbdfb3668df2ec9d2f4a8108c91bc89b725a07 (diff) | |
download | samba-5404f974f012590b13249e015fa40f33a896d774.tar.gz samba-5404f974f012590b13249e015fa40f33a896d774.tar.xz samba-5404f974f012590b13249e015fa40f33a896d774.zip |
make smbcontrol smbd ping work proper checking for arguments handle short pid_t correctly
Fixes bug #6655.
(cherry picked from commit 5359e397ff190c35414f6961be61a5110e237dd5)
(cherry picked from commit 86c1dbb473323ef9480cb57584be9e02363e80af)
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r-- | source3/lib/util.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 61a73e60773..3d7336f957b 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2743,14 +2743,15 @@ bool procid_is_me(const struct server_id *pid) struct server_id interpret_pid(const char *pid_string) { -#ifdef CLUSTER_SUPPORT - unsigned int vnn, pid; struct server_id result; - if (sscanf(pid_string, "%u:%u", &vnn, &pid) == 2) { + int pid; +#ifdef CLUSTER_SUPPORT + unsigned int vnn; + if (sscanf(pid_string, "%u:%d", &vnn, &pid) == 2) { result.vnn = vnn; result.pid = pid; } - else if (sscanf(pid_string, "%u", &pid) == 1) { + else if (sscanf(pid_string, "%d", &pid) == 1) { result.vnn = get_my_vnn(); result.pid = pid; } @@ -2758,10 +2759,19 @@ struct server_id interpret_pid(const char *pid_string) result.vnn = NONCLUSTER_VNN; result.pid = -1; } - return result; #else - return pid_to_procid(atoi(pid_string)); + if (sscanf(pid_string, "%d", &pid) != 1) { + result.pid = -1; + } else { + result.pid = pid; + } #endif + /* Assigning to result.pid may have overflowed + Map negative pid to -1: i.e. error */ + if (result.pid < 0) { + result.pid = -1; + } + return result; } char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid) |