r19487: Fix coverity # 313
[Samba.git] / examples / libsmbclient / get_auth_data_fn.h
blobeb493885af207b2e0ec71ccbf71bd2136e6cc90a
1 static void
2 get_auth_data_fn(const char * pServer,
3 const char * pShare,
4 char * pWorkgroup,
5 int maxLenWorkgroup,
6 char * pUsername,
7 int maxLenUsername,
8 char * pPassword,
9 int maxLenPassword)
11 char temp[128];
13 fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
14 fgets(temp, sizeof(temp), stdin);
16 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
18 temp[strlen(temp) - 1] = '\0';
21 if (temp[0] != '\0')
23 strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
26 fprintf(stdout, "Username: [%s] ", pUsername);
27 fgets(temp, sizeof(temp), stdin);
29 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
31 temp[strlen(temp) - 1] = '\0';
34 if (temp[0] != '\0')
36 strncpy(pUsername, temp, maxLenUsername - 1);
39 fprintf(stdout, "Password: ");
40 fgets(temp, sizeof(temp), stdin);
42 if (temp[strlen(temp) - 1] == '\n') /* A new line? */
44 temp[strlen(temp) - 1] = '\0';
47 if (temp[0] != '\0')
49 strncpy(pPassword, temp, maxLenPassword - 1);