-/* Copyright 1999-2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
char *pw;
apr_md5_ctx_t context;
unsigned char digest[16];
- char string[MAX_STRING_LEN];
+ char string[3 * MAX_STRING_LEN]; /* this includes room for 2 * ':' + '\0' */
char pwin[MAX_STRING_LEN];
char pwv[MAX_STRING_LEN];
unsigned int i;
apr_file_printf(f, "%s:%s:", user, realm);
/* Do MD5 stuff */
- sprintf(string, "%s:%s:%s", user, realm, pw);
+ apr_snprintf(string, sizeof(string), "%s:%s:%s", user, realm, pw);
apr_md5_init(&context);
#if APR_CHARSET_EBCDIC
char *dirname;
char user[MAX_STRING_LEN];
char realm[MAX_STRING_LEN];
- char line[MAX_STRING_LEN];
- char l[MAX_STRING_LEN];
+ char line[3 * MAX_STRING_LEN];
+ char l[3 * MAX_STRING_LEN];
char w[MAX_STRING_LEN];
char x[MAX_STRING_LEN];
int found;
apr_strerror(rv, errmsg, sizeof errmsg));
exit(1);
}
+ apr_cpystrn(user, argv[4], sizeof(user));
+ apr_cpystrn(realm, argv[3], sizeof(realm));
apr_file_printf(errfile, "Adding password for %s in realm %s.\n",
- argv[4], argv[3]);
- add_password(argv[4], argv[3], f);
+ user, realm);
+ add_password(user, realm, f);
apr_file_close(f);
exit(0);
}
apr_cpystrn(realm, argv[2], sizeof(realm));
found = 0;
- while (!(get_line(line, MAX_STRING_LEN, f))) {
+ while (!(get_line(line, sizeof(line), f))) {
if (found || (line[0] == '#') || (!line[0])) {
putline(tfp, line);
continue;