소스 검색

fixed strlen-bomb in run_command

master
Aaron Marcher 8 년 전
committed by Aaron Marcher (drkhsh)
부모
커밋
df928892e8
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. +10
    -1
      slstatus.c

+ 10
- 1
slstatus.c 파일 보기

@@ -453,6 +453,7 @@ ram_used(const char *null)
char *
run_command(const char* command)
{
int good;
FILE *fp;
char buffer[64];

@@ -469,7 +470,15 @@ run_command(const char* command)
pclose(fp);

/* add nullchar at the end */
buffer[strlen(buffer) - 1] = '\0';
for (int i = 0 ; i != sizeof(buffer) ; i++) {
if (buffer[i] == '\0') {
good = 1;
break;
}
}
if (good) {
buffer[strlen(buffer) - 1] = '\0';
}

/* return the output */
return smprintf("%s", buffer);


불러오는 중...
취소
저장