From c2528679d8a5da90c027f21c4970a211c5175da9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Jun 2006 21:46:15 +0000 Subject: [PATCH] r16270: Fix Klocwork #706 - ensure sscanf has correct format specifier. Jeremy. (This used to be commit dc53d35b0a1491da94e231943a81547be4c75631) --- source3/utils/net_idmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 0b5f68101ed..47e1f93b69f 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; }