am d773fc11: am 8c0a0db1: Merge "Change strncpy to strlcpy"

* commit 'd773fc118a30d3273888391ebf9f0ea5a916cd75':
  Change strncpy to strlcpy
gugelfrei
Elliott Hughes 10 years ago committed by Android Git Automerger
commit 450cfd189b

@ -121,7 +121,7 @@ int Loop::lookupActive(const char *id, char *buffer, size_t len) {
errno = ENOENT; errno = ENOENT;
return -1; return -1;
} }
strncpy(buffer, filename, len -1); strlcpy(buffer, filename, len);
return 0; return 0;
} }
@ -191,7 +191,7 @@ int Loop::create(const char *id, const char *loopFile, char *loopDeviceBuffer, s
return -1; return -1;
} }
strncpy(loopDeviceBuffer, filename, len -1); strlcpy(loopDeviceBuffer, filename, len);
int file_fd; int file_fd;

@ -110,7 +110,7 @@ int Process::checkFileDescriptorSymLinks(int pid, const char *mountPoint, char *
if (readSymLink(path, link, sizeof(link)) && pathMatchesMountPoint(link, mountPoint)) { if (readSymLink(path, link, sizeof(link)) && pathMatchesMountPoint(link, mountPoint)) {
if (openFilename) { if (openFilename) {
memset(openFilename, 0, max); memset(openFilename, 0, max);
strncpy(openFilename, link, max-1); strlcpy(openFilename, link, max);
} }
closedir(dir); closedir(dir);
return 1; return 1;
@ -140,7 +140,7 @@ int Process::checkFileMaps(int pid, const char *mountPoint, char *openFilename,
if (path && pathMatchesMountPoint(path, mountPoint)) { if (path && pathMatchesMountPoint(path, mountPoint)) {
if (openFilename) { if (openFilename) {
memset(openFilename, 0, max); memset(openFilename, 0, max);
strncpy(openFilename, path, max-1); strlcpy(openFilename, path, max);
} }
fclose(file); fclose(file);
return 1; return 1;

@ -145,8 +145,7 @@ static int do_monitor(int sock, int stop_after_cmd) {
int code; int code;
char tmp[4]; char tmp[4];
strncpy(tmp, buffer + offset, 3); strlcpy(tmp, buffer + offset, sizeof(tmp));
tmp[3] = '\0';
code = atoi(tmp); code = atoi(tmp);
printf("%s\n", buffer + offset); printf("%s\n", buffer + offset);

Loading…
Cancel
Save