[Feature][ZXW-452]merge P54U02 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I17e6795ab66e2b9d1cbbfec4b7c0028d666e177d
diff --git a/ap/lib/libatext/ext_amt_func.c b/ap/lib/libatext/ext_amt_func.c
index 431819f..569856a 100755
--- a/ap/lib/libatext/ext_amt_func.c
+++ b/ap/lib/libatext/ext_amt_func.c
@@ -2011,6 +2011,7 @@
 	    at_print(AT_ERR,"malloc cmdline_buf fail.\n");

 		return -1;

 	}

+	memset(cmdline_buf,0,CMDLINE_MAX_SIZE);

     //²éÕÒcmdlineÖеÄEnhancedSecurityÊÇ·ñ´æÔÚ

 	cmdline_fd = open("/proc/cmdline", O_RDONLY);

 	if (cmdline_fd < 0) {

@@ -2018,7 +2019,7 @@
 		free(cmdline_buf);

 		return -1;

 	}

-	ret_size = read(cmdline_fd, cmdline_buf, CMDLINE_MAX_SIZE);

+	ret_size = read(cmdline_fd, cmdline_buf, CMDLINE_MAX_SIZE - 1);

 	if(ret_size <= 0)

 	{

 		at_print(AT_ERR,"read /proc/cmdline fail.\n");

@@ -2255,6 +2256,7 @@
 			at_print(AT_ERR,"open %s fail.\n","/dev/otp");

 			*res_msg = at_err_build(ATERR_PROC_FAILED);

 			*res_msglen = strlen(*res_msg);

+			close(efuse_fd);

 			return AT_END;

 		}

 		at_print(AT_ERR,"open %s success.\n","/dev/otp");

@@ -2265,6 +2267,7 @@
 			*res_msg = at_err_build(ATERR_PROC_FAILED);

 			*res_msglen = strlen(*res_msg);

 			close(otp_fd);

+			close(efuse_fd);

 			return AT_END;

 		}

 	

@@ -2349,6 +2352,7 @@
 				*res_msg = at_err_build(ATERR_PROC_FAILED);

 				*res_msglen = strlen(*res_msg);

 				close(otp_fd);

+				close(efuse_fd);

 				return AT_END;

 			}

 			else

@@ -2370,6 +2374,7 @@
 			*res_msg = at_err_build(ATERR_PROC_FAILED);

 			*res_msglen = strlen(*res_msg);

 			close(otp_fd);

+			close(efuse_fd);

 			return AT_END;

 		}

 		 //±£Ö¤Ç°Ã湫Կhashֵд³É¹¦ÁË£¬ÔÙдÈ밲ȫboot flag

@@ -2379,6 +2384,7 @@
 	        *res_msg = at_err_build(ATERR_PROC_FAILED);

 	        *res_msglen = strlen(*res_msg);

 			close(otp_fd);

+			close(efuse_fd);

 	        return AT_END;

 	    }

 		

@@ -2393,6 +2399,7 @@
 	            *res_msg = at_err_build(ATERR_PROC_FAILED);

 	            *res_msglen = strlen(*res_msg);

 				close(otp_fd);

+				close(efuse_fd);

 	            return AT_END;

 	        }

 	        else

@@ -2414,6 +2421,7 @@
 			*res_msg = at_err_build(ATERR_PROC_FAILED);

 			*res_msglen = strlen(*res_msg);

 			close(otp_fd);

+			close(efuse_fd);

 			return AT_END;

 	    }

 

@@ -2424,6 +2432,7 @@
 	        at_print(AT_ERR, "Security flag(%#08X) in otp is not consistent!\n", otpInfo.secureFlag);

 	        *res_msg = at_err_build(ATERR_PROC_FAILED);

 	        *res_msglen = strlen(*res_msg);

+			close(efuse_fd);

 		    return AT_END;

 	    }

 	}