[Feature][T8TSK-291]modify the sensitive information in syslog
Only Configure: No
Affected branch: GSW3.0-No-Connman
Affected module: RIL
Is it affected on both ZXIC and MTK: only MTK
Self-test: Yes
Doc Update: No
Change-Id: I740228fa80217eb46ad79efa20d76d9a9da95b5a
diff --git a/framework/lynq-ril-service/src/ril.cpp b/framework/lynq-ril-service/src/ril.cpp
index 011a083..db7d129 100755
--- a/framework/lynq-ril-service/src/ril.cpp
+++ b/framework/lynq-ril-service/src/ril.cpp
@@ -304,6 +304,9 @@
static int responseFailCause(Parcel &p, void *response, size_t responselen);
static int responseStrings(Parcel &p, void *response, size_t responselen);
static int responseString(Parcel &p, void *response, size_t responselen);
+//xf.li@20231120 modify for T8TSK-291 start
+static int responseStringNoLog(Parcel &p, void *response, size_t responselen);
+//xf.li@20231120 modify for T8TSK-291 end
static int responseVoid(Parcel &p, void *response, size_t responselen);
static int responseCallList(Parcel &p, void *response, size_t responselen);
static int responseSMS(Parcel &p, void *response, size_t responselen);
@@ -366,7 +369,10 @@
void initRequestInfo(RequestInfo *pRI, int request, int mode, RIL_SOCKET_ID soc_id);
void getVoiceAndDataRegistrationState(RIL_SOCKET_ID soc_id);
const int waitResponse(int token);
-
+//xf.li@20231120 modify for T8TSK-291 start
+static void encode_log(char str[], int n);
+static void decode_log(char str[], int n);
+//xf.li@20231120 modify for T8TSK-291 end
#ifdef RIL_SHLIB
#if defined(ANDROID_MULTI_SIM)
extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
@@ -2162,7 +2168,20 @@
writeStringToParcel(p, (const char *)response);
return 0;
}
+//xf.li@20231120 modify for T8TSK-291 start
+static int responseStringNoLog(Parcel &p, void *response, size_t responselen) {
+ /* one string only */
+ startResponse;
+ char log_buf[512] = {0};
+ snprintf(log_buf, sizeof(log_buf), "%s", (char*)response);
+ encode_log(log_buf, 6);
+// appendPrintBuf("%s%s", printBuf, "(has got)");
+ closeResponse;
+ writeStringToParcel(p, (const char *)response);
+ return 0;
+}
+//xf.li@20231120 modify for T8TSK-291 end
static int responseVoid(Parcel &p, void *response, size_t responselen) {
startResponse;
removeLastChar;
@@ -2509,11 +2528,99 @@
}
startResponse;
- appendPrintBuf("%slen=%d,%s", printBuf, responselen, (char*)response);
+ //xf.li@20231120 modify for T8TSK-291 start
+ char log_buf[512] = {0};
+ if(strncmp("+CNUM:", (char*)response, strlen("+CNUM:")) == 0)
+ {
+ snprintf(log_buf, sizeof(log_buf), "len=%d,%s", responselen, (char*)response);
+ encode_log(log_buf, 6);
+ }
+ else
+ {
+ appendPrintBuf("%slen=%d,%s", printBuf, responselen, (char*)response);
+ }
+ //xf.li@20231120 modify for T8TSK-291 end
closeResponse;
return 0;
}
+//xf.li@20231120 modify for T8TSK-291 start
+static void string_to_hex(unsigned char *Buff, unsigned int BuffLen, char *OutputStr)
+{
+ int i = 0;
+ char TempBuff[512*2 + 1] = {0};
+ char strBuff[512*2 + 1] = {0};
+ if(BuffLen > 512)
+ {
+ RLOGD("string_to_hex error!");
+ return;
+ }
+ for(i = 0; i<BuffLen;i++)
+ {
+ sprintf(TempBuff,"%02x",(unsigned char)Buff[i]);
+ strncat(strBuff,TempBuff,BuffLen*2);
+ }
+ strncpy(OutputStr, strBuff, BuffLen*2);
+ return;
+}
+
+static void encode_log(char input_str[], int n)
+{
+ char c;
+ int i;
+ char str[512*2 + 1] = {0};
+ string_to_hex((unsigned char *)input_str, strlen(input_str), str);
+ for( i=0; i<strlen(str); i++)
+ {
+ c = str[i];
+ if(c>=' ' && c <= 'z')
+ {
+ if(c + n%90 <= 'z')
+ {
+ str[i] = (char)(c + n%90); //encode
+ }
+ else
+ { //After encoding, the space beyond the end reaches ‘z’, and the cycle starts from the beginning.
+ str[i] = (char)(c + n%90 - 90);//encode
+ }
+ }
+ else
+ {
+ str[i]=c;
+ }
+ }
+
+ appendPrintBuf("%s%s", printBuf, str);
+}
+//decode() only for analysis log
+static void decode_log(char str[], int n)
+{
+ char c;
+ int i;
+
+ for(i=0; i<strlen(str); i++)
+ {
+ c=str[i];
+
+ if(c >= ' ' && c <= 'z')
+ {
+ if(c - n%90 >= ' ')
+ {
+ str[i] = (char)(c - n%90); //decode
+ }
+ else
+ {
+ //After decoding, there are over spaces until ‘z’, and the lowercase letters are processed into printable information by looping
+ str[i] = (char)(c - n%90 + 90); //decode
+ }
+ }
+ else
+ {
+ str[i]=c;
+ }
+ }
+}
+//xf.li@20231120 modify for T8TSK-291 end
static int responseSIM_IO(Parcel &p, void *response, size_t responselen) {
if (response == NULL) {
@@ -5715,7 +5822,7 @@
{
char *pos, *pos2;
int argc = 0;
- printf("warren test cmd=%s\n",cmd);
+ printf("LYNQ_REQUEST cmd=%s\n",cmd);
pos = cmd;
while (1) {
// Trim the space characters.
@@ -6016,7 +6123,7 @@
argc = argc+1;
for(int t = 0;t<argc;t++)
{
- RLOGD("warren test argv[%d]=%s\n",t,argv[t]);
+ RLOGD("LYNQ_REQUEST argv[%d]=%s\n",t,argv[t]);
}
COMMAND *command = find_command(argv[0]);
if(!command)