diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-15 21:46:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:17:29 -0500 |
commit | c2528679d8a5da90c027f21c4970a211c5175da9 (patch) | |
tree | 696414a1ed761e0e537e152fea4c316e3c375d28 | |
parent | 9e7377e81f61b2a3e4b8ff4cc5cd926e25ddacf3 (diff) | |
download | samba-c2528679d8a5da90c027f21c4970a211c5175da9.tar.gz samba-c2528679d8a5da90c027f21c4970a211c5175da9.tar.bz2 samba-c2528679d8a5da90c027f21c4970a211c5175da9.zip |
r16270: Fix Klocwork #706 - ensure sscanf has correct format
specifier.
Jeremy.
(This used to be commit dc53d35b0a1491da94e231943a81547be4c75631)
-rw-r--r-- | source3/utils/net_idmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 0b5f68101e..47e1f93b69 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -193,7 +193,7 @@ static int net_idmap_restore(int argc, const char **argv) } while (!feof(stdin)) { - fstring line, sid_string; + fstring line, sid_string, fmt_string; int len; unid_t id; int type = ID_EMPTY; @@ -208,14 +208,15 @@ static int net_idmap_restore(int argc, const char **argv) line[len-1] = '\0'; /* Yuck - this is broken for sizeof(gid_t) != sizeof(int) */ - - if (sscanf(line, "GID %d %s", &id.gid, sid_string) == 2) { + snprintf(fmt_string, sizeof(fmt_string), "GID %%d %%%us", FSTRING_LEN); + if (sscanf(line, fmt_string, &id.gid, sid_string) == 2) { type = ID_GROUPID; } /* Yuck - this is broken for sizeof(uid_t) != sizeof(int) */ - if (sscanf(line, "UID %d %s", &id.uid, sid_string) == 2) { + snprintf(fmt_string, sizeof(fmt_string), "UID %%d %%%us", FSTRING_LEN); + if (sscanf(line, fmt_string, &id.uid, sid_string) == 2) { type = ID_USERID; } |