struct dirent* ad_entry;
int found = 0;
- strncat(curpath, "/", MAXPATHLEN);
- strncat(curpath, ".AppleDouble", MAXPATHLEN);
+ strlcat(curpath, "/", sizeof(curpath));
+ strlcat(curpath, ".AppleDouble", sizeof(curpath));
if (NULL == (adouble = opendir(curpath))) {
return(-1);
id = add_dir_db(name, cur_did);
if ( id == 0)
continue; /* skip, no ID */
- strncat(curpath, "/", MAXPATHLEN);
- strncat(curpath, name, MAXPATHLEN);
+ strlcat(curpath, "/", sizeof(curpath));
+ strlcat(curpath, name, sizeof(curpath));
cdir = opendir(curpath);
checkdir(cdir, curpath, id);
closedir(cdir);
cdir_id = htonl(2);
startdir = opendir(path);
- strncpy(curpath, path, MAXPATHLEN);
+ strlcpy(curpath, path, sizeof(curpath));
checkdir (startdir, path, cdir_id);
closedir(startdir);
}
set_processname("uniconv");
- strlcpy(path, argv[optind], MAXPATHLEN);
-
if ( from_charset == NULL || to_charset == NULL) {
fprintf (stderr, "required charsets not specified\n");
exit(-1);
cnid_type = DEFAULT_CNID_SCHEME;
+ /* check path */
+ strlcpy(path, argv[optind], sizeof(path));
+
+ if (path[0] != '/') {
+ /* deal with relative path */
+ if (chdir(path)) {
+ fprintf (stderr, "ERROR: cannot chdir to '%s'\n", path);
+ return (-1);
+ }
+ path[0] = 0;
+ }
+
if (path[0] == 0) {
- if (NULL == (getcwd(path, MAXPATHLEN)) ) {
- fprintf (stderr, "ERROR: path == NULL\n");
+ /* no path or relative path specified */
+ if (NULL == (getcwd(path, sizeof(path))) ) {
+ fprintf (stderr, "ERROR: getcwd failed\n");
return (-1);
}
- }
+ }
+ /* set charsets */
atalk_register_charset(&charset_iso8859_adapted);
if ( (charset_t) -1 == ( ch_from = add_charset(from_charset)) ) {